Skip to content

perf(writer): bit-packing encode ~45% faster, byte-identical (#475) - #480

Merged
dfa1 merged 1 commit into
mainfrom
perf/475-bitpack-encode
Oct 9, 2026
Merged

dfa1 merged 1 commit into
mainfrom
perf/475-bitpack-encode

Conversation

@dfa1

@dfa1 dfa1 commented Oct 9, 2026

Copy link
Copy Markdown
Owner
  • Pack each lane's words in a register; store a block at a time (no segment read-back, width switch once per block).
  • Min/max + bit-width histogram in one pass (memory-bound: one read beats a vectorized separate pass).
  • Patch count from the histogram: skip the scan when none; primitive arrays instead of boxed lists.

Microbench (10M values, 11 bits): U16/U32/U64 37/40/36 → 22/20/18 ms. Output SHA-256 unchanged across every ptype, widths, lengths 0..5000, with patches. JMH javaWriteCascading -f 3: 0.902 → 0.939 ops/s.

Not done: taking min/max from the cascade's stats as Rust does — needs an EncodingEncoder API change, and the fused pass already removes most of that cost.

Closes #475

🤖 Generated with Claude Code

https://claude.ai/code/session_015R8cf8YM8XFQqrkyhSAtYr

…475)

- packFastLanes builds each lane's words in a register and stores a block
  at a time: no read-back of the segment, and the per-width store switch
  runs once per block instead of once per word.
- Min/max and the bit-width histogram share one pass: the loop is
  memory-bound, so one read of the values beats a separately vectorized
  min/max pass.
- The patch count comes from the histogram: no scan when there are no
  patches, and exact-size primitive arrays instead of boxed lists.

10M values at 11 bits: U16/U32/U64 37/40/36 -> 22/20/18 ms; output
SHA-256 unchanged over every ptype, widths, lengths 0..5000 and patches.
JMH javaWriteCascading (-f 3): 0.902 -> 0.939 ops/s. A four-way
interleaved histogram was tried and measured no gain.

The new multi-block test also decodes patched arrays, which the existing
tests never did (their registry had no primitive decoder).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015R8cf8YM8XFQqrkyhSAtYr
@dfa1
dfa1 merged commit abb76da into main Oct 9, 2026
6 checks passed
@dfa1
dfa1 deleted the perf/475-bitpack-encode branch October 9, 2026 10:57
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.

Bit-packing encode costs ~2x Rust's CPU

1 participant