Skip to content

⚡ Bolt: optimize trie normalization and prefix collection - #61

Open
gregyjames wants to merge 2 commits into
mainfrom
bolt-trie-bitmask-normalization-opt-17268167718362437021
Open

gregyjames wants to merge 2 commits into
mainfrom
bolt-trie-bitmask-normalization-opt-17268167718362437021

Conversation

@gregyjames

@gregyjames gregyjames commented Aug 23, 2026 •

Copy link
Copy Markdown
Owner

Implemented performance optimizations in src/hypertrie/src/trie.rs:

  1. Storing bit_idx directly in normalization buffers avoids + b'a' addition during normalization and - b'a' subtraction during Trie node lookup in insert and contains.
  2. Using trailing_zeros bit-twiddling (TZCNT) on children_mask in collect_words_from_node skips empty branches and iterates directly to active child nodes.

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

Summary by CodeRabbit

  • Performance Improvements
    • Improved word and prefix lookup efficiency.
    • Reduced unnecessary processing during trie insertion and traversal.
    • Maintained readable letter output in debugging views.

- Store raw bit index directly in normalization buffer to avoid offset calculations in insert/contains
- Use trailing_zeros on children_mask bitmask in collect_words_from_node to iterate only over active child nodes

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 Aug 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@gregyjames, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

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

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

Wait for the limit to reset, then comment @coderabbitai review or push new commits to the PR.

An organization admin can change what happens after included review limits in Billing.

How do review limits work?

CodeRabbit enforces per-developer PR review limits within each organization.

For paid Pro and Pro+ reviews, CodeRabbit uses a developer's included PR review attempts over the past 7 days to set the current hourly allowance. At typical activity levels, the full plan allowance applies. Higher sustained activity can lower the allowance until earlier attempts leave the 7-day window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a9554cff-2dbc-4263-aef9-4631191eb560

📥 Commits

Reviewing files that changed from the base of the PR and between a872b11 and 2f63ee4.

📒 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: Pro Plus

Run ID: 52793e1f-342c-4db5-8e12-5e8f61b5e79a

📥 Commits

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

📒 Files selected for processing (1)
  • 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

Trie normalization now stores alphabet indices from 0 through 25. Insertion and lookup use these indices directly. Debug output restores letters for display. Prefix traversal visits only set child bits.

Changes

Trie index optimization

Layer / File(s) Summary
Direct alphabet index representation
src/hypertrie/src/trie.rs
Insertion and lookup use direct alphabet indices. Debug output converts indices to lowercase ASCII letters.
Set-bit word traversal
src/hypertrie/src/trie.rs
Word collection iterates set bits in children_mask instead of scanning all 26 alphabet positions.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to a872b

This localized performance optimization introduces no identified correctness or production risk at the current head; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 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 two main changes: optimized trie normalization and prefix collection.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-trie-bitmask-normalization-opt-17268167718362437021

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Aug 23, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #61      +/-   ##
==========================================
+ Coverage   95.83%   98.21%   +2.37%     
==========================================
  Files           3        3              
  Lines         600      615      +15     
  Branches      600      615      +15     
==========================================
+ Hits          575      604      +29     
+ Misses         19        5      -14     
  Partials        6        6              
Flag Coverage Δ
rust 98.21% <100.00%> (+2.37%) ⬆️

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.

- Store raw bit index directly in normalization buffer to avoid offset calculations in insert/contains
- Use trailing_zeros on children_mask bitmask in collect_words_from_node to iterate only over active child nodes
- Add unit test for long strings exceeding 64 bytes to maintain 100% test coverage

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