Skip to content

⚡ Bolt: optimize trie traversal and bloom filter hashing - #68

Open
gregyjames wants to merge 2 commits into
mainfrom
perf/optimize-trie-traversal-and-bloom-hashing-7413189709073019543
Open

gregyjames wants to merge 2 commits into
mainfrom
perf/optimize-trie-traversal-and-bloom-hashing-7413189709073019543

Conversation

@gregyjames

@gregyjames gregyjames commented Sep 20, 2026 •

Copy link
Copy Markdown
Owner

Implemented three targeted optimizations in native Rust HyperTrie backend:

  1. Replaced scalar multiplication i * h2 inside BloomFilter hashing loop with additive update hash += h2.
  2. Stored direct 0..25 bit indices in string normalization buffers to eliminate + b'a' and - b'a' arithmetic operations during Trie traversal.
  3. Compacted Node struct from 112 bytes to 108 bytes by encoding end_of_word into bit 31 of children_mask and removing unused fields.

Impact: Reduces native HyperTrie benchmark execution time from 22.91 ms to 21.66 ms (~5.5% speedup). All unit tests pass.


PR created automatically by Jules for task 7413189709073019543 started by @gregyjames

Summary by CodeRabbit

  • Performance

    • Improved internal word lookup and insertion efficiency.
    • Reduced memory usage for trie data, potentially improving cache performance.
    • Optimized Bloom filter index generation while preserving existing filtering behavior.
  • Maintenance

    • Updated development tooling to ignore generated build and benchmark artifacts.
    • Added internal documentation covering implementation optimizations.

- Replace scalar multiplication inside Bloom filter loop with additive accumulation (`hash += h2`)
- Store direct 0..25 bit indices in character normalization buffer to eliminate ASCII offset math during trie traversal
- Compact Trie Node struct by encoding `end_of_word` into bit 31 of `children_mask` and removing unused struct fields

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 16ab4514-3765-4241-8d18-70d6774311cc

📥 Commits

Reviewing files that changed from the base of the PR and between f10154d and d5fc311.

📒 Files selected for processing (1)
  • src/hypertrie/src/trie.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: f838ac8c-e591-4c46-b075-a74b82b00f8e

📥 Commits

Reviewing files that changed from the base of the PR and between 22ccc67 and f10154d.

⛔ Files ignored due to path filters (1)
  • src/HyperTrieCore/runtimes/linux-x64/native/libhypertrie.so is excluded by !**/*.so
📒 Files selected for processing (4)
  • .gitignore
  • .jules/bolt.md
  • src/hypertrie/src/bloom_filter.rs
  • src/hypertrie/src/trie.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The trie now stores word-end state in its child bitmask and uses direct character indices during traversal. Bloom filter indexing uses incremental hashing. The repository also ignores generated benchmark and build directories.

Changes

HyperTrie optimizations

Layer / File(s) Summary
Trie representation and traversal
src/hypertrie/src/trie.rs, .jules/bolt.md
Node stores word-end state in children_mask. Trie insertion, lookup, debugging, and word collection use direct bit indices.
Bloom filter index generation
src/hypertrie/src/bloom_filter.rs
Bloom filter operations and the test helper use a running hash value to generate slot indices.

Repository housekeeping

Layer / File(s) Summary
Ignore generated artifacts
.gitignore
The ignore file excludes BenchmarkDotNet artifacts and build output directories.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: optimizing trie traversal and Bloom filter hashing. It is concise and directly related to the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 2 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.22%. Comparing base (d35e0e1) to head (d5fc311).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
+ Coverage   95.83%   98.22%   +2.39%     
==========================================
  Files           3        3              
  Lines         600      620      +20     
  Branches      600      620      +20     
==========================================
+ Hits          575      609      +34     
+ Misses         19        5      -14     
  Partials        6        6              
Flag Coverage Δ
rust 98.22% <100.00%> (+2.39%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

- Replace scalar multiplication inside Bloom filter loop with additive accumulation (`hash += h2`)
- Store direct 0..25 bit indices in character normalization buffer to eliminate ASCII offset math during trie traversal
- Compact Trie Node struct by encoding `end_of_word` into bit 31 of `children_mask` and removing unused struct fields
- Add unit tests for long strings (> 64 bytes) and non-alphabetic character filtering

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
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.

1 participant