WIP: storage: checkpoint index.db during quiet writer intervals (#1051) #1080

Draft
kayg wants to merge 1 commit from fix/1051-index-idle-checkpoint into dev
Owner

Occasional index.db checkpoints delay saves. This change runs proactive PASSIVE checkpoints on the existing index writer after at least 100 commands and 100 ms of quiet, while retaining SQLite’s native 1000-page backstop. meta.db and history.db production code is unchanged. References #1051.

The idle budget admits at most 1000 allocated WAL pages, derived from the database’s actual page size. SQLite cannot partially limit a PASSIVE call. Retained allocation shrinks to that budget on WAL reuse. Above 16 MiB, the next writer command attempts TRUNCATE with a zero busy timeout, restores the prior timeout, and returns retryable NotSavedYet if a reader still prevents reuse. One transaction can overshoot the cap. Publication NORMAL/FULL durability is unchanged.

Cost is O(1) file metadata per writer command, one weak timer per dirty Home, the existing bounded writer queue, and O(WAL pages) admitted maintenance. The failure/size/crash table is in #1051 (comment).

Validation: store unit/crash tests pass on x86 and aarch64 (83 tests each). Fresh x86 workspace tests pass (1,741 passed, zero failed, 22 ignored), workspace clippy with -D warnings passes, and the production release build passes. Formatting, file-docs and layer checks pass. Baseline file-size lint fails identically on dev and this branch; no ceiling was raised. Final functional evidence and cleanup proof: #1051 (comment). aarch64 evidence: #1051 (comment).

Performance qualification failed. The controlled 5400-save soak’s MAX checks qualify, but continuous journal commits, cold first-page tails, and history checkpoint-sync overlaps exceed the predeclared dev/dev bounds. This remains a draft; no production policy was patched after those misses. The cold first-page cause remains unresolved, and per-command size admission is an unisolated candidate cost for journal writes. #1064 remains unchanged. Full per-arm gate table, raw evidence and slowest-20 attribution: #1051 (comment).

Agents never merge.

Round 2 tested the proposed concurrent background-checkpoint cause before patching. Timestamp joins show no overlap with cold requests or measured journal/history commits; the six history sync overlaps are separate from index checkpoints. The hypothesis is disproved for the traced workload, so no warmup/shared disk-busy scheduling patch was made and qualification was not rerun. The five performance blockers remain unresolved. Full traces, slowest-20 joins, limitations and cleanup proof: #1051 (comment).

Occasional index.db checkpoints delay saves. This change runs proactive PASSIVE checkpoints on the existing index writer after at least 100 commands and 100 ms of quiet, while retaining SQLite’s native 1000-page backstop. meta.db and history.db production code is unchanged. References #1051. The idle budget admits at most 1000 allocated WAL pages, derived from the database’s actual page size. SQLite cannot partially limit a PASSIVE call. Retained allocation shrinks to that budget on WAL reuse. Above 16 MiB, the next writer command attempts TRUNCATE with a zero busy timeout, restores the prior timeout, and returns retryable NotSavedYet if a reader still prevents reuse. One transaction can overshoot the cap. Publication NORMAL/FULL durability is unchanged. Cost is O(1) file metadata per writer command, one weak timer per dirty Home, the existing bounded writer queue, and O(WAL pages) admitted maintenance. The failure/size/crash table is in https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-91527. Validation: store unit/crash tests pass on x86 and aarch64 (83 tests each). Fresh x86 workspace tests pass (1,741 passed, zero failed, 22 ignored), workspace clippy with -D warnings passes, and the production release build passes. Formatting, file-docs and layer checks pass. Baseline file-size lint fails identically on dev and this branch; no ceiling was raised. Final functional evidence and cleanup proof: https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-91963. aarch64 evidence: https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-91747. Performance qualification failed. The controlled 5400-save soak’s MAX checks qualify, but continuous journal commits, cold first-page tails, and history checkpoint-sync overlaps exceed the predeclared dev/dev bounds. This remains a draft; no production policy was patched after those misses. The cold first-page cause remains unresolved, and per-command size admission is an unisolated candidate cost for journal writes. #1064 remains unchanged. Full per-arm gate table, raw evidence and slowest-20 attribution: https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-91879. Agents never merge. Round 2 tested the proposed concurrent background-checkpoint cause before patching. Timestamp joins show no overlap with cold requests or measured journal/history commits; the six history sync overlaps are separate from index checkpoints. The hypothesis is disproved for the traced workload, so no warmup/shared disk-busy scheduling patch was made and qualification was not rerun. The five performance blockers remain unresolved. Full traces, slowest-20 joins, limitations and cleanup proof: https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-92107.
storage: checkpoint only the journal during quiet intervals
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
f2a1ccef3b
kayg changed title from WIP: storage: checkpoint only index.db between saves (#1051) to WIP: storage: checkpoint index.db during quiet writer intervals (#1051) 2026-11-11 18:08:03 +00:00
Author
Owner

Performance qualification failed on head 82ecc5a1e95c6febe2eb8241c69db800ac791a00. The full gate table and raw evidence include all six soak arms, identical-dev controls, list quantiles, WAL timeline and slowest-20 timings. This stays draft; #1064 is not superseded. Store unit/crash tests pass on both build architectures. Fresh x86 workspace tests (1,741 passed, 22 ignored), workspace clippy and production release build pass. Final functional logs and cleanup proof also record the unchanged baseline size-lint failures. All own jobs and perf holds are finished.

Performance qualification failed on head `82ecc5a1e95c6febe2eb8241c69db800ac791a00`. The [full gate table and raw evidence](https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-91879) include all six soak arms, identical-dev controls, list quantiles, WAL timeline and slowest-20 timings. This stays draft; #1064 is not superseded. Store unit/crash tests pass on both build architectures. Fresh x86 workspace tests (1,741 passed, 22 ignored), workspace clippy and production release build pass. [Final functional logs and cleanup proof](https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-91963) also record the unchanged baseline size-lint failures. All own jobs and perf holds are finished.
Author
Owner

round 2: tested the orchestrator’s contention hypothesis first and stopped without a production patch after disproval for the traced workload. timestamp report, raw traces and all slowest-20 correlations. No background checkpoint ran in the candidate cold invocations; the only fresh journal checkpoint began after all measured commits. The retained soak’s 27 background checkpoints overlap no journal/history commit or save request, and the six history sync overlaps are separate. Original five performance failures still block qualification; this remains draft at 82ecc5a1e95c6febe2eb8241c69db800ac791a00. All own jobs and holds are finished. #1064 unchanged.

round 2: tested the orchestrator’s contention hypothesis first and stopped without a production patch after disproval for the traced workload. [timestamp report, raw traces and all slowest-20 correlations](https://git.kayg.org/kayg/calternal/issues/1051#issuecomment-92107). No background checkpoint ran in the candidate cold invocations; the only fresh journal checkpoint began after all measured commits. The retained soak’s 27 background checkpoints overlap no journal/history commit or save request, and the six history sync overlaps are separate. Original five performance failures still block qualification; this remains draft at `82ecc5a1e95c6febe2eb8241c69db800ac791a00`. All own jobs and holds are finished. #1064 unchanged.
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
Markdown extraction contract / markdown-native-contract (pull_request) Has been cancelled
Markdown extraction contract / markdown-editor-contract (pull_request) Has been cancelled
This pull request is broken due to missing fork information.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'fix/1051-index-idle-checkpoint:fix/1051-index-idle-checkpoint'
git switch 'fix/1051-index-idle-checkpoint'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'dev'
git merge --no-ff 'fix/1051-index-idle-checkpoint'
git switch 'fix/1051-index-idle-checkpoint'
git rebase 'dev'
git switch 'dev'
git merge --ff-only 'fix/1051-index-idle-checkpoint'
git switch 'fix/1051-index-idle-checkpoint'
git rebase 'dev'
git switch 'dev'
git merge --no-ff 'fix/1051-index-idle-checkpoint'
git switch 'dev'
git merge --squash 'fix/1051-index-idle-checkpoint'
git switch 'dev'
git merge --ff-only 'fix/1051-index-idle-checkpoint'
git switch 'dev'
git merge 'fix/1051-index-idle-checkpoint'
git push origin 'dev'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!1080
No description provided.