Skip to content

⚡ Bolt: batch save state updates for better performance#783

Open
georgi wants to merge 1 commit intomainfrom
bolt-save-many-optimization-12008955676744676120
Open

⚡ Bolt: batch save state updates for better performance#783
georgi wants to merge 1 commit intomainfrom
bolt-save-many-optimization-12008955676744676120

Conversation

@georgi
Copy link
Contributor

@georgi georgi commented Mar 18, 2026

💡 What: Implement save_many method in Database Adapters (SQLite, PostgreSQL, Supabase) to handle bulk list of dicts. Update DBModel base class to add a save_many class method that exposes this interface to other classes. Update StateManager to use RunNodeState.save_many over iterating through instances calling state.save() for each one.
🎯 Why: StateManager handles bulk enqueued states from executing workflow nodes but processed them with single row updates. This causes high DB roundtrips and slows down node executions with large DAGs.
📊 Impact: Eliminates N+1 writes in StateManager._process_batch. Significant reduction in DB write time/latency, leading to lower node start/stop latencies.
🔬 Measurement: Can be observed with large graphs by tracking the duration of _process_batch.


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

Adds `save_many` to Database Adapters and uses it to perform a batch `insert or update` of `RunNodeState` instances in `StateManager`, reducing database roundtrips and resolving the N+1 latency issues.

Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
@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.

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