Skip to content

refactor(durable-streams-rust): checkpoint cleanup — syncfs default-on (Linux), drop dead fsync fan-out#4707

Merged
balegas merged 1 commit into
perf/wal-checkpoint-syncfsfrom
perf/wal-cleanup
Jul 13, 2026
Merged

refactor(durable-streams-rust): checkpoint cleanup — syncfs default-on (Linux), drop dead fsync fan-out#4707
balegas merged 1 commit into
perf/wal-checkpoint-syncfsfrom
perf/wal-cleanup

Conversation

@balegas

@balegas balegas commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Final PR of the cardinality-cliff stack (#4697#4704#4705 → this): now that the ideal disk-based implementation is validated end-to-end, clean up what the campaign obsoleted.

  • --wal-checkpoint-syncfs defaults ON for Linux. Validated across the whole campaign: +51% at the 100k cliff, neutral-or-better everywhere below it, and with perf(durable-streams-rust): --stream-lanes — shard stream data files across per-device lane dirs #4705 it is one syncfs per stream lane. off remains as the escape hatch; non-Linux is unaffected (no syncfs, per-file loop as before).
  • Remove --wal-fsync-parallel / FSYNC_FANOUT. Parallel per-file checkpoint fsync regressed in every controlled test (f8 −11% on NVMe, f16 −19% CPU-constrained) — it steals device budget from the commit path — and the syncfs barrier supersedes it wholesale. The flag is accepted as a warning no-op so existing deploy scripts don't crash. Checkpoint durability (step 2) is now exactly two modes: per-lane syncfs (Linux default) or the serial per-file fallback.
  • e2e flag resets restore the platform default instead of hard false.
  • WAL_TUNING.md brought to the final state: stream-lanes results (1M wall broken: 68k → 212k), cardinality-based lane-split guidance (1 data lane ≤100k streams; 3+ at ≥500k), updated flag set, fd-ceiling note (durable-streams-rust: lazy stream-file fd management (1 fd per live stream ≈ nofile ceiling at 1M streams) #4706).

Verification

106/106 tests pass. No behavior change on non-Linux; on Linux the only default change is syncfs-on, measured extensively (suites: wal-syncfs, wal-splitlane, wal-sizetrigger, wal-stacked-1m, wal-streamlanes-1m).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Y3x7bcT9vLGiT4tXZeQpnk

…n (Linux), drop dead fsync fan-out, refresh WAL_TUNING

- --wal-checkpoint-syncfs defaults ON for Linux (validated +51% at the cliff,
  neutral below; off = escape hatch). Non-Linux unchanged (no syncfs).
- Remove FSYNC_FANOUT / --wal-fsync-parallel: parallel per-file checkpoint
  fsync regressed in every controlled test (f8 -11% NVMe, f16 -19% constrained)
  and the syncfs barrier supersedes it. Flag accepted as a warning no-op so old
  deploy scripts don't crash. Checkpoint step 2 is now two modes: per-lane
  syncfs (Linux default) or the serial per-file fallback.
- e2e resets restore the platform default instead of hard 'false'.
- WAL_TUNING.md: stream-lanes results (1M wall broken), cardinality-based
  lane-split guidance, updated flag set, fd-ceiling note (#4706).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y3x7bcT9vLGiT4tXZeQpnk

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-approved: all changes are within the durable streams package.

Base automatically changed from perf/wal-stream-lanes to perf/wal-checkpoint-syncfs July 13, 2026 21:54
@balegas
balegas merged commit 60a52c3 into perf/wal-checkpoint-syncfs Jul 13, 2026
8 of 11 checks passed
@balegas
balegas deleted the perf/wal-cleanup branch July 13, 2026 21:54
balegas added a commit that referenced this pull request Jul 14, 2026
…yncfs checkpoints, per-shard triggers, stream lanes (#4697)

Eliminates the WAL write cardinality cliff end-to-end. Formerly a 4-PR
stack (#4704, #4705, #4707 folded in here). Full deployment guidance:
`WAL_TUNING.md` (in this PR). **Validated by the canonical benchmark
campaign 2026-07-14** (ds-bench#6: `results/REPORT.md` +
`PROVENANCE.md`) run against this PR's head.

## The problem

WAL-durable write throughput collapsed with stream count: **10.4k ops/s
@100k streams** (vs ~110k @10k), degrading further under load. Two
compounding causes:
1. The checkpoint issued **one `fdatasync` per touched stream** — an
O(N) barrier storm sharing the device with commit fsyncs.
2. At extreme cardinality (~1M), checkpoint **writeback amplification**
(~40× for small appends: dirty page + inode + extents + journal per
file) saturated the single data device — one `syncfs` measured at 60–74
s.

## The changes

| commit | what | measured effect |
|---|---|---|
| syncfs checkpoint | one `syncfs` barrier per stream lane instead of
O(N-touched) `fdatasync` (unconditional on Linux) | +51% at the 100k
cliff |
| per-shard checkpoint triggers | `--wal-checkpoint-interval-ms` +
`--wal-checkpoint-wal-bytes` (retained-WAL/replay budget; shards
self-stagger, in-flight guard, panic-safe) | checkpoint cost ≈ 0 |
| `--stream-lanes N` | hash stream data files across per-device lane
dirs; N parallel per-lane syncfs; lane count persisted + validated on
open | 1M wall broken: 68k → **212k** (syncfs 60–74s → 6–11s) |
| cleanup | dead knobs removed (`--wal-fsync-parallel`, meta gates,
meta-sweep toggles, `--tier local`); memory×tier rejected at startup;
flag-clear WAL records decode as torn | smaller, safer surface |

## Results — canonical campaign 2026-07-14 (this PR's head, ideal
configuration)

**Write saturation** (`canonical-write`, 256 B appends,
c4d-standard-64-lssd, 3 stream lanes + 3 WAL lanes, pinned cores):

| streams | wal-ideal | memory (no-fsync ceiling) |
|---|---|---|
| 10k | 417k | 680k |
| 100k | **382k (−8%, no cliff)** | 632k |

vs 10.4k @100k pre-campaign = **37×**. At extreme cardinality (same
config): 285k @500k, 212k @1m.

**Reads** (unchanged by this PR, revalidated): catch-up 2.27–2.74 GiB/s,
cardinality-flat 10→100 streams; SSE tail p99 2–3 ms up to 2048
connections.

**Mixed interference**: 100k concurrent catch-up readers cost a pinned
50k ops/s write load nothing (303 MiB/s replay served alongside). The
2026-07-02 memory-mode delivery collapse no longer reproduces on this
build: delivery tracks writes 1:1 to 127k/s (wal: keeps pace to ~40k,
caps ~64k del/s at full write saturation).

## Correctness

- The recoverability contract is unchanged: ack = WAL group-commit
fdatasync; a WAL segment is recycled only after its records' stream
bytes are fsynced AND the durable-tail map is persisted. All knobs only
change *when/how* that sequence runs.
- 105/105 tests: syncfs crash-recovery e2e, 3-lane crash-recovery +
layout-spread + lane-mismatch rejection, memory-mode sidecar-skip
regression, randomized crash sim.
- CI green including all four conformance configs (`memory`,
`wal-default`, `wal-read-offload-always`, `wal-resident-cache`).
- Defaults preserve behavior except syncfs-on-Linux (extensively
measured); `--stream-lanes` defaults to 1 = byte-identical layout.
Changeset: patch.

## Follow-ups (tracked)

- #4695 log-structured store (removes per-file writeback amplification
structurally — the residual 100k→1M slope)
- #4696 cold tier as durable store
- #4706 lazy fd management (1 fd/live stream = 96% of the 1,048,576
ceiling at 1M streams)
- #4709 io_uring experiment (measured as a regression in v1 form;
default off, not for merge)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01Y3x7bcT9vLGiT4tXZeQpnk

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant