From d416d672dba9a5aceeff5bb5c3f8a02cae15232c Mon Sep 17 00:00:00 2001 From: beads/crew/wolf Date: Fri, 2 Jan 2026 17:30:58 -0800 Subject: [PATCH] bench(sqlite): add isolated cache rebuild benchmarks (bd-zw72) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add BenchmarkRebuildBlockedCache_Large and _XLarge to measure cache rebuild performance in isolation. Results show cache rebuild takes ~773ms at 10K issues and ~1.3s at 20K, significantly slower than the ~50ms originally estimated in the issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- internal/storage/sqlite/sqlite_bench_test.go | 33 ++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/internal/storage/sqlite/sqlite_bench_test.go b/internal/storage/sqlite/sqlite_bench_test.go index b1f1fc57..752330e0 100644 --- a/internal/storage/sqlite/sqlite_bench_test.go +++ b/internal/storage/sqlite/sqlite_bench_test.go @@ -236,6 +236,39 @@ func BenchmarkSyncMerge(b *testing.B) { } } +// BenchmarkRebuildBlockedCache_Large benchmarks cache rebuild in isolation on 10K database +// This measures the core operation that bd-zw72 is investigating for incremental optimization +func BenchmarkRebuildBlockedCache_Large(b *testing.B) { + store, cleanup := setupLargeBenchDB(b) + defer cleanup() + ctx := context.Background() + + b.ResetTimer() + b.ReportAllocs() + + for i := 0; i < b.N; i++ { + if err := store.rebuildBlockedCache(ctx, nil); err != nil { + b.Fatalf("rebuildBlockedCache failed: %v", err) + } + } +} + +// BenchmarkRebuildBlockedCache_XLarge benchmarks cache rebuild in isolation on 20K database +func BenchmarkRebuildBlockedCache_XLarge(b *testing.B) { + store, cleanup := setupXLargeBenchDB(b) + defer cleanup() + ctx := context.Background() + + b.ResetTimer() + b.ReportAllocs() + + for i := 0; i < b.N; i++ { + if err := store.rebuildBlockedCache(ctx, nil); err != nil { + b.Fatalf("rebuildBlockedCache failed: %v", err) + } + } +} + // Helper function func intPtr(i int) *int { return &i