perf: cut the 15.8s cold-start stall (exploration 0233, Wave 1)#290
Merged
crs48 merged 5 commits intoJun 26, 2026
Merged
Conversation
…B bloat) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…33 B1) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Also logs DB size before/after, which captures the db-stats measurement 0233 asked for. Mirrors the 0229 presence-blob cleanup: one-shot, localStorage-gated, idle-scheduled, never on the boot critical path, never throws. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ry goes first (0233 C2) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
🖼️ UI changes in this PRNo visual differences detected in the changed UI. |
Contributor
|
Preview removed for PR #290. |
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.
Implements Wave 1 of exploration 0233 — the cheap, safe cold-read mitigations. The boot-debug trace (enabled by #288) finally named the culprit in one line:
One landing query, 15.8 s of real execution,
queueMs:0— and every op after itexecMs:0. That's a cold OPFS page-in of the first query's working set on the single SQLite worker; the 256 MB page cache only helps re-reads, so it never touched the first read. The file is large/fragmented (a 424k-row append-only change log + 1.3M-row scalar index grown interleaved), so the cold read faults pages scattered across it.What's in this PR
PRAGMA mmap_size(web.ts): memory-map reads so the first cold query faults via the OS instead of thousands of synchronous 8 KiB reads. Guarded — a no-op whereopfs-sahpooldoesn't support it. This is the lever for the first read.VACUUM(db-vacuum.ts): defragments the OPFS file so subsequent cold boots fault a smaller, denser working set. Mirrors the 0229 presence cleanup (one-shot, localStorage-gated, idle-scheduled, off the critical path, never throws). Logs file size before/after — which also captures thedb statsmeasurement the doc asked for.Deliberately deferred (separate, focused PRs)
The doc is a multi-wave plan that gates later waves on measurement and touches the protocol kernel — implementing them blind here would be reckless:
db stats/ instrument the ~4.4 s secondary gap — runtime observations; A3 now logs the file size, and the rest needs a live capture against the user's OPFS data.changesDB —changesis the signed, hash-chained protocol kernel (0200, golden vectors). Pruning it needs a spec + cross-impl test updates.INVALID_HASH).The 0233 doc stays
[_](3/10 implementation items done) — Wave 1 lands here; the architectural waves follow with measurements in hand.Test plan
db-vacuum.test.ts(3 cases: opfs vacuum+latch, memory-skip-no-latch, flag no-op).@xnetjs/sqlite+apps/web: typecheck clean, full suites green (677 tests in touched areas).core.bareflip from the hook's ownpnpm installbreaking devkit git tests — all pass with healthy git; none are in touched code.🤖 Generated with Claude Code