⚡ Bolt: Replace HashSet with Vec for block IDs tracking during output compaction - #83
Conversation
…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>
|
👋 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 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>
💡 What:
The
collect_body_block_idsfunction inorch8-engine/src/evaluator.rswas allocating and cloning Strings (BlockId) into aHashSeton the hot execution path when compacting iteration outputs. I replacedHashSetwithVec<&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-enginewhere 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_searchis 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