perf: use single transaction for AST node insertion (3.6s → 350ms)#333
perf: use single transaction for AST node insertion (3.6s → 350ms)#333carlos-alm merged 2 commits intomainfrom
Conversation
|
Claude finished @carlos-alm's task —— View job PR Review: AST Transaction Optimization ⭐⭐⭐⭐Todo List:
Root Cause AnalysisProblem Being Solved: The Why This Approach: The fix correctly addresses the root cause by collecting all AST node rows across all files first, then inserting them in a single transaction call. This matches the pattern used by other build phases (CFG, dataflow, complexity) which already correctly used single transactions. Risk Assessment: LOW - This is a genuine performance optimization addressing a clear inefficiency without changing the semantic behavior. Configuration Changes & Test Integrity ✅Configuration Analysis: No high-risk configuration changes detected:
Test Changes Review:
Code Quality ReviewImplementation Quality (
Performance Impact:
Dependencies & Changes:
Final AssessmentApproval Justification: This PR demonstrates textbook performance optimization - identifies bottleneck, applies correct solution (transaction batching), maintains semantic correctness, and delivers measurable results. Code quality is high and follows project patterns. |
Greptile SummaryExcellent performance optimization that fixes the per-file transaction antipattern in
All changes follow established patterns in the codebase and maintain test coverage (1431 tests passing). Confidence Score: 5/5
Important Files Changed
Last reviewed commit: 95e9aef |
buildAstNodes was calling tx(rows) per-file inside the loop, creating 172 separate SQLite transactions each with a BEGIN/COMMIT/fsync cycle. All other phases (CFG, dataflow, complexity) correctly used a single wrapping transaction. Collect all rows across files first, then insert in one tx(allRows) call. Benchmarked: astMs drops from ~3600ms to ~350ms (native) and ~547ms (WASM). Native per-file build time: 24.9 → 8.5 ms/file. Impact: 1 functions changed, 12 affected
ef76756 to
ef23a81
Compare
|
Claude finished @carlos-alm's task —— View job PR Review: AST Transaction Optimization ⭐⭐⭐⭐Todo List:
Root Cause AnalysisProblem Being Solved: The Why This Approach: The fix correctly addresses the root cause by collecting all AST node rows across all files first, then inserting them in a single transaction call. This matches the pattern used by other build phases (CFG, dataflow, complexity) which already correctly used single transactions. Risk Assessment: LOW - This is a genuine performance optimization addressing a clear inefficiency without changing the semantic behavior. Configuration Changes & Test Integrity ✅Configuration Analysis: No high-risk configuration changes detected:
Test Changes Review: No test files were modified in this PR. The commit only touches:
✅ No test expectations lowered or assertions weakened Code Quality ReviewImplementation Quality (
Performance Impact:
Dependencies & Changes:
Final AssessmentApproval Justification: This PR demonstrates textbook performance optimization - identifies bottleneck, applies correct solution (transaction batching), maintains semantic correctness, and delivers measurable results. Code quality is high and follows project patterns. |
Summary
buildAstNodeswas callingtx(rows)per-file inside the loop, creating 172 separate SQLite transactions each with aBEGIN/COMMIT/fsynccycletx(allRows)callBenchmark results
astMsastMsTest plan
node scripts/benchmark.jsconfirms astMs drop