Repository navigation
perf(persistence): delete replaced coverage and dead-code rows in one statement - #4359
Merged
Merged
Conversation
… statement save_coverage_files and save_dead_code_findings loaded every row they replaced and deleted it one object at a time. Both issue one DELETE now. replace_dead_code_findings reads only the acted-on rows' keys and deletes the open rows in scope through the shared chunked delete, so dismissals and rows outside the scope are untouched as before.
swati510
approved these changes
Oct 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The coverage and dead-code writers loaded every row they were about to replace and deleted it one ORM object at a time. They issue a single
DELETEinstead, the same shape the health findings and metrics writers use.How
save_coverage_files: oneDELETEon the repo'scoverage_filesrows, still before the inserts, souq_coverage_filessees the same order.save_dead_code_findings: oneDELETEon the repo's open rows.replace_dead_code_findings: reads only the (file, kind, symbol) keys of acted-on rows, then deletes the open rows. With a scope, the delete goes through the existing chunked_batch_delete_in, so a scope wider than SQLite's variable limit still works. Rows outside the scope and dismissed rows are left exactly as before.coverage_map.save_test_coveragealready used a singleDELETE; nothing to change there.Neither table has a foreign key, relationship cascade or ORM hook that the per-row delete was triggering, and no caller reads the loaded rows. The read-snapshot staleness hook fires for the bulk statement as it did for the flushed deletes.
Verification
Each copy re-saved its own stored rows with the old code and with this branch: coverage save, dead-code save, repo-wide replace, then a replace scoped to every other file with 10% of findings dismissed first. Row counts and a SHA-256 over every column except the id and the save-time stamp match between old and new on all three. Medians of 3 alternating runs:
save_coverage_filessave_dead_code_findingsreplace_dead_code_findingssave_dead_code_findingsreplace_dead_code_findingsRepo-wide
replace_dead_code_findingsis within noise (Superset 326 vs 339 ms, MLflow 353 vs 283 ms); its time goes to the inserts.New test
test_scoped_replace_past_one_delete_chunk_keeps_exactly_the_right_rowslocks the rows left after a scoped replace that spans more than one delete chunk. It passes on main and on this branch. Coverage, dead-code and persist-order suites: 128 passed.