SQLite WAL checkpoints run on the server event-loop thread; moving them to a Worker removes multi-second fsync stalls
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- bun, sqlite, typescript
- Ambito
- database, performance
Direzione di ricerca
Start with the SQLite configuration and store initialization in packages/core/src/database/database.ts, then trace how the Bun server event loop and workers are started. Implement a worker-owned connection that joins the WAL before disabling writer checkpoints, with the described periodic and size-triggered checkpoint behavior and fallback when the worker exits. Done means main-thread database and WAL fsync activity is moved off the event loop, the store remains readable in the unchanged build, and fault tests cover worker crashes and pinned readers.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
OpenCode 2.4.2 on Linux (the latest release) opens its file-backed SQLite store in WAL mode with synchronous=NORMAL (packages/core/src/database/database.ts:44-45, the same on dev), and the writer keeps SQLite's default automatic checkpoint (1,000 pages). SQLite runs that checkpoint inside the commit that crosses the threshold, so its fsync calls on the WAL and the database file run on the thread that also runs the server event loop. #64532 removed the checkpoint at open and notes that the work moves to these automatic checkpoints. The current dev branch still has no other checkpoint path in packages/core/src/database.
Measurement. A scratch service ran a local build of v2.4.2 with its data directory on Btrfs, an offline stub provider (32 prompts, 512 provider requests per burst), and a separate process doing direct writes and many small-file deletes on another NVMe drive. strace -f -T -y on the main thread recorded 124 fsync calls to the store's database and WAL in a 61-second burst: 7.12 s in total, 1.40 s for the longest call. Without the other process: 124 calls, 0.23 s in total, 49 ms for the longest call. These are syscall wall times. They include scheduling, and they are not a direct measure of event-loop stalls, but every main-thread call of 20 ms or more in the loaded run was one of these fsync calls.
Prototype. In a local build I opened a second connection in a Worker that joins the WAL first. Automatic checkpoints are turned off on the writer only after the Worker reports ready, and the default comes back if the Worker exits. The Worker runs PASSIVE checkpoints every 5 s or when the WAL passes 64 MiB, a bounded FULL attempt at 1 GiB, and a final TRUNCATE after the writer closes. Same load, three matched pairs against the unchanged build (both builds also carry #66543), in both orders and once without the other process:
| Pair | Main-thread DB+WAL fsync time (unchanged → Worker) |
Burst time | Main-thread CPU per request |
|---|---|---|---|
| With load, Worker build first | 188 ms → 9.7 ms | 54.9 s → 80.8 s (did not repeat) | — |
| With load, unchanged build first | 202 ms → 3.3 ms | 63.5 s → 57.9 s | 71.0 → 66.9 ms |
| Without load | 202 ms → 20 ms | 66.5 s → 59.8 s | 72.8 → 69.2 ms |
The checkpoint fsync calls moved to the Worker thread (18–89 calls per burst). The WAL high-water mark grew from about 4 MB to 54–69 MB. A store migrated by the prototype opened and read normally in the unchanged build.
Request. Could the Bun host run WAL checkpoints from a separate connection in a Worker, along these lines? Open questions I could not settle: a long-lived reader can pin WAL frames, so the 1 GiB FULL step cannot give a hard cap; the Worker crash and pinned-reader paths need fault tests; and a different checkpoint cadence changes the power-loss window under synchronous=NORMAL. I can share the prototype diff if it helps.
- Lingua principale
- TypeScript
- Stelle
- 230k
- Fork
- 31.3k
- Merge medio
- 5h 32m
- PR unite (30g)
- 453
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di anomalyco/opencode
-
area/desktop platform/macos status/repro-plausible type/bug version/v2
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
anomalyco/opencode#67064 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 82/100
anomalyco/opencode#67009 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
area/web type/feature version/v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
anomalyco/opencode#67001 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
skills: a Claude-compatible SKILL.md that fails to parse is dropped without any logForse già presa @liwenjie200543 l’ha presa 2 giorni fa. Apertaarea/plugins platform/linux reproduced type/bug version/v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
anomalyco/opencode#66970 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
tui: Mermaid renderer displays <b>/<strong> tags literally and ignores \n line breaksForse già presa @argszero l’ha presa 2 giorni fa. Apertaarea/tui platform/wsl status/repro-simulated type/bug version/v2
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
anomalyco/opencode#66773 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di anomalyco/opencode
Issue simili
-
enhancement feature/signals self-driving team/self-driving
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
PostHog/posthog#144208 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue web
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
triage: not actionable
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
oxc-project/oxc#30518 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug Claude useability
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
wazuh/wazuh-dashboard-plugins#9751 ·
I maintainer di solito rispondono entro 1 giorno