Skip to content

⚡ Bolt: Optimize SessionManager.list_sessions#39

Draft
google-labs-jules[bot] wants to merge 1 commit intomainfrom
bolt-optimize-list-sessions-4785286200393040658
Draft

⚡ Bolt: Optimize SessionManager.list_sessions#39
google-labs-jules[bot] wants to merge 1 commit intomainfrom
bolt-optimize-list-sessions-4785286200393040658

Conversation

@google-labs-jules
Copy link

💡 What

This change optimizes the SessionManager.list_sessions method by fixing an N+1 query problem and batching database updates.

🎯 Why

The previous implementation executed a separate database query inside a loop for each running child session to check its parent's status. This caused a significant number of database calls, slowing down the list command, especially with many active sessions.

📊 Impact

Reduces the number of database SELECT queries from O(N) to a constant O(1) (specifically, from N+1 queries to 2 in the test case) and consolidates all UPDATE queries into a single transaction. This makes listing sessions significantly faster and more efficient.

🔬 Measurement

The performance improvement was validated using a temporary benchmark test that counted the number of SQL queries executed by the method. The test confirmed a reduction from 6 SELECT queries to 2 in a scenario with 5 child sessions checking their parent. The temporary test was removed after verification to keep the test suite clean.


PR created automatically by Jules for task 4785286200393040658 started by @charles-forsyth

…uery

Refactors the `list_sessions` method to improve performance.

- Pre-fetches all necessary parent session data in a single query, eliminating the N+1 query problem that occurred when checking the status of running child sessions.
- Batches all status updates for crashed sessions into a single `UPDATE` statement, reducing the number of database write transactions.

This significantly speeds up the `deep-research list` command, especially in environments with many nested or active sessions.
@google-labs-jules
Copy link
Author

👋 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.

0 participants