Repository navigation
chore(beads): close polylogue-9soj with post-#3460 re-measurement - #3463
Conversation
Problem: polylogue-9soj scoped a selective index-deferral follow-up on the premise that #3460 (skip the no-op full-replace delete cascade for new sessions) would need auditing before any deferral could be safe. What changed: re-measured the bead's original SIMPLE variant (defer all 72 non-unique CREATE INDEX statements, recreate after) on top of #3460 using the same two-point regression harness #3460 itself used (tests/infra/rebuild_cost_model.py). #3460 did eliminate the catastrophic +69% regression the bead originally found, but blanket deferral still does not meaningfully help post-#3460: marginal per-raw cost is within ~2-4% either direction (noise) on the dominant claude-code-session/d9 stratum (38% of the population), both by wall clock and by CPU time (immune to this session's host contention). Projected against the operator's 4h20m calibration rebuild, the best case reads as low tens-of-seconds, not an order-of-magnitude lever. Closing rather than scoping the narrower selective variant: a subset of an already-neutral blanket change would move the needle even less. Full numbers and methodology are in the bead's close_reason. polylogue-fpid (unwired prepare_session_rows off the writer thread) remains the tracked, unexplored lever. Ref polylogue-9soj, polylogue-623q, polylogue-cs86
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. 💤 Files selected but had no reviewable changes (1)
⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Re-ran the index-deferral experiment that
polylogue-9sojscoped, on topof
#3460(merged minutes before this session started), and closed thebead with a well-evidenced negative/neutral finding: index deferral is
not the rebuild-speedup lever it looked like, even in its simplest
blanket form. No production code changes in this PR — pure bead
bookkeeping (
.beads/issues.jsonl).Problem
The operator's last full index rebuild took 4h20m (measured stage split:
index_parsed_write47%,full_replace38%,census16% — the writeside is 85%).
polylogue-9sojrecorded that the classic lever — buildsecondary B-tree indexes after bulk insert instead of maintaining them
during — had been tried and rejected: dropping all 72 non-unique
CREATE INDEXstatements before bulk write and recreating after madeapply_s187.6s -> 317.7s (+69%), because_clear_session_projection_rows'spoint-DELETEs against ~14 tables became full table scans without
indexes, even though every DELETE matched zero rows on a from-empty
rebuild.
#3460(merged 2026-07-31,2bbe7574d) threads asession_row_existedboolean into
_replace_full_session_messages_and_blocksand skips thatentire delete cascade when a session provably has no prior rows — exactly
true for every session in a full rebuild-from-empty. That looked like it
might have retired the root cause the original index-deferral experiment
tripped over, so the operator asked to re-measure before investing in the
bead's scoped selective-audit alternative (~50-60 of 72 indexes kept,
requiring a new defer-flag threaded through
IndexGenerationStore.create()/initialize_archive_database()plus anew terminal rebuild stage).
Solution
No code change. Re-measured using the same two-point regression harness
#3460itself used to justify its own numbers(
tests/infra/rebuild_cost_model.py:measure_stratum), against the twolargest representative strata (
claude-code-session/d9= 38% of the livepopulation by raw count,
codex-session/d9). The deferred variantmonkeypatches
archive_tiers.ARCHIVE_DDL_BY_TIER[ArchiveTier.INDEX]tostrip the 72 non-unique
CREATE INDEXstatements before the pass, thenrecreates them against the built
index.dbafterward (scratch scripts,not committed:
/realm/tmp/perf-rebuild-index/measure_defer.py,measure_defer_breakdown.py).Result:
#3460genuinely fixed the pathology — the catastrophic+69% regression is gone. But blanket deferral doesn't meaningfully help
either. Repeated single-pass measurements (3x each, n=15 and n=60,
claude-code-session/d9, taken clean of host contention):CPU time (immune to other processes stealing cycles on this session's
~10-concurrent-agent-worktree host) is the trustworthy signal here: it's
within noise either direction. Wall-clock shows a consistent small
edge to deferred, but it's driven by the
fixed_sintercept (fresharchive DDL bootstrap: 72 fewer
CREATE INDEXat connect time, ~1s), nota per-raw saving — and a real rebuild pays that fixed cost once for the
whole run, not once per stratum sample. Projected against 4h20m, the
realistic win is low tens-of-seconds, not an order of magnitude.
First-pass numbers were a red herring. An initial single-sample
2-point run showed deferred 2.4x worse (marginal 0.1246 vs 0.0481
s/raw) — but that run overlapped an unrelated background
test_full_population_projectionbaseline attempt (which itself failedon
pytest-timeout's default 120s ceiling — the opt-in full-populationtest needs
--timeout=0, undocumented in the harness's own docstringexample). Repeating cleanly after that process exited reproduced neither
the win nor the loss — flat, near-zero difference. This is recorded in
the close reason as a methodology note: single-sample 2-point regressions
on a shared, noisy host are not trustworthy without repetition.
Root cause of the wash:
#3460already removed the one place indexabsence helped (zero-match point-DELETEs going O(n) without an index).
Every other per-session write during bulk-build (messages/blocks/
action_pairs inserts,
field_path_union,graph_resolve) is genuinelyINSERT-bound — B-tree maintenance during insert was never the dominant
cost.
_repopulate_bulk_build_derived_state's post-pass FTS/trigram/action_pairs/delegation_facts bulk repopulation reads back through
blocks/messagesat full-table scale regardless of when secondaryindexes get built, confirmed by instrumenting its
bulk_build_substagestimings directly (each sub-stage within noise of the other, eager vs
deferred).
polylogue-9sojis closed rather than narrowed to its selective variant:since blanket deferral (all 72) is already a wash, a subset (50-60) would
move the needle even less — the selective audit isn't worth building.
Verification
bd show polylogue-9soj --json->status: closed, full numbers inclose_reason./realm/project/polylogue/.claude/worktrees/agent-a2955c03f32b27b5e/.venv/bin/python(own venv, resolution-verified against
polylogue.storage.sqlite.archive_tiers.write.__file__before everyrun — guards the shared-venv
.pthhazard that pointed the maincheckout's venv at
/realm/project/polylogueand invalidated otherlanes' numbers tonight).
devtools verify --quicknot applicable — nopolylogue/sourcechanged, only
.beads/issues.jsonl. Pre-push hook's beads-only-diffcheck ran automatically on push: "backlog hygiene: zero unhandled
findings across 1434 issues scanned."
test_full_population_projection --run-cost-model-fullharness end to end (needs
--timeout=0; the per-stratum quickmethodology above is the same one
#3460itself used for its landedclaims, and is sufficient evidence for a negative/neutral result on a
~2-4% effect size).
Ref polylogue-9soj, polylogue-623q, polylogue-cs86