Skip to content

⚡ Bolt: Optimize GroupNode child loop performance#2218

Merged
georgi merged 4 commits intomainfrom
bolt/perf-group-node-child-check-17338441262491056562
Mar 21, 2026
Merged

⚡ Bolt: Optimize GroupNode child loop performance#2218
georgi merged 4 commits intomainfrom
bolt/perf-group-node-child-check-17338441262491056562

Conversation

@georgi
Copy link
Collaborator

@georgi georgi commented Mar 18, 2026

⚡ Bolt: GroupNode Child Check Performance Optimization

💡 What

Refactored GroupNode.tsx to combine two separate useNodes subscriptions into a single optimized for loop that checks for children and bypassed children simultaneously.

🎯 Why

Previously, every GroupNode on the canvas subscribed to state.nodes using two separate .some() loops.
Because ReactFlow updates the nodes array reference on every drag frame (60fps), these loops ran continuously during interactions.
This caused O(G * N) operations per frame (where G = number of group nodes, N = total nodes), taking up valuable main thread time.

📊 Impact

  • Reduces Main Thread Work: Combines two O(N) array iterations into a single loop.
  • Early Exit: The loop stops as soon as both conditions (hasChildren and someChildrenBypassed) are met, further reducing iteration time.
  • Improved Responsiveness: Smoother node dragging when workflows contain Group Nodes.

🔬 Measurement

Verify by checking the React Profiler during node drag operations with multiple group nodes. The useNodes selector execution time within GroupNode will be significantly reduced.

🧪 Testing

  • Ran cd web && pnpm typecheck: Passed.
  • Ran cd web && pnpm lint: Passed.
  • Ran make test-web: Verified core tests pass.

PR created automatically by Jules for task 17338441262491056562 started by @georgi

@google-labs-jules
Copy link
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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 18, 2026

Deploying nodetool with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2e57ab4
Status: ✅  Deploy successful!
Preview URL: https://ff26f584.nodetool.pages.dev
Branch Preview URL: https://bolt-perf-group-node-child-c.nodetool.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 18, 2026

Deploying nodetool-staging with  Cloudflare Pages  Cloudflare Pages

Latest commit: addaf6d
Status:⚡️  Build in progress...

View logs

Copy link
Collaborator Author

georgi commented Mar 21, 2026

Code changes reviewed and approved - the GroupNode optimization with combined selector, early exit, and reference caching is correct and well-implemented.

However, this PR has merge conflicts (likely in lock files) that prevent merging. Please rebase on latest main to resolve the conflicts, then this can be merged.

google-labs-jules bot and others added 3 commits March 21, 2026 08:30
Combines two independent `O(N)` `.some()` iterations over `state.nodes` into a single optimized `for` loop with an early exit. Memoizes the returned object reference to prevent unnecessary component re-renders during React Flow drag updates.

Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
Updates package-lock.json in web, electron, and mobile workspaces to resolve `npm error EUSAGE` conflicts during `npm ci` in GitHub Actions.

Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
Replaces inline `require` with standard ES6 import and type casting to resolve `@typescript-eslint/no-require-imports` failure.

Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
@georgi georgi force-pushed the bolt/perf-group-node-child-check-17338441262491056562 branch from 2e57ab4 to 50b05db Compare March 21, 2026 08:30
@georgi georgi merged commit 573b887 into main Mar 21, 2026
4 of 5 checks passed
@google-labs-jules
Copy link
Contributor

Code changes reviewed and approved - the GroupNode optimization with combined selector, early exit, and reference caching is correct and well-implemented.

However, this PR has merge conflicts (likely in lock files) that prevent merging. Please rebase on latest main to resolve the conflicts, then this can be merged.

I've rebased the branch on top of the latest main, resolved any conflicts, and pushed the updated branch. I also resolved the preexisting linting issue (@typescript-eslint/no-require-imports) in JobItem.test.tsx that caused a CI failure.

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