Optimize leaf prefix search benchmarks - #1635
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR refactors leaf search comparison logic across Go, C, and Rust implementations by removing virtual-key comparators and reconstructing prefix+suffix keys for direct comparison. It adds KeyKind infrastructure to support variable-length and fixed 8-byte big-endian key representations, introduces variable-length key benchmarking tables and generators, optimizes Rust internal storage from heap vectors to fixed-size arrays, and wires new benchmark cases into the test suite. ChangesLeaf search refactoring and variable-length key support
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR optimizes prefix-compressed leaf search by reconstructing fallback keys before comparison and keeps the standalone Go/C/Rust leaf benchmark harnesses aligned with new fixed-BE8 and variable-length search cases.
Changes:
- Removes the virtual prefix comparator and updates production/matched prefix search paths to compare reconstructed keys.
- Adds explicit key-kind handling for fixed-BE8 columnar search in benchmark harnesses.
- Adds variable-length columnar search cases to standalone benchmark outputs and smoke summary.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
TreeDB/node/leaf.go |
Updates production prefix block search fallback comparison logic. |
experiments/rust_leaf_bench/src/main.rs |
Updates Rust benchmark harness data structures and search cases. |
experiments/rust_leaf_bench/run_leaf_smoke.sh |
Adds variable-length row to smoke benchmark summary. |
experiments/rust_leaf_bench/matched_go/main.go |
Aligns matched Go benchmark search cases and fixed-BE8 handling. |
experiments/rust_leaf_bench/matched_c/main.c |
Aligns matched C benchmark search cases and fixed-BE8 handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uint64_t v = 0; | ||
| memcpy(&v, src, sizeof(v)); | ||
| #if defined(__GNUC__) || defined(__clang__) | ||
| return __builtin_bswap64(v); | ||
| #else | ||
| return ((v & 0x00000000000000ffULL) << 56) | ((v & 0x000000000000ff00ULL) << 40) | | ||
| ((v & 0x0000000000ff0000ULL) << 24) | ((v & 0x00000000ff000000ULL) << 8) | | ||
| ((v & 0x000000ff00000000ULL) >> 8) | ((v & 0x0000ff0000000000ULL) >> 24) | | ||
| ((v & 0x00ff000000000000ULL) >> 40) | ((v & 0xff00000000000000ULL) >> 56); | ||
| #endif |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@experiments/rust_leaf_bench/matched_c/main.c`:
- Around line 296-307: The function load_be64_unaligned currently always
byte-swaps the copied uint64_t, which breaks correctness on big-endian hosts;
change it to only swap on little-endian systems (leave the value as-is on
big-endian). Locate load_be64_unaligned and after memcpy use a compile-time
endianness check (e.g. __BYTE_ORDER__ / __ORDER_LITTLE_ENDIAN__ or platform
be64toh/be64toh/ntohll if available) to conditionally call __builtin_bswap64(v)
(or equivalent) only when host is little-endian, otherwise return v unchanged so
BE64 values remain correct on big-endian hosts.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 894d8e11-c186-4117-b893-f94838d2b3f1
📒 Files selected for processing (5)
TreeDB/node/leaf.goexperiments/rust_leaf_bench/matched_c/main.cexperiments/rust_leaf_bench/matched_go/main.goexperiments/rust_leaf_bench/run_leaf_smoke.shexperiments/rust_leaf_bench/src/main.rs
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 1 file(s) based on 1 unresolved review comment. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 1 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Summary
Validation
cargo build --release --manifest-path experiments/rust_leaf_bench/Cargo.tomlcc -O3 -std=c11 -Wall -Wextra experiments/rust_leaf_bench/matched_c/main.c -o /tmp/treedb_leaf_matched_c_pr_checkgo test ./TreeDB/node -run 'TestLeafColumnarPrefix|TestLeafPrefix|TestLeafColumnar' -count=1go test ./TreeDB/node -run '^$' -bench 'BenchmarkSearchLeaf_(PrefixV2|ColumnarPrefixV2)$' -benchtime=2s -count=3Focused prefix benchmark on this branch:
For comparison, clean origin/main in the same temporary worktree measured:
Final integrated smoke:
BENCHTIME=2s ./run_leaf_smoke.shKey rows from the final smoke:
Summary by CodeRabbit
New Features
Refactor
Chores