Repository navigation
Conversation
|
Several concerns here:
|
|
I measured it before changing anything, and you were right on the main point: the cost is mostly bad usage. Why it rescans. The DWARF line store calls Small sets. Over the 108 DWARF files in testbins, 94 pools get adds; the median has 3 distinct strings and 90 have 256 or fewer. With no duplicate locality, the bloom beats a hash table from 64 to 256 strings, and a plain scan beats both below about 32. So a table should not be the default for small pools. Memory. The HtPP in this PR copies every key, so the index holds a second copy of every string: 350 KB on libc against 105 KB for the whole pool today. Keying by string hash to position avoids the copy (139 KB), but none of this shows in peak RSS (495 MB for that load). What fixes it. The same string arrives on consecutive rows 61-98% of the time, so remembering the last hit is enough:
I would replace this PR with the last-hit check alone: about ten lines in |
|
Yeah an extra concern for me is that the kashrable keys are strdups and considering we hold them all in a string pool we can just store the offset inside that pool instead and that will require a different htpp monster (change the callbacks that implement the keydup and such). |
|
The last hit thing for dupped checks is probably the best approach for this usecase but not for all thats why i think we can have a better strpool policy to handle different usecases in a better way |
Description
Half of the time spent loading a binary with a large DWARF line table goes into
r_strpool_add: the pool's 1024-bit bloom saturates after a few hundred strings, andr_strpool_getthen compares every pooled string on every call (the function carries anXXX this is O(n)comment). The addrline store interns the file name twice per row, so a libc with 1553 source files and 600k rows does about 10^8strcmpcalls.With this PR the same load takes 1.84 s wall and 1.82 user on the same box; callgrind attributed 48% of the instructions to the pool scan before.
RStrpoolkeeps anHtPPfrom string to position instead of the bloom. It is built on the firstr_strpool_get/r_strpool_add, so an append-only user (corelog) never pays for it, andr_strpool_appendkeeps it in sync once it exists.slice,slice_rangeandemptydrop it, since positions move.r_strpool_addisgetorappend; a repeatedappendof the same string still returns a new position whilegetkeeps answering the first one, as the scan did.test/unit/test_strpool.ccovers dedup, append-then-get, 5000 strings across pool growth, and lookups afterslice_rangeandempty; the pool's visible behaviour is unchanged, so no golden moves and the numbers above are the evidence. A failedreallocin the pool used to free the old buffer and leave the positions pointing at it; it now keeps the buffer and reports the failure.