Repository navigation
[core] Keep the rbm32 and rbm64 union decoded between rows - #1568
JeonDaehong wants to merge 2 commits into
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
Keeping the union decoded has clear value for high-cardinality aggregates. I ran 5,286 core and primary-key table tests on 57677458, including a new write, commit, scan, and compaction probe. The probe found a release-mode write latency regression for fragmented rbm64 inputs.
| Entry::Vacant(vacant) => { | ||
| vacant.insert(container); | ||
| } | ||
| Entry::Occupied(mut occupied) => occupied.get_mut().union(container), |
There was a problem hiding this comment.
[P2] Promote fragmented rbm64 unions to a bitset as they grow. I wrote a single batch of 32,768 rows to one key in an aggregation table with fields.bitmap.aggregate-function=rbm64. Each row holds a singleton bitmap for (1 << 40) + 2 * i, so all values share a high-48-bit container and remain fragmented. Three release runs measured 177–190 ms for write through commit on e4b84b47 and 625–640 ms on this head. The union bytes matched before and after compaction.
On main, intermediate encoding promotes fragmented containers to bitsets, which the next union decodes as Words. With the decoded accumulator, each singleton stays on Ranges::union and sorts and scans the growing range list. Please promote dense, fragmented ranges in memory using the same size threshold as encoding, and include this input shape in the benchmark.
There was a problem hiding this comment.
Thanks @JingsongLi, reproduced it with your shape: 914–922 ms on the previous head, 278–279 ms on main (write through commit, 3 runs). A range list now turns into a bitset as soon as encoding would write it as one (more than 4096 values and at least 2048 runs), and a single incoming range is inserted in place instead of re-sorting the whole list. Your shape takes 12 ms now. I added it to the benchmark along with runs of three values and random values in one container, and the output bytes match main for every shape. Updated numbers are in the description (14b0d6d).
Purpose
Closes #1567.
rbm32andrbm64deserialized and re-serialized the accumulated bitmap for every row, so a key with many rows took time quadratic in its bitmap size.Brief change log
result()serializes the union. A lone input is still returned unchanged.rbm64, a range list becomes a bitset once encoding would write it as one (more than 4096 values and at least 2048 runs), and a single incoming range is inserted in place.Tests
keeps_a_lone_input_and_resets_the_unionin both files checks that a lone Java input is returned byte for byte, that the union is right, and thatresetclears it.merge_and_insert_ranges_match_sort_and_normalizecompares the range merge with sort and normalize on random inputs, and two more tests check that the promoted bitset encodes to the same bytes.Measured on c7i.8xlarge, release build, main and this branch alternated 3 times (ranges across runs). The output bytes hash the same on both for every shape.
Writing one commit through a table with
rbm32:Same with
rbm64(frag2is every other value, as in the review):frag2)Aggregating directly, 1 key with N single-value bitmaps:
One input per key is unchanged (25–26 ms for 100,000 keys either way). Three inputs per key, 100,000 keys: rbm32 81 → 60 ms, rbm64 130–134 → 98–99 ms. Random values in one container (50,000 inputs) take 464 → 11 ms in
rbm64.API and Format
No public API or storage format changes.
Documentation
None.