Skip to content

[core] Keep the rbm32 and rbm64 union decoded between rows - #1568

Open
JeonDaehong wants to merge 1 commit into
apache:mainfrom
JeonDaehong:rbm-keep-decoded-union
Open

JeonDaehong wants to merge 1 commit into
apache:mainfrom
JeonDaehong:rbm-keep-decoded-union

Conversation

@JeonDaehong

Copy link
Copy Markdown
Contributor

Purpose

Closes #1567.

rbm32 and rbm64 deserialized 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

  • The accumulator keeps the first input as bytes. The second input decodes it once, and later inputs are unioned into the decoded bitmap.
  • result() serializes the union. A lone input is still returned unchanged.

Tests

keeps_a_lone_input_and_resets_the_union in both files checks that a lone Java input is returned byte for byte, that the union is right, and that reset clears it.

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:

rows main this PR
1 key × 100,000 7,053–7,066 ms 144–145 ms
100 keys × 1,000 204–205 ms 94 ms
100,000 keys × 3 288–291 ms 266–276 ms

Aggregating directly, 1 key with N single-value bitmaps:

N rbm32 main rbm32 PR rbm64 main rbm64 PR
10,000 84 ms 10–11 ms 337–339 ms 15 ms
100,000 7,120–7,123 ms 116 ms 31,030–31,077 ms 163–164 ms

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 129 → 98 ms.

API and Format

No public API or storage format changes.

Documentation

None.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rbm32 and rbm64 aggregation re-serialize the bitmap for every row

2 participants