Skip to content

chore(beads): close polylogue-9soj with post-#3460 re-measurement - #3463

Merged
Sinity merged 1 commit into
masterfrom
worktree-agent-a2955c03f32b27b5e
Jul 31, 2026
Merged

Sinity merged 1 commit into
masterfrom
worktree-agent-a2955c03f32b27b5e

Conversation

@Sinity

@Sinity Sinity commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

Re-ran the index-deferral experiment that polylogue-9soj scoped, on top
of #3460 (merged minutes before this session started), and closed the
bead 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_write 47%, full_replace 38%, census 16% — the write
side is 85%). polylogue-9soj recorded that the classic lever — build
secondary B-tree indexes after bulk insert instead of maintaining them
during — had been tried and rejected: dropping all 72 non-unique
CREATE INDEX statements before bulk write and recreating after made
apply_s 187.6s -> 317.7s (+69%), because _clear_session_projection_rows's
point-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 a session_row_existed
boolean into _replace_full_session_messages_and_blocks and skips that
entire 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 a
new terminal rebuild stage).

Solution

No code change. Re-measured using the same two-point regression harness
#3460 itself used to justify its own numbers
(tests/infra/rebuild_cost_model.py:measure_stratum), against the two
largest representative strata (claude-code-session/d9 = 38% of the live
population by raw count, codex-session/d9). The deferred variant
monkeypatches archive_tiers.ARCHIVE_DDL_BY_TIER[ArchiveTier.INDEX] to
strip the 72 non-unique CREATE INDEX statements before the pass, then
recreates them against the built index.db afterward (scratch scripts,
not committed: /realm/tmp/perf-rebuild-index/measure_defer.py,
measure_defer_breakdown.py).

Result: #3460 genuinely 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):

metric eager (median) deferred (median) delta
wall_s @ n=60 6.22s 5.26s -15%
wall_s @ n=15 3.98s 3.06s -23%
cpu_s @ n=60 2.77s 2.75s ~0%
cpu_s @ n=15 1.50s 1.43s -5%
marginal s/raw (wall) 0.0498 0.0489 -2%
marginal s/raw (cpu) 0.0281 0.0293 +4%

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_s intercept (fresh
archive DDL bootstrap: 72 fewer CREATE INDEX at connect time, ~1s), not
a 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_projection baseline attempt (which itself failed
on pytest-timeout's default 120s ceiling — the opt-in full-population
test needs --timeout=0, undocumented in the harness's own docstring
example). 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: #3460 already removed the one place index
absence 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 genuinely
INSERT-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/messages at full-table scale regardless of when secondary
indexes get built, confirmed by instrumenting its bulk_build_substages
timings directly (each sub-stage within noise of the other, eager vs
deferred).

polylogue-9soj is 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 in
    close_reason.
  • Measurement scripts run via
    /realm/project/polylogue/.claude/worktrees/agent-a2955c03f32b27b5e/.venv/bin/python
    (own venv, resolution-verified against
    polylogue.storage.sqlite.archive_tiers.write.__file__ before every
    run — guards the shared-venv .pth hazard that pointed the main
    checkout's venv at /realm/project/polylogue and invalidated other
    lanes' numbers tonight).
  • devtools verify --quick not applicable — no polylogue/ source
    changed, only .beads/issues.jsonl. Pre-push hook's beads-only-diff
    check ran automatically on push: "backlog hygiene: zero unhandled
    findings across 1434 issues scanned."
  • Not run: the full test_full_population_projection --run-cost-model-full
    harness end to end (needs --timeout=0; the per-stratum quick
    methodology above is the same one #3460 itself used for its landed
    claims, and is sufficient evidence for a negative/neutral result on a
    ~2-4% effect size).

Ref polylogue-9soj, polylogue-623q, polylogue-cs86

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
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • .beads/issues.jsonl
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 40432f45-7eff-453d-97f9-71c71a9afae9

📥 Commits

Reviewing files that changed from the base of the PR and between 5798b3d and ab5301b.

📒 Files selected for processing (1)
  • .beads/issues.jsonl

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Sinity
Sinity merged commit 7a0d381 into master Jul 31, 2026
3 checks passed
@Sinity
Sinity deleted the worktree-agent-a2955c03f32b27b5e branch July 31, 2026 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant