Repository navigation
Conversation
… encoding bench Co-authored-by: Isaac <no-reply@databricks.com>
…ive width The encoder kept INT32 deltas as i64, so its per-block min and per-miniblock max reductions ran on 64-bit lanes, which the baseline x86-64 target can only emulate, and the per-value put loop did block bookkeeping for every value. - put fills a block a slice at a time, so the delta loop vectorizes - INT32 deltas are stored, reduced and packed as i32/u32 - each miniblock's bit width comes from OR-ing the adjusted deltas while they are rewritten in place, replacing the max reduction (same bit width: every adjusted delta is non-negative) - the padded tail of the last miniblock is packed with the miniblock instead of a put_value per padding slot Output is byte-identical. Co-authored-by: Isaac <no-reply@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
None.
Rationale for this change
On the default x86-64 target,
DeltaBitPackEncoderspends most of its time in reductions that theCPU can only emulate:
i64, so the per-blockminand per-miniblockmaxrun on 64-bitlanes. SSE2 has no 64-bit compare, so each reduction costs about 10 instructions per 2 values.
putchecks for a full block after every value, so the delta loop can't vectorize.Profile of INT32 encoding on main:
flush_block_values57%,put26%.What changes are included in this PR?
putfills each block a slice at a time. It is#[inline], so callers that put one value at atime, like the Arrow writer's DELTA_BYTE_ARRAY lengths, keep it in their loop.
i32/u32for INT32).this equals the bit width of their maximum. The OR is fused into the loop that subtracts the
minimum, which removes the max pass.
put_valueper padding slot.Output is byte-identical.
The first commit adds the benchmark cases, so it can serve as the benchmark baseline. #12273 starts
with the same commit.
Are these changes tested?
Covered by the existing encoder round-trip tests. Output was also checked to be byte-identical to
main's on more than 2,600 inputs: every block layout, several
putchunkings, page splits, andsorted, random, constant, arithmetic, extreme and bursty data.
The first commit adds DELTA_BINARY_PACKED cases to the
encodingbench: 16K values, well predicted(sorted, small gaps) and poorly predicted (uniformly random). The encoder is reused across
iterations, as the column writer reuses it across pages. Measured on an Intel Xeon Platinum 8559C,
default x86-64 target, median of 3-5 alternating rounds:
encodingbenchFilling blocks a slice at a time gives 1.23-1.29x on its own. The rest comes from the native width
and the fused OR.
In
arrow_writer,primitive_non_null/parquet_2is 1.21x faster. String columns withparquet_2,which put one length at a time, are 1.00-1.02x. The default-property cases don't use this encoder
and stayed within ±3%.
None of the measured inputs got slower. For INT64 the block minimum over
i64is still emulated onSSE2;
x86-64-v2builds vectorize it. Not measured on aarch64, which has 64-bit vector compares,so the gain there may be smaller.
Are there any significant user-facing changes?
No.
AI usage disclosure
An AI coding agent (Claude Code) generated the code, the benchmark cases and this description, and
ran the benchmarks and the output checks. This PR is a draft until the submitter has reviewed it.
This pull request and its description were written by Isaac.