⚡ Bolt: optimize SessionManager database efficiency#61
⚡ Bolt: optimize SessionManager database efficiency#61charles-forsyth wants to merge 1 commit intomainfrom
Conversation
This PR optimizes the `SessionManager` class to improve database efficiency, especially during recursive research tasks. 💡 What: - Optimized `list_sessions` to use a `LEFT JOIN` for fetching parent data, solving the N+1 query problem. - Batched `UPDATE` statements in `list_sessions` for crashed sessions. - Optimized `append_to_result` to use a single SQL `UPDATE` with concatenation (||). - Implemented a thread-safe initialization cache to avoid redundant migrations and pragmas. - Added database indexes for `interaction_id`, `parent_id`, and `updated_at`. 🎯 Why: Database round-trips were identified as a potential bottleneck during session management, particularly when many child sessions are created. 📊 Impact: - Listing N sessions now uses 1 SELECT query instead of N+1. - Appending to results now uses 1 query instead of 2. - Redundant initializations now use 0 queries. 🔬 Measurement: Verified with a custom query counting script and confirmed that all existing tests pass. 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. |
Optimized SessionManager for database efficiency. Reduced query counts for session listing and updates. Added indexes and initialization caching.
PR created automatically by Jules for task 8524224429222575141 started by @charles-forsyth