Skip to content

Pack richer compact masked sort keys - #147

Open
aneubeck wants to merge 4 commits into
mainfrom
aneubeck-compact-masked-sort-key
Open

Pack richer compact masked sort keys#147
aneubeck wants to merge 4 commits into
mainfrom
aneubeck-compact-masked-sort-key

Conversation

@aneubeck

Copy link
Copy Markdown
Collaborator

Summary

  • derive a proven maximum bucket position from each geometric configuration, while keeping a conservative full-type default for custom configurations
  • pack complete masked bucket positions at the resulting width and use leftover key bits for an order-preserving prefix of the next position
  • add randomized ordering properties and focused maximum-position, partial-prefix, absent-position, and bucket-zero coverage for GeoDiffConfig7/10/13
  • include GeoDiffConfig10 in the masked-sort Criterion benchmark

Packing

  • GeoDiffConfig7: 14 bits per position; 4 complete positions + 8 high bits of the fifth
  • GeoDiffConfig10: 17 bits per position; 3 complete positions + 13 high bits of the fourth
  • GeoDiffConfig13: 20 bits per position; 3 complete positions + 4 high bits of the fourth

The trailing prefix is monotonic: if it differs, its ordering is the ordering of the full next position; if it does not differ, callers retain the existing cmp_masked fallback.

Validation

  • cargo test -p geo_filters --all-features
  • cargo test -p geo_filters --doc --all-features
  • repository-style Clippy checks for the library and tests
  • cargo bench -p geo_filters --bench masked_sort --no-run
  • cargo bench -p geo_filters --bench masked_sort -- --noplot

Measured absolute Criterion medians on this machine (not a before/after speedup claim):

Config cmp_masked sort sort_key sort key construction
7 632.37 µs 27.726 µs 16.174 µs
10 744.53 µs 25.361 µs 14.140 µs
13 861.25 µs 26.039 µs 14.664 µs

Use configuration-derived bucket widths to fit more complete masked positions and an order-preserving prefix of the next position into each u64 key.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 24, 2026 07:59
@aneubeck
aneubeck requested a review from a team as a code owner August 24, 2026 07:59

Copilot AI 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.

Pull request overview

Compacts masked sort keys using configuration-specific bucket bounds, improving sort efficiency.

Changes:

  • Adds maximum bucket-position bounds and denser key packing.
  • Expands ordering tests and benchmarks GeoDiffConfig10.
  • Corrects the maximum geometric bucket calculation.
Show a summary per file
File Description
crates/geo_filters/src/diff_count.rs Implements compact key packing and tests.
crates/geo_filters/src/config/buckets.rs Corrects the inclusive maximum bucket.
crates/geo_filters/src/config.rs Exposes configuration bucket bounds.
crates/geo_filters/evaluation/masked_sort.rs Adds GeoDiffConfig10 benchmarks.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

for _ in 0..complete_positions {
let position = positions.next().unwrap_or(0);
debug_assert!(position <= max_position);
key = (key << position_bits) | position;
Let configurations provide the required bucket-position bit width directly so masked key packing does not derive it from an intermediate maximum.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f922e63e-969b-47b1-86a0-3a54220589f2
Make the shared configuration helper expose the required bit count directly and reuse it for bucket-type validation.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f922e63e-969b-47b1-86a0-3a54220589f2
Use the exact b + 7 bit-width identity for the maximum geometric bucket position.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f922e63e-969b-47b1-86a0-3a54220589f2
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.

3 participants