Repository navigation
perf(encoding): accelerate dictionary interning, sampling, and decode gather - #10911
Merged
Merged
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
BubbleCal
approved these changes
Nov 12, 2026
Xuanwo
added a commit
that referenced
this pull request
Nov 12, 2026
Main's `ci` profile lint fails with `clippy::undocumented_unsafe_blocks` at `DictionaryDataBlock::gather_variable_width_typed` (`data.rs:1200`), which blocks the full Rust lint for every PR in the workspace, #10750 included. The existing `SAFETY:` note sits inside the outer unsafe block, so it justifies the unchecked offset reads but leaves the block itself undocumented. This moves the justification above the block and extends it to cover the rest of it: the index/offset bounds proven by `validate_offsets_for_append` and the first pass, `total_bytes` fitting both `usize` and `T`, the two output allocations being disjoint from the dictionary data, and every rebased offset and payload byte being written before the `set_len` calls. Comment-only; no runtime change. Context: the block came in with #10911. Validation on this branch: `cargo fmt --all -- --check` and `cargo clippy --profile ci --all --tests --benches -- -D warnings` both pass.
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.
Summary
Optimize dictionary encoding, cardinality sampling, and dictionary-to-Arrow materialization in
lance-encodingwhile preserving 100% wire-format and behavioral compatibility:DictionaryDataBlockgather & single-pass dictionary validation (data.rs):DataBlockBuildervirtual dispatch (Ndyn append_validatedcalls, repeatedoffsetsreallocations, and per-rowArcclones on nullable validity) with direct typed gather paths for 32/64-bitVariableWidthBlock(exact byte-size precomputation inu128+ single-passcopy_nonoverlappingand offset rebasing),FixedWidthDataBlock(8/16/32/64/128-bit and arbitrary byte-aligned widths), andNullableDataBlock(BooleanBuffer::collect_bool), falling back cleanly when unreferenced dictionary entries contain malformed offsets.DictionaryDataBlock::into_arrow(dict.validate_layout(&data_type)) and construct the expandedVariableWidthBlockviainto_arrow_unchecked, avoiding redundant UTF-8 and offset re-validation across allNexpanded rows while preserving fallback semantics for partially referenced dictionaries.CompactInternerfor dictionary encoding (encodings/logical/primitive/dict.rs):std::collections::HashMap<U8SliceKey, i32>(SipHash-1-3+ 24-byte fat-pointer slots into cold input pages + per-row budget checks) acrossdict_encode_variable_width,dictionary_encode(64/128-bit), andencode_fixed_rowswith a compact open-addressingu32slot table (4bytes/slot) backed byxxh3_64/mix_u64, canonicaldictionary_buffercomparisons, a 1-entry MRU consecutive-run fast path, and vacant-insertion-only byte budget tracking.sample_unique_ratio(encodings/logical/primitive/structural_encoder.rs):Vec<usize>sample-index allocation, pre-sizeHashSettototal_samples, and replaceSipHash-1-3(including double-hashing ofxxh3_64outputs on variable-width pages) withFastSampleHasher/IdentityU64Hasher.Benchmark Results
End-to-end Lance v2.2
FileWriter+FileReaderover in-memoryObjectStore, 7 alternating AB/BA paired rounds (9timed iterations after3warmups per round) pinned to a single physical core onAMD EPYC 4585PX:control_fullzip_bin512_scan_4mib(control)dict_i64_128_card_scan_524kdict_i64_128_card_write_524kdict_utf8_low_card_scan_524kdict_utf8_nullable_1k_card_scan_262kdict_utf8_low_card_write_524kdict_utf8_nullable_1k_card_write_262kTest Plan
CompactInternerprobing/rehash equivalence (cargo test -p lance-encoding --lib)cargo test -p lance-file --lib)cargo fmt --alland full workspacecargo clippy --all --tests --benches -- -D warnings