Repository navigation
⚡ Bolt: [Replace .collect() chains in deep tree BFS with pre-allocated loops] - #395
ovasylenko wants to merge 2 commits into
Conversation
…re-allocated vectors Replaces `.filter_map(...).collect()` iterators with manual loops and `Vec::with_capacity(tree.len())` when building the `children_of` index in deep tree BFS traversal functions. This eliminates repeated memory reallocations on execution hot paths. 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. |
- Update pulldown-cmark to fix RUSTSEC-2026-0433 - Update inout and winnow to latest to fix yanked/ambiguous dependency - Update minimatch via pnpm overrides to fix GHSA-g3hv-75wg-m249 Co-authored-by: ovasylenko <3797513+ovasylenko@users.noreply.github.com>
💡 What: Replaced
.filter_map(|...| ...).collect()chains in deep execution tree traversals (cancel_subtree,reset_subtree_to_pending,skip_subtrees,settle_live_descendants) with manual loops pushing to aVecinstantiated withVec::with_capacity(tree.len()).🎯 Why: When
.collect()consumes an iterator resulting from.filter_map(), it has no size hint, forcing the underlyingVecto allocate and reallocate multiple times as elements are appended. Because every node in a tree has at most one parent, the number of parent-child relationships cannot exceedtree.len(). Pre-allocating to this known upper bound entirely eliminates allocator churn and reallocation overhead in the cancellation, skipped, and reset hot paths.📊 Impact: Reduces heap allocations and completely eliminates vector reallocations during deep subtree traversals, lowering CPU overhead and latency during cancellation or iterative evaluation ticks.
🔬 Measurement: Verify via execution tests
cargo +nightly test -p orch8-engine --features orch8-storage/postgres evaluatorand observe reduced allocation metrics in memory profiling on deep nested Parallel/ForEach workflows.PR created automatically by Jules for task 12025759494752385837 started by @ovasylenko