Skip to content

⚡ Bolt: Replace HashSet with Vec for block IDs tracking during output compaction - #83

Merged
ovasylenko merged 2 commits into
mainfrom
bolt/hashset-to-vec-output-compaction-14973451970852441863
Jul 6, 2026
Merged

⚡ Bolt: Replace HashSet with Vec for block IDs tracking during output compaction#83
ovasylenko merged 2 commits into
mainfrom
bolt/hashset-to-vec-output-compaction-14973451970852441863

Conversation

@ovasylenko

Copy link
Copy Markdown
Contributor

💡 What:
The collect_body_block_ids function in orch8-engine/src/evaluator.rs was allocating and cloning Strings (BlockId) into a HashSet on the hot execution path when compacting iteration outputs. I replaced HashSet with Vec<&BlockId> and adjusted the iteration to use .sort_unstable(), .dedup(), and .binary_search().

🎯 Why:
String allocation and hashing have a measurable overhead in hot loops. During loop iterations where we do output compactions, cloning large numbers of identifiers hurts throughput. Replacing the map with a zero-allocation vector reference lookup bypasses this constraint and mirrors performance principles observed in orch8-engine where similar optimizations exist.

📊 Impact:
Eliminates O(N) heap allocations for block ID collection entirely on loop body traversal. Based on comparable operations in rust, avoiding String cloning combined with .binary_search is markedly faster for smaller block tracking limits than a clone-heavy Hashset map.

🔬 Measurement:
Testing confirms exact behavioral compatibility passing cargo test -p orch8-engine --lib evaluator::tests.


PR created automatically by Jules for task 14973451970852441863 started by @ovasylenko

…utput compaction

Avoids allocating and deep cloning `String` based `BlockId`s repeatedly during execution loop compaction by passing a `Vec<&BlockId>` and utilizing `.sort_unstable()` and `.dedup()` coupled with `.binary_search()`.

Co-authored-by: ovasylenko <3797513+ovasylenko@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.

…utput compaction

Avoids allocating and deep cloning `String` based `BlockId`s repeatedly during execution loop compaction by passing a `Vec<&BlockId>` and utilizing `.sort_unstable()` and `.dedup()` coupled with `.binary_search()`.

Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
@ovasylenko
ovasylenko merged commit 084bb87 into main Jul 6, 2026
14 checks passed
@ovasylenko
ovasylenko deleted the bolt/hashset-to-vec-output-compaction-14973451970852441863 branch July 16, 2026 00:10
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