⚡ Bolt: optimize SessionManager database operations#59
⚡ Bolt: optimize SessionManager database operations#59charles-forsyth wants to merge 1 commit intomainfrom
Conversation
- Use LEFT JOIN in list_sessions to avoid N+1 queries for parent status. - Batch UPDATE statements for crashed sessions. - Add indexes for interaction_id, parent_id, and updated_at. - Refactor append_to_result to use a single UPDATE query. - Add thread-safe initialization cache to skip redundant _init_db calls. Co-authored-by: charles-forsyth <54458298+charles-forsyth@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. |
💡 What:
SessionManager.list_sessionsby using aLEFT JOINto fetch parent session status and PID in a single query, eliminating the N+1 query problem.UPDATEstatements for 'crashed' sessions into a single query usingWHERE id IN (...).interaction_id,parent_id, andupdated_atto improve lookup and sorting performance.append_to_resultto use a single SQLUPDATEwith concatenation, eliminating a redundantSELECT._init_db(schema check and migration) calls within the same process.🎯 Why:
list_sessionsmethod was performing an additionalSELECTquery for every running child session to check its parent's status, leading toSessionManagerinstantiation were adding unnecessary overhead, especially in recursive research mode where many agents are spawned.📊 Impact:
list_sessionsfromlist_sessionsfor 100 sessions (from 0.086s to 0.010s).listcommand and overall system efficiency.🔬 Measurement:
sqlite3.Connection.executecalls.uv run pytest).PR created automatically by Jules for task 5037856749770711362 started by @charles-forsyth