Delete and restore: p95 under 50 ms on the perf VM #125
Closed
opened 2026-10-14 04:31:33 +00:00 by kayg
·
30 comments
No Branch/Tag specified
main
port/tasks-float-2
fix/train-1116-2
fix/train-1116-3
fix/train-1116-1
fix/flake-1134
fix/server-1182
dev
port/notes-float-3c
docs/auto-update-ig
feat/dav-transport
port/tasks-float-1
wip/mail1011-sv-order-1116
fix/flake-1179
fix/flake-1178
fix/guards-1153-fsio-split
fix/guards-1153-notes-split-we
fix/guards-1153-notes-lib
fix/guards-1153-notes-home
fix/guards-1153-ui-primitives
fix/guards-1153-primitives-e2e
fix/guards-1153-visibility-doc
feat/paper-grey-1116
fix/flake-1165
fix/flake-1119
docs/imap-766-plan-v2
fix/e2e-unique-ports
t3/paged-search-reconcile-final
wip/mail1011-final-1115
docs/tasks-float-port
perf/editor-first-paint-1c
feat/imap-notes-fetch
feat/imap-notes-projection
feat/imap-notes-readonly
feat/imap-notes-auth
feat/imap-notes-server-foundation
wip/mail1011-txn-ownvocab-1115
wip/mail1011-txn-novocab-1115
perf/p1117-final-harness
perf/single-shot-repeats
port/tasks-matrix
wip/mail1011-txn-1115
fix/static-gates-1155
feat/files-s1-identity-r7
fix/files-r7-idle-loop
fix/daily-train-1152
port/notes-float
fix/editor-tables-test-types
port/notes-float-listscript
feat/tasks-actions
port/notes-float-phone-preload
perf/sound-comparator
port/notes-float-listscroll
port/notes-float-budgets
port/notes-float-suite-fix-b
port/notes-float-sidebar-fix
port/notes-float-trim
port/notes-float-3-lists
fix/attachments-meta-capability
docs/carddav-writes-v2-plan
feat/contacts-companion-pure
issue/carddav-read-perf-fix-r2
issue/carddav-read-r2
port/notes-float-devsync2
review/calendar-2
review/switcher-a-pills
port/notes-float-switcher-a
port/port-tables-2
review/switcher-ends
wip/whiteboard-s1-1114
port/port-tables
wip/mail1011-perfneutral
review/photo-tint
port/notes-float-shell
wip/local/collections-db
wip/local/mail-p1
wip/local/cold-growth-on-tiering
wip/local/tiering-v3-s1
wip/local/wal1051-cap
wip/local/tiering-v3-s1-resume
wip/local/index-position-startup-scan
port/notes-float-flat
port/notes-float-promote
wip/handover/mail1011-candidate
wip/handover/files-s1-candidate
port/notes-float-shell-only
port/notes-float-perf
feat/whiteboard-s1
feat/tiering-v5
fix/app-switch-hitch
wip/local/files-s1-dev-v4-final
feat/files-s1-dev-v4
fix/c2-glass-shared
feat/flat-lists
wip/handover/whiteboard-s1-resume
wip/att-lazy-861
feat/switcher-browse
wip/att-lazy-860
feat/tasks-float
recovered/flat-backup-candidate
perf/stalls-1054-kc
land/ai-toolbar
feat/collections-db
feat/collections-db-fixes
codex/mail-1011-redesign-20261111
fix/ai-toolbar
backup/macos-vm/st3-head
perf/trim-candidate-phonestack
feat/switcher-three
fix/1051-index-idle-checkpoint
perf/stalls-1054-kb
perf/stalls-1054-k
perf/stalls-1054-r3
fix/c2-contrast-tail
perf/stalls-1054-r3-preview
feat/collections-before
feat/tiering-v4
fix/timelog-caret
wip/local/tasks-actions
docs/tasks-writes-v2-plan
st3-r3
feat/pass8
review/calendar-2-before-1111
wip/tiering-v3-cold4
perf/stalls-1054-r2
fix/suite-A4
fix/suite-A5-probe
fix/suite-A6
fix/suite-A3
fix/suite-A2
fix/suite-A5
fix/suite-A1
wip/local/attachments-861-fix
feat/contrast
wip/local/ports-861
storage/wal-checkpoint-off-save-1051
wip/local/mail-1011-reconcile-20261110
feat/style-sheet-fixes
feat/money-round
perf/stalls-1054
wip/tiering-v3-cold5
t3/mail-1011-liveness
feat/iphone-fixes
feat/notes-approve
wip/local/shrow-work
feat/files-s1-identity
feat/quickfix
wip/tiering-v3-cold
wip/local/shared-row-swipes
backup/macos-vm/pfx-B
backup/macos-vm/pfx-C
backup/macos-vm/pfx-D
feat/contrast-r1
feat/tiering-v3-s2-tags
feat/folder-drop
t3/photos-s1
feat/tiering-v3-s1-namespace
wip/local/photos-s1
t3/photos-plan-slice-one
recovered/backup/p1b-61505
t3/paged-search-reconcile
t3/smooth-pane-transitions
t3/index-position-startup-scan
fix/private-staging-759b-r2
backup/macos-vm/hk/hk1009/pr877
backup/macos-vm/hk/hk1009/pr878
docs/undo-block-ids-plan
fix/undo-768
backup/macos-vm/hk/hk1009/pr875
backup/macos-vm/hk/hk1009/pr904
proto/block-identity-v7d
backup/macos-vm/hk/hk1009/pr846
backup/macos-vm/hk/hk1009/pr860
backup/macos-vm/hk/hk1009/pr861
backup/macos-vm/hk/hk1009/pr849
backup/macos-vm/hk/hk1009/pr848
backup/macos-vm/hk/hk1009/pr853
backup/macos-vm/hk/hk1009/pr957
backup/macos-vm/hk/hk1009/pr893
backup/macos-vm/hk/hk1009/pr889
backup/macos-vm/hk/hk1009/pr902
docs/imap-notes-plan
docs/quota-plan-2
fix/parallel-test-flakes
docs/calendar-backend-v2-plan
feat/calendar-ical-converter
backup/macos-vm/hk/hk1009/pr808
docs/contacts-import-v2-plan
issue/610-pm-midnight
feat/calendar-v2-s1-containment
backup/macos-vm/hk/hk1009/pr854
backup/macos-vm/hk/hk1009/pr845
backup/macos-vm/hk/hk1009/pr917
docs/dav-recorder-v2-plan
plan/previews-865
plan/save-log-durable-entry
backup/macos-vm/hk/hk1009/pr934
fix/e2e-data-on-ram
backup/macos-vm/hk/hk1009/pr888
feat/appwindow3
feat/appwindow2
feat/appwindow
feat/money-p1
feat/keys-sheet
review/calendar-2-themes
feat/smooth-cursor
fix/float-style
review/calendar-2-float
release/2026-11-06-hotfix
archive/port/rows-drop-code
archive/port/rows-actions
archive/port/rows
scratch/tasks-894-ui-gates
review/calendar-2-night-wip
recovered/flaky/toast-reduced
release/2026-11-05
archive/flaky/rows-drop-fixed
archive/flaky/rows-actions
archive/flaky/rows
sim/bm15-final
sim/bm15-bis-932
sim/bm15-bis-909
sim/bm15
sim/bm15-bis-887
perf/tiering-option-b
fix/sw-lazy-precache
archive/plan/save-log-durable-entry
mock/money-fix2
archive/fix/e2e-data-on-ram
mock/appearance-all
mock/pill-press
mock/pill-press-mac
backup/macos-vm/appearance-after
mock/auto-swipes
mock/mail-actions
backup/macos-vm/mock/mail-actions
mock/money-static
archive/review/standards-917
perf/tiering-761-fix
mock/type-audit
mock/third-pane
feat/contacts-import-v2-s1
perf/executor-hot-path
archive/port/hidden-blocks
archive/port/devices
scratch/executor-on-894
scratch/executor-spans2
scratch/executor-spans
archive/port/rows-drop
feat/tiering-761-d-scale
feat/tiering-761-c-index
feat/tiering-761-b-reader
archive/review/sharing-pr3-review-9fec3d1f
perf/ports-lazy-budgets
feat/tiering-761-a-migration
archive/review/sharing-pr3-review
archive/review/sharing-pr3-review-code
archive/plan/previews-865
archive/port/port-attachments-3
archive/port/contacts-merge
fix/motion-audit-859
fix/motion-audit-859-mac
archive/port/port-pickers
archive/port/port-tables-2
archive/port/port-tables
recovered/local/sharing-s1-pr2-room-snapshot-candidate
archive/fix/parallel-test-flakes-code-minipc01
docs/imap-766-readonly-slice
feat/dav-recorder-v3
research/788-diagnosis
archive/fix/parallel-test-flakes
archive/perf/pr792-cold-index-edit
docs/sharing-slice-1
recovered/feat/dav-recorder-v2
recovered/feat/dav-recorder-v2-edd7bbb
spike/imap-766-s0-cases
archive/fix/undo-768
recovered/feat/dav-recorder
recovered/feat/dav-recorder-901acd4
feat/contacts-import
perf/cold-growth-on-764
perf/cold-growth-on-tiering
recovered/feat/tasks-set-status
feat/tasks-move-reorder
feat/tasks-delete-promote-duplicate
feat/carddav-writes
perf/quota-on-tiering
perf/quota-simple
perf/cold-growth-on-quota-stack
recovered/perf/cold-growth-on-tiering
feat/calendar-identity
feat/calendar-event-parser
feat/calendar-props-maps
port/glass-when-ring
recovered/feat/tiering-761-s1-wip-8132a84
recovered/feat/tiering-761-s1-wip-9da4094
recovered/feat/tiering-761-s1-wip-724512c
recovered/feat/tiering-761-s1-wip-66e667e
recovered/feat/tiering-761-s1
wip/6by32-01-tier-761-s1-pause-20261030
spike/imap-766-s0
wip/6by32-02-calternal-pause-20261030
wip/8by64-01-review-688-pause-20261030
wip/6by32-01-verify-744-pause-20261030
wip/6by32-01-verify-742-pause-20261030
fix/private-staging-759b
wip/6by32-01-review-748-pause-20261030
wip/6by32-01-review-733c-pause-20261030
wip/6by32-01-review-733b-pause-20261030
review/calendar-month
wip/local/bm15-trash
plan/759b-staging
review/767b-tests
review/preview-2026-10-29
docs/tiering-731-plan
wip/c6b02-review-733d
wip/c6b02-bm1-full-a
docs/deploy-plan
fix/storage-owner-liveness-642
fix/storage-fix-7
feat/tiering-731
wip/tiering-731-first-attempt
perf/idle-honest-2
fix/storage-private-tmp-642-dev
fix/storage-exact-file-quarantine-642
perf/one-flush-save
review/calendar-static
review/indexing-ring
review/when-field-2
proto/block-identity-2-review
proto/block-identity-review
review/when-field
issue/tasks-create-ids
issue/tasks-create
review/combined
review/task-polish
review/top-buttons
review/q1-q5
archive/integ325-293
archive/integ325-ci
issue/calendar-adr
archive/old/train/2026-10-23bk2
archive/old/train/2026-10-23bk
issue/469-mockup-9a
issue/smart-tasks-mockup
issue/469-menus
issue/652-signout-flake
issue/652-history-fix7
issue/652-history-fix6
archive/old/issue/spring-check-perf
issue/spring-check-perf
issue/659-rename-fast
archive/old/train/2026-10-21ar
issue/search-hardening-3
issue/652-history-fix5
issue/660-port-sheets-glass
issue/652-history-fix4
issue/652-history-fix3
issue/652-history-fix2
issue/652-history-flake
train/2026-10-21an
issue/settings-admin-port
issue/search-port
train/2026-10-20am
issue/storage-split-fix2
issue/storage-split
archive/old/issue/folder-ids-fix
train/2026-10-20al
archive/old/issue/folder-ids
train/2026-10-20ak
issue/tables-mockup
train/2026-10-19aj
train/2026-10-19ai
issue/469-merge-fixes
issue/sidebar-band
archive/old/issue/608-settings-spec
train/2026-10-19ah
issue/swipe-offscreen
train/2026-10-19ag
archive/old/issue/590-nlp-adr
archive/old/issue/587-event-after-write-2
train/2026-10-19af
archive/old/issue/587-event-after-write
issue/469-pill-room-c
issue/469-pill-room
train/2026-10-19ae
issue/469-narrow-handle
issue/397-ios-swipe-2
issue/469-desk-fixes
archive/old/issue/auto-update-adr
issue/469-filter-gap
issue/469-port-1b
issue/442-opacity-flake
issue/327-web-fast-3
archive/old/issue/469-port-1
issue/469-port-1
issue/327-web-fast-2
archive/old/issue/327-web-fast
archive/old/issue/425-stt-bench-vq1
archive/old/issue/445-no-bleed
archive/old/issue/400-swipe-mockup-2
issue/426-client-review
issue/426-client-2
issue/426-client
archive/old/issue/476-safe-area-lab
archive/old/issue/445-top-light
issue/471-blocks-mockup
archive/old/issue/448-links-app-2
archive/old/issue/448-links-app
archive/old/issue/398-cold-links
issue/434-442-small-2
issue/434-442-small
archive/old/issue/398-unload
archive/old/issue/445-bottom-band
issue/445-bottom-band
issue/351-rem-3
issue/351-rem-2
issue/351-rem
archive/old/issue/327-first-note
issue/395-width-phone
archive/old/issue/327-typing
issue/396-ios-edges
issue/397-ios-swipe
archive/old/issue/327-notes-index
issue/345-347-contrast-empty-2
archive/old/issue/44-arenas
issue/44-arenas
archive/integ325
archive/old/issue/327-perf-harness
archive/old/issue/44-thp
issue/44-thp
archive/old/issue/285-sticky-pills
archive/old/issue/44-trim-3
issue/44-trim-3
archive/old/issue/165-cards
archive/old/issue/165-picker-2
archive/old/issue/212-multi-select
No results found.
Labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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#125
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From #90: on the perf VM, delete is 22–38 ms p50 and 113–150 ms p95; restore is 22–35 ms p50 and 37–55 ms p95. Each delete does about 4 serial fsyncs at 8–15 ms each.
Proposal: answer once the job's plan is durable, and flush its final "done" write in the background. That's safe because the job journal replays on restart. The change is in the shared job code that rename and make-note also use, so measure those too. Keep the budgets gate.
Starting re-measurement on branch
issue/125-delete-remeasure, based onorigin/devatc82161d7c6fefcd476d73a92f1fbc2461ef2fef1.Source inspection on base
c82161d7: the three relevant #253 commits (2a0302f,c48bdfe,80557e8) are not ancestors oforigin/dev. The current delete move still relies onrename_safelysyncing both source and destination directories before returning. The existingtrash_benchonly times directNotescalls for delete/restore; it has no permanent-delete samples or interleaving. Latency numbers are pending, so there is no performance conclusion yet.Implementation is waiting for review of the proposed design in the active chat. Source inspection is complete; no benchmark run or code change has started. Approval is needed before adding the focused harness scenario and timing instrumentation.
Starting the delete/restore remeasurement on branch
issue/125-delete-remeasure, based onorigin/devatc82161d7c6fefcd476d73a92f1fbc2461ef2fef1. I will measure the requested SSD and rotational-disk scenarios and report findings here.The SSD baseline is waiting for the required perf VM lock:
/root/perf-vm.lockis currently held by another run. I have not started a competing benchmark. Staging remains at 22% disk use; measurements are pending the lock becoming available.SSD baseline complete on
/dev/sda1(non-rotational), with 5 warm runs × 30 interleaved API operations per metric (150 samples each). Values are p50 / p95 / max in ms; p50 and p95 follow the harness median-of-runs style, max is across all samples.Finding: 100k restore p95 is 169 ms, above the 50 ms SSD threshold. Delete and permanent delete p95 are below the threshold. I’m tracing the restore tail before deciding which #253 changes still apply.
SSD cause breakdown from debug timing logs in the final 100k warm run (30 timed cycles plus 30 pre-trash deletes):
watch.reconcileindex.updateremoveindex.flushflush.rename_from_trashhistory.job_progressrestorehistory.commitInference from those timings and the current watcher code: reconciliation folds every indexed path while holding the index lock; a request can then wait on that lock during its restore path lookup. The watcher stall accounts for the long tail far better than the awaited file flush or history commit. I will verify this against the HDD baseline before applying the relevant #253 index/watcher changes.
Rotational-disk baseline complete on
/dev/sdb1(ext4, ROTA=1), same 5 warm runs × 30 interleaved operations per metric (150 samples each). Values are p50 / p95 / max in ms.Finding: 10k restore and both 100k job operations exceed the 150 ms HDD p95 threshold. The 10k delete p95 is exactly 150 ms; permanent-delete p95s are below the threshold. I’m applying the watcher/index changes that match the measured SSD cause.
The HDD trace confirms the same cause at 100k. In the final warm run:
watch.reconcile(30 samples) p50 33.4 ms, p95 774.8 ms, max 1217.2 ms;index.updateremove (60) p95 0.05 ms, max 181.2 ms;index.flush(90) p95 65.7 ms, max 208.5 ms; durable restore rename (30) p95 61.9 ms; durablehistory.job_progressrestore (30) p95 40.3 ms. The watcher scan is the largest tail; index log flush also competes with the durable file and history flushes. I’m porting the O(notes) watcher lookup, lazy non-awaited index writes and the safe queued final job status save.Independent durability and performance review started on branch issue/125-delete-review, based on issue/125-delete-remeasure at
c37ffe1031. Comparison base origin/dev isc82161d7c6. I will audit crash consistency, directory counts, and interleaved HDD trash.forget performance, then run the required gates.Audit finding from code: trash::put removes the existing Trash markdown before attempting the source move. With a durable delete rename and a lost lazy index removal, replay can see the old index path and remove the only surviving file. trash::restore also returns success for an indexed path even when that file does not exist, leaving the note in Trash. Startup scan and bulk replay start concurrently (lib.rs home()), so scan repair is not guaranteed to precede these operations. Added two focused stale-index regression tests; running them before fixes. The original SIGKILL delete test creates an open room, whose delete uses synchronous forget_index, so it does not cover the new closed-note lazy removal.
Compiling rusqlite v0.40.2
Compiling calternal-notes v0.1.0 (/home/kayg/Developer/calternal-wt-125/crates/notes)
Finished
testprofile [unoptimized + debuginfo] target(s) in 2m 14sRunning unittests src/lib.rs (/home/kayg/Developer/calternal-target-125/debug/deps/calternal_notes-6ac741039e501ea4)
running 2 tests
thread 'tests::trash::delete_replay_with_a_stale_index_keeps_the_only_file' (1654465) panicked at crates/notes/src/tests/trash.rs:383:44:
called
Result::unwrap()on anErrvalue: Error { code: NotFound, detail: "note 01a14366-d8e2-73f1-ba86-23e1c4e88b5b was deleted" }note: run with
RUST_BACKTRACE=1environment variable to display a backtracetest tests::trash::delete_replay_with_a_stale_index_keeps_the_only_file ... FAILED
thread 'tests::trash::restore_with_a_stale_index_really_moves_the_file_back' (1654466) panicked at crates/notes/src/tests/trash.rs:399:5:
assertion failed: env.notes_dir().join("Plans.md").is_file()
test tests::trash::restore_with_a_stale_index_really_moves_the_file_back ... FAILED
failures:
failures:
tests::trash::delete_replay_with_a_stale_index_keeps_the_only_file
tests::trash::restore_with_a_stale_index_really_moves_the_file_back
test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 184 filtered out; finished in 0.05s
error: test failed, to rerun pass
-p calternal-notes --libSecond confirmed finding: Index::under's leaf fast path returns only the newest ID's path when two IDs shadow the same folded path. The previous full scan returned both paths, allowing watcher removal to remove both IDs. New regression test under_keeps_shadowed_paths_for_watcher_removal fails with left ["same.MD"], right ["Same.md", "same.MD"]. Fix retains the full lookup when shadowed IDs exist; ordinary leaf events keep the fast path. Parent counts themselves are incremented/decremented centrally in set/unset and rebuilt on load, so rename and removal do not bypass count maintenance.
Third confirmed finding: an indexed outside markdown file can have no calternal-id in its bytes. After restore, losing the lazy put line lets startup assign a different ID to the same file, orphaning its original identity/history. The regression restore_durably_indexes_a_note_without_an_embedded_id fails with persisted.path_of(id) == None instead of Some("Outside.md"). Fix: keep lazy index puts for files carrying the correct embedded ID, but await a durable index mapping before renaming files without that ID. Existing SIGKILL cases plus new chained delete/restore/delete/forget cases passed; the new shadow-path and missing-ID tests exposed the additional gaps.
Durability fixes and expanded tests now pass: calternal-notes reports
test result: ok. 192 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 6.46s. This includes stalling the index log across SIGKILL for closed-note deletes/restores, rapid delete/restore and restore/delete, restore/delete/permanent-delete, direct stale-index replay before scan repair, raw markdown identity persistence, folded lookup differential checks, and nested folder rename/outside-move event bursts. Baseline release build is complete; the author release build and interleaved 10k HDD measurements are next. The final workspace gates will follow the performance verdict.The permanent-delete regression is reproducing in the interleaved 10k HDD comparison, using the same harness and build environment: baseline p50 values so far are 32.719, 36.477, 32.788 ms; author p50 values are 105.030 and 102.853 ms (author p95 207.008 and 201.999 ms). Measurements continue to five runs each. trash::forget's removal and History::purge code are unchanged except tracing; delayed background index fsyncs are a candidate for the interference. I am checking this rather than treating the earlier table as VM noise. All workspace tests passed; Clippy passed after correcting lock lifetimes in the new tests.
Five interleaved runs per variant are complete (10k HDD, 30 samples/run, the author's Trash scenario). Median run p50/p95 and largest max: baseline 32.788/91.934/164.531 ms; author
c37ffe198.529/201.999/284.030 ms. This is a real regression in this comparison, not an inference from the earlier table. A separate debug run measured overlap between index fsync and Trash directory sync in 22 of 30 permanent deletes, including a 223.496 ms Trash sync overlapping a 208.441 ms index fsync. I am testing an ablation/fix: append rebuildable lazy cache entries without background fsync, while explicit durable updates, compaction and unload sync earlier writes. The required Trash directory sync and history purge remain synchronous before the answer, and restored files without embedded IDs retain their new awaited index write. Final fixed-branch measurements will decide whether this removes the regression.A further power-loss finding in the existing index-log writer: loading skips an incomplete final JSON record, but appending the next durable mapping directly after an unterminated tail joins both records into invalid JSON. The next mapping was acknowledged durable yet was absent on reload. New regression a_torn_tail_cannot_swallow_the_next_durable_mapping fails with None versus Some("Outside.md"). This matters for the restored outside-file identity guarantee. The smallest fix separates append batches with a newline, so an old torn tail cannot consume the next record. The extra blank lines are ignored by the existing reader. This was also present in the baseline; the audit fixes it on the review branch.
The index-fsync ablation improves but does not fully remove the regression: one 30-sample no-background-index-fsync run measured trash.forget 67.9 ms p50 / 143 ms p95, compared with 98.1/162 ms for a durability-fixes-only control. The remaining deferred restore-completion history write also competes with subsequent Trash removal. The smallest additional change is to await final progress for batches containing restore steps; other final job saves remain queued. This strengthens restore completion durability and moves its flush cost back into the restore answer. SIGKILL restore tests will now expect a durable done row, while still losing the lazy index put and checking startup repair. Delete tests continue to force uncommitted final progress and replay.
The latest gate rerun hit an existing fanout seed-crash test's 30-second client-response timeout: tests::fanout::a_crash_before_the_seed_is_durable_never_doubles_text, at tests/clients.rs:298. All new review regressions passed in that run (193 other notes tests passed). Earlier full workspace runs passed this test. The final UTF-8 index change does not alter this test's valid records, and its scenario does not use Trash or bulk jobs. I am rerunning it alone, then rerunning the required workspace gates with RUST_TEST_THREADS=2 to reduce shared-host contention. The timeout output will be retained in the result evidence; it will not be presented as a passing gate.
The five-run fixed comparison recovered trash.forget: baseline 35.239/87.510/119.259 ms versus review 35.402/62.987/184.608 ms (p50/p95/largest max). However, I am not accepting that candidate yet: restore p95 rose to 304.303 ms versus baseline 163.537 ms. The index writer still delayed its cache appends by 100 ms even after fsync was removed, moving allocation and write I/O into later operations. I have removed that delay as well; queued records are now appended immediately, with durable commands still syncing earlier cache writes. I will measure the final variant again, including the conservative missing-Trash-details retention fix once its regression test runs. Shared build slots are currently occupied by other jobs; the required wrappers remain in use.
Additional power-loss finding (also present in baseline): Trash details are not independently fsynced, and read() reconstructed deleted_ms from the markdown file's modification time when those details were missing. start() runs empty(now - KEEP) 60 seconds after boot. A note last edited more than 30 days ago could therefore be permanently purged shortly after a just-acknowledged delete and power loss. The new regression creates a Trash file with a 1970 mtime and no details, and requires a fresh retention age. The fix uses recovery time for unknown deletion times and writes the recovered details so pagination and future sweeps see a stable age. If that metadata write fails, later reads conservatively grant another grace period. Explicit permanent deletion and Empty Trash still work. This avoids adding another fsync to every normal delete.
{"deleted_ms_from_old_binary": 1000, "retention_cutoff_ms": 1789542450910, "newly_trashed_note_eligible_for_automatic_purge": true}
The API reproduction now passes on the final review binary. Before: deleted_ms was 1000, so the newly trashed note was eligible for automatic purge. After: deleted_ms is the current recovery time (1792134743470), and it is not eligible for automatic purge. The same synthetic 1970-mtime note and missing-details setup was used in both runs. The final VM binary hash matches the local build (23af8ceab029922e50072b95d309d3867e4def643e622970f8d4c8ce4ffd38b8). The previously timed-out seed-crash test also passed alone: 1 passed in 0.11s. The full workspace gates are rerunning with two test threads.
Independent review finished. Head SHA:
1b2c280771. Tested and measured code SHA:fe53835790; the final commit adds review evidence only.Review PR: #477. It builds on issue/125-delete-remeasure, opened as PR #475: #475. Both target dev and replace no PR. Nothing was merged or deployed, and this issue remains open.
Six durability/index problems are fixed: delete replay removing the surviving Trash file; stale-index restore answering without moving the file; restored outside markdown losing its ID; leaf lookup omitting shadowed paths; torn JSON/Unicode log tails hiding durable mappings; and missing Trash details causing premature retention purge. Central directory-count maintenance matched full scans across moves, Unicode paths, reloads and event bursts. Queued final progress preserves app-operation ordering through the durable plan/purge writer; restore completion is now awaited to remove flush contention.
The permanent-delete regression was real: initial baseline p50/p95 was 32.788/91.934 ms versus author 98.529/201.999 ms. Final baseline is 33.809/71.618 ms versus review 35.835/67.174 ms, with five interleaved runs and 30 samples per run for every build. Per-run p50 ranges overlap. Maxima remain variable. Final restore p95 is 203.345 ms versus baseline 202.533 ms; the original 150 ms target remains unmet. The report records that limitation and the remaining original-path/title fallback when unsynced Trash details are lost to a true power failure.
All required gates pass. Workspace tests: 445 passed, two ignored. The earlier seed-crash timeout passed on isolated recheck and the final two-thread workspace run. Full report:
1b2c280771/docs/perf/issue-125-delete-review.mdGate output and performance table, copied verbatim below:
Issue #125 review: verification output
Tested code commit:
fe53835(later commits contain review evidence only).All heavy commands ran through the required build-slot wrapper, with
CARGO_TARGET_DIR=/home/kayg/Developer/calternal-target-125. The final workspacetest command used
RUST_TEST_THREADS=2. Compiler and library setup used theexisting Nix GCC/OpenSSL helper; command output below is copied verbatim.
cargo fmt --all --checkExit status: 0.
Output was empty.
cargo clippy --workspace --all-targets -- -D warningsExit status: 0.
cargo test --workspaceExit status: 0.
Seed-crash test recheck
The concurrent run timed out waiting for a client response. It passed alone
and in the final two-thread workspace run. Isolated recheck output (verbatim):
Earlier timeout output (verbatim excerpt):
Missing-details API reproduction
Same synthetic note, 1970 mtime, missing Trash details; previous and fixed
binaries, respectively (verbatim):
trash.forgetperformance tableFive runs per build, 30 samples per run, interleaved on the perf VM HDD.
Output (verbatim):
Evidence moved out of the repo (
docs/perf/issue-125-delete-remeasure.md):Issue #125: delete and restore remeasurement
Measured 2026-10-16 on the perf VM, from base
c82161d7c6fefcd476d73a92f1fbc2461ef2fef1.Method
/dev/sda1, ext4, non-rotational. Rotational disk:/dev/sdb1, ext4, mounted at/mnt/b/hdd-ext4.Before and after
Delete and restore are now under threshold at all measured SSD points and at 100k on HDD. HDD 10k restore is 152 ms p95, 2 ms over the 150 ms target. Permanent deletion remains slower on HDD and was measured separately from the delete/restore threshold.
Cause breakdown
Baseline debug traces at 100k showed watcher reconciliation dominating the tail. On SSD,
watch.reconcilewas p50 27.164 ms and p95/max 1892.46 ms (9 spans);index.update removep95 was 0.031 ms,index.flushp95 10.310 ms, restore rename p95 18.047 ms, and history commit p95 5.759 ms. On HDD,watch.reconcilewas p50 33.431 ms, p95 774.786 ms, max 1217.192 ms;index.flushp95 was 65.689 ms, restore rename p95 61.878 ms, and history commit p95 28.586 ms.The watcher folded every indexed path while holding the index lock. The final build uses a folded parent-directory count to return immediately when a vanished path has no indexed descendants, and retains the full folded lookup for folder removals. At 100k on SSD,
watch.index_underdropped to p50 0.001 ms / p95 0.014 ms (33 spans), andwatch.reconcileto p50 2.702 ms / p95 15.761 ms (9 spans). At 10k on HDD,watch.index_underwas p50 0.000 ms / p95 0.006 ms.The final job-progress write is queued but its flush is not awaited before the answer; ordinary progress and the durable job plan remain synchronous.
history.job_progressenqueue was p95 0.023 ms on SSD at 100k and 0.026 ms on HDD at 10k. Index mutations are in-memory immediate;index.updatep95 was at most 0.027 ms on the SSD run and 0.023 ms on the HDD run. The index log and final history update can flush in the background.The remaining HDD 10k restore tail is explained by two required serialized syncs: the durable history job-plan commit p95 was 66.784 ms, and
rename_safelyfor the restore p95 was 79.607 ms. Their sum is about 146 ms before request overhead, consistent with the 152 ms API p95. On HDD 100k those spans were 45.401 ms and 61.554 ms p95, with 145 ms overall restore p95.Permanent deletion from Trash has a separate durable path. On HDD,
flush.trash_removep95 was 81.633 ms at 10k and 169.893 ms at 100k;history.purgep95 was about 45 ms. This accounts for the hightrash.forgetp95 (201 ms and 181 ms). That path was measured and instrumented but not relaxed because both file removal and history purge must be durable before the answer.Changes and durability
rename_safelyand its directory syncs are unchanged.running), restarts on the same data, and verifies replay leaves one correct file and Trash state. Both tests passed in the workspace run.The implementation and result are committed locally on
issue/125-delete-remeasure. No PR was opened because the requiredGIT_SSH_COMMAND="ssh -i /home/kayg/.ssh/git.kayg.org" git push -u origin issue/125-delete-remeasurewas rejected withPermission denied (publickey). Forgejo issue, comment, and pull-request API routes returned HTTP 500 ({"message":"","url":"https://git.kayg.org/api/swagger"}), so the final issue comment could not be posted.Risks: the HDD 10k restore p95 remains 2 ms above target because of required sync latency. Very large maxima remain under shared-host and rotational-disk load (for example, SSD 100k restore max 1341 ms). HDD permanent-delete p95 increased versus baseline; its synchronous Trash directory removal and history purge dominate the current trace. The directory counter uses memory proportional to distinct indexed parent paths; the measured fixture has 900 nested notes at 100k, and idle RSS remained about 13.2–13.4 MB.
Required gates
cargo fmt --all --checkexited 0; stdout/stderr was empty.cargo clippy --workspace --all-targets -- -D warningsexited 0. Output (verbatim):cargo test --workspaceexited 0. Final profile line (verbatim):Test target summaries (verbatim):
Evidence moved out of the repo (
docs/perf/issue-125-delete-review.md):Independent delete and restore review (#125)
Reviewed
c37ffe1031be35e1251eeb070173bd32fa5641e1againstc82161d7c6fefcd476d73a92f1fbc2461ef2fef1. Fixes build onissue/125-delete-remeasureinissue/125-delete-review.Confirmed durability and index findings
Delete replay could remove the only file. A closed-note delete removes
its index entry lazily and durably renames the file to Trash. Startup scan
and job replay start concurrently. With the old index entry still present,
trash::putremoved the Trash file as supposedly stale, then failed to openthe nonexistent source. The stale-index regression failed with
NotFound.Replay now recognizes the surviving Trash file before removing anything,
repairs the index, and returns the existing result.
Restore could answer without restoring. The old indexed path was treated
as proof of an already completed restore, even if that file did not exist.
The stale-index restore regression failed its file-exists assertion. Restore
now requires an actual file before taking that shortcut.
Outside markdown could lose its stable ID. Outside files need not carry
calternal-id. Losing a restore's lazy index put left no durable associationbetween that file and its ID; scanning would assign a new ID. The regression
observed
persisted.path_of(id) == Noneafter the answer. Restore now checksthe file header and awaits the index write when its ID is not recoverable
from the bytes. Files carrying the correct ID retain the lazy path.
The leaf shortcut omitted shadowed paths. With two IDs at one folded
path,
underreturned just the newest spelling. The prior full lookupreturned both, letting reconciliation remove both IDs. The regression got
["same.MD"]instead of["Same.md", "same.MD"]. The shortcut now fallsback to the full lookup whenever shadowed IDs exist.
An unterminated log tail swallowed the next durable mapping. Loading
ignored an incomplete JSON tail, but the next append continued on that
same line. A fresh mapping acknowledged durable was absent on reload.
The failing regression covers this exact sequence. Append batches now
terminate an unterminated previous tail before writing new records, and
loading skips invalid UTF-8 records as well as malformed JSON. The regression
also covers a tail cut inside a Unicode character. This bug was
also present in the comparison baseline.
Lost details could cause immediate retention purge. This pre-existing
fallback used the markdown's old modification time as its deletion time.
The 30-day sweep starts 60 seconds after boot, so an old note freshly moved
to Trash could be purged after a power loss erased its unsynced details.
A read-only API reproduction against the previous binary returned
deleted_ms: 1000for the new Trash entry, making it eligible immediately.The regression uses a 1970 mtime and requires a fresh grace period. Recovery
now grants that grace period and writes recovered details to keep pagination
and future sweeps stable. If this write fails, future reads renew the grace
period. Explicit permanent deletion and Empty Trash still apply.
The parent-directory counter itself has no independent update path:
setfirst unsets the old slot, adds every folded ancestor, and
unsetremovesthose ancestors. File loading and unloading rebuild/reset the same state.
A differential test compares
underwith a full folded scan across repeatedmoves, removals, shared paths, Unicode names, compaction and unload/reload.
A reconciliation test exercises nested folder renames and moves outside Notes
with repeated parent/child event paths.
Crash ordering
The job plan is committed synchronously before execution. Completed final
progress is sent to the history writer before releasing the job lock and
answering. Batches containing restores now await final progress to prevent
that background sync from competing with a following Trash removal. A subsequent
job's synchronous plan write commits preceding queued progress in FIFO order. Permanent deletion's synchronous history purge does
so too. Therefore acknowledged app operations do not replay older deletes or
restores over a later committed plan. File moves still synchronize both source
and destination directories before answering.
The original delete SIGKILL test created an open room and used the synchronous
index-removal path. The revised tests close rooms and explicitly stall the
index writer, as well as holding final history progress. They kill the child
only after its answer, assert the persisted job state (
runningfor aqueued delete,
donefor a restore), restart and check the files, Trash, index, ordinary list and paged list. Additional cases cover rapiddelete/restore, restore/delete, and restore/delete/permanent-delete. A direct
permanent-delete attempt on a restored live note is rejected and remains rejected across a kill. Direct
stale-index tests force execution before scan repair, independent of scheduling.
SIGKILL tests exercise process death, not loss of the kernel's page cache or a
storage device's write cache. Power-loss reasoning assumes successful filesystem
syncs are honored. Trash details are intentionally not separately synced in the
original implementation; missing details are reconstructed from the markdown,
so original path/title metadata can fall back to the note title after power loss.
Permanent-delete regression investigation
The first comparison alternates baseline and author builds for five runs each
on
/mnt/b/hdd-ext4ofroot@10.69.69.63. Every invocation uses the author's--trash-onlyscenario with 10k notes and 30 timed samples per operation.Each invocation rebuilds its indexed fixture before one warm run; all ten
runs use the same fixture seed, harness, compiler, release settings and runtime
libraries. Runs alternate their order in each pair. Every VM run holds
flock -o /root/perf-vm.lockand is launched through the shared build-slotwrapper. No staging or production VM is used.
The comparison reproduces the regression: median run p50/p95/max is
32.788/91.934/164.531 ms for baseline versus 98.529/201.999/284.030 ms for the
author branch. Max here is the largest sample, not the median of run maxima.
The permanent-delete unlink, directory sync and history purge are unchanged
apart from tracing. A separate debug run shows index fsync overlapping Trash
directory sync in 22 of 30 deletes. One 223.496 ms Trash sync overlaps a
208.441 ms index fsync. A control build with only the durability fixes still
measures 98.1 ms p50 / 162 ms p95 for permanent delete in one run.
The fix appends rebuildable lazy index records without background
fsync. The next durable command, compaction or unload synchronizes all earlier
writes, including lazy records written in previous batches. The awaited
mapping for markdown without an embedded ID remains durable before restore.
Note files, directory moves, the job plan, permanent deletion and history
purge retain their required syncs. A no-background-index-fsync control improved
permanent delete to 67.9 ms p50 / 143 ms p95 in one run, but left a remaining
regression. Final progress for batches containing restore steps is therefore
awaited, returning its sync cost to the restore answer. This is stronger
completion durability and leaves other final batches queued. The final
measurement below tests whether this removes the regression. The first fixed
comparison recovered permanent-delete p50/p95 to 35.402/62.987 ms versus
35.239/87.510 ms for baseline, but restore p95 was 304.303 ms versus
163.537 ms. The final variant also removes the 100 ms delay before cache
appends, so cache allocation and write I/O are no longer shifted into a later
operation. Those intermediate results are retained separately.
The timing command for every invocation is:
The source build uses Rust 1.99.0, the repository's release profile (fat LTO,
one codegen unit), its SQLite fdatasync setting, and
CARGO_TARGET_DIR=/home/kayg/Developer/calternal-target-125. Per-run metricsummaries and binary hashes are retained with this report. The trace/control
runs are separate from the five-run comparison tables.
One concurrent workspace gate run timed out in the existing
tests::fanout::a_crash_before_the_seed_is_durable_never_doubles_texttest after30 seconds waiting for a client response; 193 other notes tests passed in that
run. Earlier full workspace runs passed it. The failure is retained in the
verification artifact. The final verification reruns that test alone and runs
the full required commands with
RUST_TEST_THREADS=2to reduce contention onthe shared host.
Final result
The permanent-delete regression is real, and the final fixes recover it to
baseline run variation. The original comparison was about 3× slower at p50.
Final p50 is 6.0% above baseline and p95 is 6.2% below baseline. Per-run p50
ranges overlap. The largest sample remains higher, so this does not claim
equal worst-case latency on the shared VM.
c82161dc37ffe1c82161dfe53835Final delete p50/p95 is 66.233/131.859 ms versus baseline
104.816/232.289 ms. Restore p50/p95 is 103.526/203.345 ms versus baseline
93.288/202.533 ms. Awaiting restore completion returns its sync cost to the
restore response; the final tail is comparable to baseline. The original
150 ms HDD restore target is not met in this review. Permanent-delete
syncs and note durability were preserved.
All final gates pass: format check, workspace Clippy with warnings denied,
and workspace tests (445 passed, two ignored; 195 notes tests passed).
The isolated seed-crash recheck passes too. Full command output is copied
verbatim in the verification artifact.
Per-run metrics and binary hashes include
both the intermediate and final comparisons. The measured and tested code
commit is
fe53835; later commits contain review evidence only.Evidence moved out of the repo (
docs/perf/issue-125-delete-review-gates.md):Issue #125 review: verification output
Tested code commit:
fe53835(later commits contain review evidence only).All heavy commands ran through the required build-slot wrapper, with
CARGO_TARGET_DIR=/home/kayg/Developer/calternal-target-125. The final workspacetest command used
RUST_TEST_THREADS=2. Compiler and library setup used theexisting Nix GCC/OpenSSL helper; command output below is copied verbatim.
cargo fmt --all --checkExit status: 0.
Output was empty.
cargo clippy --workspace --all-targets -- -D warningsExit status: 0.
cargo test --workspaceExit status: 0.
Seed-crash test recheck
The concurrent run timed out waiting for a client response. It passed alone
and in the final two-thread workspace run. Isolated recheck output (verbatim):
Earlier timeout output (verbatim excerpt):
Missing-details API reproduction
Same synthetic note, 1970 mtime, missing Trash details; previous and fixed
binaries, respectively (verbatim):
trash.forgetperformance tableFive runs per build, 30 samples per run, interleaved on the perf VM HDD.
Output (verbatim):
Raw runs (
docs/perf/issue-125-delete-review-runs.json), moved out of the repo:Closing during the 26 Oct handover cleanup: The delete/restore fixes landed in dev (PRs #477, #498).