perf(media): the apply fsyncs the journal once per batch, not per move #108

Merged
dank merged 1 commits from perf/media-apply-batch into main 2026-10-31 18:20:17 -07:00
Owner

Why

The 58k-rename TVShows apply on the spinning array spent most of its wall time in
journal durability, not in renames: one fsync per rename, and on top of it a
quadratic Journal.already() scan over a record list that grows all run.

Change

  • Journal indexes move intents by (src, dst); already() is O(1).
  • --batch N (default 64): write N intents → fsync once → perform those N
    renames. The durability rule is now per batch instead of per move, and it is
    unchanged in kind: no rename runs before its own intent is on disk, so a
    crash mid-batch replays that batch and resumes.
  • --batch 1 reproduces the old per-move flush.

Tests

tests/media_relayout.bats:

  • an apply interrupted mid-batch loses nothing — the rerun completes every move;
  • batching changes no final path and no journal line.

Full suite green (781 tests). Docs: the --batch paragraph in
serverAppConfigs-docs/Dankserver/Media Relayout.md.


cwd: /home/blank/.omp/wt/apply-batch · session: 2026-10-30T23-38-45-297Z_01a18f2e-18b1-7573-bcd5-ac99636f8bcb

## Why The 58k-rename TVShows apply on the spinning array spent most of its wall time in journal durability, not in renames: one `fsync` per rename, and on top of it a quadratic `Journal.already()` scan over a record list that grows all run. ## Change - `Journal` indexes move intents by `(src, dst)`; `already()` is O(1). - `--batch N` (default 64): write N intents → `fsync` once → perform those N renames. The durability rule is now per batch instead of per move, and it is unchanged in kind: **no rename runs before its own intent is on disk**, so a crash mid-batch replays that batch and resumes. - `--batch 1` reproduces the old per-move flush. ## Tests `tests/media_relayout.bats`: - an apply interrupted mid-batch loses nothing — the rerun completes every move; - batching changes no final path and no journal line. Full suite green (781 tests). Docs: the `--batch` paragraph in `serverAppConfigs-docs/Dankserver/Media Relayout.md`. --- cwd: /home/blank/.omp/wt/apply-batch · session: 2026-10-30T23-38-45-297Z_01a18f2e-18b1-7573-bcd5-ac99636f8bcb
dank added 1 commit 2026-10-31 18:05:03 -07:00
The 58k-rename apply on the spinning array spent most of its wall time in
fsyncs: one durability flush per rename, and a quadratic `Journal.already()`
scan over a growing record list on top of it. Both are the journal's, not the
renames'.

- `Journal` indexes move intents by (src, dst) so `already()` is O(1).
- `--batch N` (default 64) writes N intents, fsyncs once, then performs those
  N renames. The invariant is unchanged: no rename runs before its own intent
  is durable, so a crash mid-batch replays the batch and resumes.
- Tests: a mid-batch kill loses nothing and the rerun completes; batching
  changes no final path and no journal line.
dank merged commit 3344b51fbd into main 2026-10-31 18:20:17 -07:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dank/serverAppConfigs#108