Skip to content

⚡ Bolt: [Replace .collect() chains in deep tree BFS with pre-allocated loops] - #395

Closed
ovasylenko wants to merge 2 commits into
mainfrom
bolt-evaluator-collect-12025759494752385837
Closed

ovasylenko wants to merge 2 commits into
mainfrom
bolt-evaluator-collect-12025759494752385837

Conversation

@ovasylenko

Copy link
Copy Markdown
Contributor

💡 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 a Vec instantiated with Vec::with_capacity(tree.len()).

🎯 Why: When .collect() consumes an iterator resulting from .filter_map(), it has no size hint, forcing the underlying Vec to 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 exceed tree.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 evaluator and observe reduced allocation metrics in memory profiling on deep nested Parallel/ForEach workflows.


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

…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>
@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.

- 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>
@ovasylenko ovasylenko closed this Nov 14, 2026
@ovasylenko
ovasylenko deleted the bolt-evaluator-collect-12025759494752385837 branch November 19, 2026 04:21
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