⚡ [performance improvement description] Unroll delete queries to avoid Array allocations#45
⚡ [performance improvement description] Unroll delete queries to avoid Array allocations#45Gunnarguy wants to merge 1 commit into
Conversation
Co-authored-by: Gunnarguy <110250624+Gunnarguy@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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Sorry @Gunnarguy, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
There was a problem hiding this comment.
Pull request overview
This PR optimizes the SQLite deletion path in SQLiteFullTextService by replacing an array-driven loop in deleteStructuredMetadata with explicitly unrolled sqlite3_prepare_v2 / bind / step / finalize calls, aiming to avoid small heap allocations in a hot DB-layer path.
Changes:
- Removed the temporary
[String]array of DELETE statements used for structured-metadata cleanup. - Expanded the deletion logic into two explicit DELETE statement executions for both document-id and container-id variants.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
💡 What: Replaced the array-based loop in
deleteStructuredMetadatamethods with unrolled explicit SQLite statement prepares and executes.🎯 Why: To eliminate the heap allocations and overhead of Swift Arrays and iterators during document and chunk deletion processes.
📊 Measured Improvement: As documented during the process, it was not possible to gather precise benchmark measurements due to the lack of the Swift toolchain,
xcodebuild, andfastlanein this development environment (Linux based). However, this optimization is a universally accepted Swift best-practice for small static query sets in performance-sensitive DB layer paths, saving multiple heap allocations per call and matching other similar code paths in the file.PR created automatically by Jules for task 8004551170782227939 started by @Gunnarguy