mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 10:37:23 +01:00
phase170: close staged commit headroom decision
This commit is contained in:
1 parent
4caf1b492b
commit
9b69b5b8fd
4 files changed
+457
-194
No files matched your search
@@ -1,245 +1,321 @@
|
||||
# Current Plan: Phase 170 Default WALStore Staged Commit Pipeline
|
||||
# Current Plan: Phase 171 Default WALStore Checkpoint Pipeline
|
||||
|
||||
Status: active evidence-first product-path milestone.
|
||||
Status: active evidence-first shipped-backend milestone.
|
||||
|
||||
Phase 168 proved that replacing positioned writes with `io_uring` does not
|
||||
improve a one-request-per-round WAL. Phase 169 proved that a separate segmented
|
||||
format can group queued requests correctly, but one owner that serializes
|
||||
encode, CRC, `WriteAt`, and publication still does not scale:
|
||||
Phase 170 proved that WAL append-call coalescing is mechanically effective but
|
||||
not sufficient under the complete default `walstore` workload:
|
||||
|
||||
```text
|
||||
segmented writers=1 101.98 MiB/s
|
||||
segmented writers=4 78.68 MiB/s
|
||||
positioned writers=4 79.51 MiB/s
|
||||
segmented entries/segment 1.348
|
||||
four/single 0.772x
|
||||
four/positioned 0.990x
|
||||
ordinary writers=4 64.09 MiB/s
|
||||
explicit batch writers=4 47.22 MiB/s
|
||||
batch/ordinary 0.737x
|
||||
ordinary WriteAt calls/entry 1.000
|
||||
batch WriteAt calls/entry 0.06250
|
||||
paired batch gains 2/5
|
||||
ordinary four-writer range 2.936x
|
||||
batch four-writer range 3.500x
|
||||
```
|
||||
|
||||
The next experiment must improve the shipped default path rather than add a
|
||||
third backend. The existing `walstore` format already has the useful primitive:
|
||||
`walWriter.appendBatch` preserves independently recoverable records while
|
||||
coalescing adjacent encoded bytes into fewer positioned writes. Phase 170 asks
|
||||
whether a bounded staged pipeline can use that primitive for concurrent
|
||||
ordinary writes without changing the disk format, durability contract, or
|
||||
recovery model.
|
||||
The batch control reduced WAL `WriteAt` calls by about 16x, yet throughput and
|
||||
stability did not improve. A staged append owner was therefore rejected before
|
||||
implementation.
|
||||
|
||||
The next measured seam is the other half of the shipped persistence pipeline.
|
||||
The default flusher snapshots the complete dirty map and, for each current
|
||||
entry, reads and validates WAL location metadata, reads block data, issues one
|
||||
extent `WriteAt`, fsyncs the shared file, persists the checkpoint, and advances
|
||||
the recyclable tail. This work competes with foreground WAL append on the same
|
||||
file and currently exposes only flush-count and byte-count evidence.
|
||||
|
||||
The plan review also found correctness debt in this path that must be fixed
|
||||
before optimization:
|
||||
|
||||
- `persistCheckpoint` currently updates the in-memory checkpoint before its
|
||||
superblock write succeeds, so a later cycle can incorrectly treat a failed
|
||||
checkpoint as reusable;
|
||||
- checkpoint metadata is not fsynced before in-memory WAL-tail reuse;
|
||||
- `Close` marks the store closed before `flusher.Stop` requests its final
|
||||
cycle, so that promised final flush currently exits without work;
|
||||
- default `walstore` has no explicit extent-write ownership rule between
|
||||
flusher writeback and direct rebuild BASE installation;
|
||||
- a WAL-slot mismatch currently deletes the dirty entry and continues, even
|
||||
though the flusher has not proved that entry was already durably
|
||||
checkpointed.
|
||||
|
||||
Phase 167 already proved that bounded contiguous checkpoint writes can reduce
|
||||
writeback syscall amplification in the opt-in `parallel-walstore`. Phase 171
|
||||
tests the corresponding mechanism in the default `walstore`, without changing
|
||||
its disk format, recovery rules, or public storage contract.
|
||||
|
||||
## Goal
|
||||
|
||||
Build one evidence-gated staged commit candidate inside the default
|
||||
`WALStore` implementation that:
|
||||
Build one evidence-gated checkpoint/writeback improvement for the shipped
|
||||
`WALStore` that:
|
||||
|
||||
- retains the current superblock, WAL entry, circular-region, dirty-map,
|
||||
flusher, checkpoint, and recovery formats;
|
||||
- validates and owns caller payloads before asynchronous admission;
|
||||
- assigns one contiguous LSN range only when a bounded batch is ready to
|
||||
commit;
|
||||
- uses the existing `walWriter.appendBatch` path for several ordinary
|
||||
existing-format records;
|
||||
- updates dirty-map and visible head state atomically from the complete append
|
||||
result;
|
||||
- completes each caller only after its record is appended and readable;
|
||||
- gives Sync an exact fence over requests admitted before the call;
|
||||
- keeps queue, payload, encoded bytes, waiter count, and batch size bounded;
|
||||
- proves a material ordinary-write gain before any mounted or RF3 claim.
|
||||
- first makes checkpoint publication, tail reuse, Close, and direct BASE
|
||||
overlap failure-safe;
|
||||
- measures foreground WAL and background checkpoint work independently;
|
||||
- preserves the current complete-snapshot checkpoint invariant;
|
||||
- materializes every verified latest dirty block before advancing checkpoint;
|
||||
- combines contiguous extent LBAs into bounded positioned writes;
|
||||
- retains compare-and-delete protection against concurrent overwrite;
|
||||
- keeps circular-WAL validation, retention pins, Sync, recovery, direct BASE
|
||||
install, and rebuild semantics unchanged;
|
||||
- reduces checkpoint I/O operations and stabilizes ordinary-write throughput
|
||||
before any mounted or RF3 claim.
|
||||
|
||||
This is one large milestone. Profiling, owner semantics, Sync/failure,
|
||||
flusher/recovery compatibility, comparable performance, and mounted admission
|
||||
are deliverables inside Phase 170.
|
||||
This is one large milestone. Instrumentation, bounded writeback, failure and
|
||||
concurrency semantics, recovery equivalence, Linux performance, and conditional
|
||||
mounted admission are deliverables inside Phase 171.
|
||||
|
||||
## Non-Goals
|
||||
|
||||
- No new backend name or file-format version.
|
||||
- No segmented record, direct I/O, `io_uring`, SQPOLL, fixed buffer, FUA, raw
|
||||
device, or NVMe atomic-write claim.
|
||||
- No arbitrary batching sleep. The owner may consume already admitted work;
|
||||
an isolated request must not wait for a timer.
|
||||
- No change to replication protocol, authority, frontend, CSI, or operation
|
||||
status semantics.
|
||||
- No weakening of the rule that `Write` is readable after return but becomes
|
||||
crash durable only after a covering successful `Sync`.
|
||||
- No mounted test used to excuse a failed local engine gate.
|
||||
- No new WAL format, backend name, frontend protocol, or product selector.
|
||||
- No staged append owner from Phase 170.
|
||||
- No `io_uring`, direct I/O, raw device, SQPOLL, fixed buffer, FUA, or NVMe
|
||||
atomic-write claim.
|
||||
- No partial dirty-map snapshot that advances checkpoint past omitted entries.
|
||||
- No disabled-flusher performance claim.
|
||||
- No arbitrary sleep added to make benchmark samples look stable.
|
||||
- No replication, authority, CSI, or Operation Layer semantic change.
|
||||
- No WAL-read coalescing unless D2 evidence shows it is the next measured
|
||||
limiter after extent-write coalescing.
|
||||
|
||||
## Existing Product Seam
|
||||
|
||||
Today `WALStore.Write` holds `s.mu` across:
|
||||
The current `flusher.flushOnce` path is:
|
||||
|
||||
```text
|
||||
assign tentative LSN
|
||||
-> wal.append
|
||||
-> encode + copy + CRC
|
||||
-> WAL writer lock
|
||||
-> one WriteAt
|
||||
-> dirty-map update
|
||||
-> advance nextLSN/H
|
||||
snapshot all latest dirty-map entries
|
||||
-> read one WAL header per entry and validate LSN/location
|
||||
-> read each current block from WAL
|
||||
-> WriteAt one block into its natural extent slot
|
||||
-> fsync the shared file
|
||||
-> persist checkpoint metadata
|
||||
-> advance WAL tail
|
||||
-> compare-and-delete each flushed dirty entry
|
||||
```
|
||||
|
||||
The storage instrumentation already exposes:
|
||||
This shape is correct but syscall-heavy. It also rereads WAL metadata when
|
||||
`readFromWAL` materializes data after the first validation pass. The initial
|
||||
change must target only extent writeback; WAL read materialization remains a
|
||||
separate measured decision.
|
||||
|
||||
- WAL copy, encode, and checksum operation/byte/time totals;
|
||||
- WAL append time and append-lock wait;
|
||||
- whole-write commit-lock wait;
|
||||
- `WriteAt` calls, bytes, maximum size, wrap count, and padding;
|
||||
- dirty-map update operation/time totals.
|
||||
The proven helper shape in `core/storage/parallelwal`:
|
||||
|
||||
`walWriter.appendBatch` already validates all entries, plans wrap/capacity
|
||||
before publication, encodes existing-format entries into a bounded buffer, and
|
||||
coalesces adjacent bytes into one `WriteAt` where possible. Phase 170 should
|
||||
reuse it, not create another codec.
|
||||
- sorts checkpoint LBAs;
|
||||
- groups only physically contiguous destination blocks;
|
||||
- caps each positioned extent write at 1 MiB;
|
||||
- returns an explicit operation count;
|
||||
- does not alter the WAL record format.
|
||||
|
||||
Phase 171 may reuse the algorithm, not the parallel backend's header, lane,
|
||||
extent-switch, or recovery model.
|
||||
|
||||
## Required Invariants
|
||||
|
||||
1. The bytes accepted by existing recovery remain unchanged.
|
||||
2. Every admitted request owns immutable payload bytes until terminal
|
||||
completion.
|
||||
3. Queue-full or validation rejection consumes no LSN.
|
||||
4. A failed batch consumes no visible LSN range, publishes no dirty-map entry,
|
||||
and returns an error to every request in that batch.
|
||||
5. A successful batch assigns consecutive LSNs in request order and updates
|
||||
WAL offsets, dirty-map entries, `nextLSN`, `S/H`, and caller results as one
|
||||
logical commit.
|
||||
6. Same-LBA requests remain ordered. Read-after-Write observes the latest
|
||||
completed LSN.
|
||||
7. Sync fences the highest request admitted before the call, waits for that
|
||||
prefix to finish, then preserves the existing fsync and superblock rules.
|
||||
8. Flusher/admission wakeups cannot deadlock with the owner, Sync, Close, or
|
||||
WAL-pressure callbacks.
|
||||
9. Circular wrap may split physical writes, but never split logical success or
|
||||
expose padding as a record.
|
||||
10. Close drains or terminally completes every admitted request before file
|
||||
close.
|
||||
11. Recovery, `ScanLBAs`, `R/S/H`, checkpoint, recycle-floor, direct BASE
|
||||
install, and retention behavior remain byte-for-byte or semantically
|
||||
equivalent.
|
||||
12. Disabled or rejected candidate code leaves the current synchronous
|
||||
`walstore` path unchanged.
|
||||
1. The current superblock and WAL bytes remain unchanged.
|
||||
2. A flush cycle advances in-memory or on-disk checkpoint only after every
|
||||
current entry in its complete snapshot has been verified, materialized,
|
||||
written, covered by a successful extent fsync, and followed by a successful
|
||||
checkpoint-metadata write and fsync.
|
||||
3. A failed extent write or fsync advances neither checkpoint nor recyclable
|
||||
tail. Partial extent writes remain safe because recovery replays the
|
||||
retained WAL.
|
||||
4. A concurrent newer write to the same LBA remains visible and dirty.
|
||||
Compare-and-delete may remove only the exact flushed LSN.
|
||||
5. A WAL-slot/header mismatch fails the flush cycle closed. It removes no dirty
|
||||
entry and advances no checkpoint unless durable checkpoint evidence proves
|
||||
that exact entry is already obsolete.
|
||||
6. Contiguous coalescing never crosses an LBA gap, block-size boundary,
|
||||
configured maximum write size, or extent-region boundary.
|
||||
7. Circular WAL wrap, padding, stale-slot detection, trim, ordinary records,
|
||||
and multi-block record data offsets retain current behavior.
|
||||
8. Foreground append and background extent writes may overlap only in disjoint
|
||||
file regions. Flusher writeback and direct rebuild BASE installation need
|
||||
an explicit extent ownership rule so a coalesced range cannot overwrite a
|
||||
newer BASE block.
|
||||
9. Recovery-retention and active rebuild pin floors continue to clamp
|
||||
checkpoint/tail advancement exactly as today.
|
||||
10. Sync retains its current target-head and fsync semantics. Checkpoint
|
||||
optimization may not claim a higher durable frontier or hide a failed
|
||||
flusher cycle.
|
||||
11. Close rejects new writes, performs one final best-effort complete flush
|
||||
while the file remains usable, and never closes the file while writeback
|
||||
is active.
|
||||
12. Instrumentation distinguishes WAL append, WAL readback, extent writeback,
|
||||
fsync, checkpoint metadata, and cleanup work. Counters cannot turn a
|
||||
partial cycle into a successful cycle.
|
||||
13. A rejected candidate leaves default flusher behavior and all external
|
||||
contracts unchanged.
|
||||
|
||||
## Deliverables
|
||||
|
||||
### D1. Product-Path Baseline And Headroom Decision
|
||||
### D1. Correctness Hardening And Full-Pipeline Baseline
|
||||
|
||||
- Extend the existing `BenchmarkPhase167WALStoreContention` evidence rather
|
||||
than creating a synthetic backend.
|
||||
- Run 4 KiB ordinary Write with 1/2/4/8 writers, explicit final Sync, and a
|
||||
timed final flusher drain that must settle checkpoint to head.
|
||||
- Run the existing explicit `WriteBatch` control to show whether fewer
|
||||
`WriteAt` calls have measurable value on the same machine.
|
||||
- Report median/range, p50/p95/p99, allocations, CPU profile, syscall counts,
|
||||
flusher/checkpoint activity, all write-instrumentation stages, and exact
|
||||
Sync cadence.
|
||||
- Separate cumulative CPU work from wall-clock lock wait; do not sum
|
||||
overlapping concurrent durations into a false percentage.
|
||||
- Admit D2 only if five-run range and paired-sample checks are stable and
|
||||
either record encode/copy/checksum/lock work has material parallel headroom
|
||||
or the existing-format batch control proves material syscall/coalescing
|
||||
headroom. A concurrency deficit is important diagnostic evidence, not a
|
||||
mandatory stop when absolute coalescing headroom is already material.
|
||||
- Stop if the profile instead shows an already saturated device or no
|
||||
existing-format batch advantage.
|
||||
- Add failure injection around checkpoint metadata write/fsync. Prove failure
|
||||
advances neither in-memory checkpoint nor WAL tail, retry succeeds, and
|
||||
crash/reopen uses only a durably published checkpoint.
|
||||
- Require a checkpoint metadata fsync before any corresponding WAL-tail reuse.
|
||||
- Repair or explicitly replace the current Close sequencing so the promised
|
||||
final flush can run after new writes are fenced but before file close. Prove
|
||||
dirty close/reopen and final-flush failure behavior.
|
||||
- Define and test flusher-versus-direct-BASE extent ownership. A direct block
|
||||
and a coalesced range that overlap must resolve according to the rebuild
|
||||
bitmap/frontier contract rather than goroutine timing.
|
||||
- Make an unexplained WAL-slot/header mismatch fail the cycle closed with no
|
||||
dirty deletion, checkpoint advance, or tail reuse. Only explicit durable
|
||||
checkpoint evidence may classify an entry as safely obsolete.
|
||||
|
||||
### D2. Bounded Existing-Format Commit Owner
|
||||
- Add product-owned counters for snapshot entries, validated/stale entries,
|
||||
WAL header/data read operations and bytes, extent write operations and
|
||||
bytes, maximum extent write size, fsync time/count, checkpoint metadata
|
||||
operations, successful/failed cycles, and cycle latency.
|
||||
- Extend the Phase 170 ordinary-Write benchmark rather than creating a
|
||||
synthetic storage backend.
|
||||
- Run 4 KiB ordinary Write and explicit 16-block WriteBatch with 1/2/4/8
|
||||
writers, normal 100 ms flusher cadence, explicit final Sync, and complete
|
||||
final drain.
|
||||
- Report five-run median/range, p50/p95/p99, allocations, foreground stage
|
||||
metrics, flusher metrics, CPU, selected syscalls, checkpoint coverage, and
|
||||
exact Sync cadence.
|
||||
- Report foreground Write duration, final Sync duration, and final drain
|
||||
duration separately. Throughput admission uses the foreground interval,
|
||||
while drain improvement remains a separately named operational result.
|
||||
- Report contiguous-run count/distribution and the theoretical minimum bounded
|
||||
extent-write operations for both sequential and randomized-LBA workloads.
|
||||
D2 is not admitted when realistic snapshots have no material coalescing
|
||||
opportunity.
|
||||
- Verify counters against deterministic small fixtures and external
|
||||
`strace` where available. Product counters are authoritative for scoped
|
||||
work; whole-process `strace` remains qualitative unless a dedicated test
|
||||
binary isolates the operation.
|
||||
|
||||
- Add one internal, disabled-by-default candidate mode for tests and
|
||||
benchmarks; do not add a CLI/product selector yet.
|
||||
- Reserve request and payload capacity before copying caller bytes.
|
||||
- Use a fixed queue and explicit maximum entries/bytes per append batch.
|
||||
- Form batches only from requests already admitted when the owner drains the
|
||||
queue; no batching timer.
|
||||
- Assign a tentative contiguous LSN range, call `walWriter.appendBatch`, and
|
||||
publish offsets/dirty-map/frontier only on complete success.
|
||||
- Prove one writer, concurrent writers, same-LBA order, wrap, queue-full,
|
||||
admission failure, partial physical write failure, Close, and bounded memory.
|
||||
- Run an early same-run performance gate. Remove the owner immediately if it
|
||||
neither reduces WriteAt calls nor preserves one-writer cost.
|
||||
### D2. Bounded Contiguous Extent Writeback
|
||||
|
||||
### D3. Sync, Failure, And Read Visibility
|
||||
- Add one internal, disabled-by-default comparison mode before changing the
|
||||
shipped default.
|
||||
- Sort the existing complete dirty snapshot by LBA without changing which
|
||||
entries are included.
|
||||
- Materialize and write contiguous destination LBAs in bounded chunks of at
|
||||
most 1 MiB.
|
||||
- Keep only one bounded data chunk live at a time; do not build an additional
|
||||
volume-sized data map.
|
||||
- Preserve fail-closed stale-slot handling, trim zeroing, multi-block
|
||||
`dataOffset`, max-LSN tracking, extent-fsync then
|
||||
checkpoint-write/fsync ordering, WAL-tail advancement, and
|
||||
compare-and-delete behavior.
|
||||
- Prove contiguous, gapped, reverse snapshot order, overwrite, trim,
|
||||
multi-block, wrap, maximum chunk, final partial chunk, and empty-cycle
|
||||
behavior.
|
||||
- Inject first/middle/final extent-write failure and fsync failure. Each must
|
||||
retain recovery through the unchanged WAL and publish no false checkpoint.
|
||||
|
||||
- Add an admission/publication fence so Sync covers exactly requests admitted
|
||||
before its call.
|
||||
- Preserve the current logical-Sync semantics and group-committer behavior.
|
||||
- Prove that a failed lower batch cannot allow a higher LSN to become visible
|
||||
or durable.
|
||||
- Prove read-after-Write, concurrent same-LBA overwrite, Write/Sync races,
|
||||
Sync/Close races, and no orphaned waiters.
|
||||
- Inject encode, WAL-full, wrap-padding, short-write, `WriteAt`, fsync, and
|
||||
superblock metadata failures.
|
||||
- Keep status/instrumentation truthful for queued, batched, failed, and
|
||||
completed operations.
|
||||
### D3. Concurrency, Scheduling, And Optional WAL Readback Decision
|
||||
|
||||
### D4. Flusher, Recovery, Retention, And Replication Equivalence
|
||||
- Exercise foreground Write/WriteBatch while a large flush cycle is active,
|
||||
including repeated same-LBA overwrite and WAL pressure wakeups.
|
||||
- Exercise direct BASE installation against overlapping and adjacent flusher
|
||||
ranges; no result may depend on physical write completion order.
|
||||
- Prove admission, flusher, Sync, retention pin, and Close cannot deadlock.
|
||||
- Measure flusher-cycle occupancy, foreground p99, extent operations per block,
|
||||
and WAL read operations per block after D2.
|
||||
- If WAL readback is then a material limiter, add one separately gated bounded
|
||||
read-materialization change that retains per-record LSN/type/length checks
|
||||
and handles ring wrap. Otherwise record the no-change decision.
|
||||
- Do not combine fsync scheduling or group-committer redesign into this
|
||||
deliverable unless a dedicated trace proves duplicate/concurrent fsync is
|
||||
the remaining dominant cost.
|
||||
|
||||
- Run the existing WAL recovery and corruption suites against candidate-created
|
||||
files; no new recovery branch is allowed.
|
||||
- Exercise background flush during active admission and while Sync fences a
|
||||
target.
|
||||
- Prove dirty-map offsets for batched records, circular wrap, checkpoint
|
||||
advancement, WAL admission pressure, recycle-floor pins, and restart.
|
||||
### D4. Recovery, Retention, Rebuild, And Replication Equivalence
|
||||
|
||||
- Run existing WAL recovery, corruption, typed-failure, flusher, retention,
|
||||
recycle-pin, direct-frontier, and close/reopen suites against
|
||||
candidate-created files.
|
||||
- Add crash windows after extent fsync, after checkpoint pwrite, after
|
||||
checkpoint fsync, and before/after WAL-tail publication.
|
||||
- Prove `ScanLBAs`, catch-up, direct BASE install, `AdvanceFrontier`, and
|
||||
rebuild use the unchanged current contracts.
|
||||
- Run logical replication/RF3 component tests without changing the wire
|
||||
protocol.
|
||||
returned-replica rebuild retain their current contracts.
|
||||
- Exercise checkpoint advancement under an active recycle-floor pin and after
|
||||
pin release.
|
||||
- Run storage race coverage and RF1/RF3 logical replication component tests.
|
||||
- No new recovery or replication branch is allowed.
|
||||
|
||||
### D5. Comparable Linux Performance Decision
|
||||
|
||||
- Compare candidate and unchanged synchronous `walstore` in one rotated m02
|
||||
session with five one-second repetitions.
|
||||
- Include ordinary 4 KiB Write at 1/2/4/8 writers and explicit 16-block
|
||||
WriteBatch controls.
|
||||
- Report median/range, p50/p95/p99, allocations, CPU, selected syscalls,
|
||||
WriteAt calls/bytes, entries per append batch, queue high-water/rejections,
|
||||
flusher/checkpoint work, and exact Sync cadence.
|
||||
- Admit only if:
|
||||
- one-writer throughput is at least 90% of baseline;
|
||||
- four-writer throughput is at least 1.5x baseline four-writer throughput;
|
||||
- candidate four-writer throughput is at least 1.3x candidate one-writer
|
||||
throughput, unless both paths are shown to hit the same measured device
|
||||
ceiling;
|
||||
- ordinary writes average more than one entry per append batch and reduce
|
||||
`WriteAt` calls per entry;
|
||||
- p99 and five-run range remain bounded;
|
||||
- queue-full, fallback, partial-write, durability, and recovery counters are
|
||||
clean.
|
||||
- Compare candidate and unchanged default flusher in one rotated m02 session
|
||||
with five one-second repetitions.
|
||||
- Include ordinary 4 KiB Write and explicit 16-block WriteBatch at 1/2/4/8
|
||||
writers with identical flusher, Sync, file, and checkpoint settings.
|
||||
- Report median/range, p50/p95/p99, allocations, CPU, scoped/selected syscalls,
|
||||
append and flusher stage metrics, extent operations per block, checkpoint
|
||||
coverage, pressure waits, and failed-cycle counters. Foreground, final Sync,
|
||||
and final drain durations must remain separate.
|
||||
- Admit the candidate only if:
|
||||
- one-writer ordinary throughput is at least 95% of baseline;
|
||||
- four-writer ordinary throughput improves by at least 1.25x;
|
||||
- candidate four-writer median is not below candidate one-writer median
|
||||
unless measured device saturation explains the ceiling;
|
||||
- extent `WriteAt` operations per contiguous block fall materially and match
|
||||
deterministic counter/trace evidence;
|
||||
- ordinary four-writer range is at most `1.50x` and improves materially from
|
||||
the Phase 170 `2.936x` baseline;
|
||||
- p99, WAL pressure, failed cycles, checkpoint coverage, and cleanup remain
|
||||
bounded and correct.
|
||||
|
||||
### D6. Mounted RF1 And RF3 Close Gate
|
||||
|
||||
- Run only if D5 admits the candidate.
|
||||
- Build matching product and CSI images from the exact candidate commit.
|
||||
- Run mounted NVMe/TCP RF1 concurrent Write/Flush/Read/checksum and durable
|
||||
restart recovery.
|
||||
- Run mounted NVMe/TCP RF1 concurrent Write/Flush/Read/checksum, durable
|
||||
restart, and sustained writeback pressure.
|
||||
- Run RF3 sync-quorum with a delayed non-quorum peer, catch-up/rebuild,
|
||||
restart, status honesty, and continued mounted I/O.
|
||||
restart, honest status, and continued mounted I/O.
|
||||
- Compare baseline and candidate in the same lab session.
|
||||
- Finish with product-owned cleanup verification and zero Kubernetes, NVMe,
|
||||
iSCSI, process, and durable-path residue.
|
||||
- Add a product setting or change the default only after this gate passes.
|
||||
- Change the default flusher only after this gate passes.
|
||||
|
||||
## Stop Rules
|
||||
|
||||
Stop and remove the staged owner if:
|
||||
Stop and remove the candidate if:
|
||||
|
||||
- D1 cannot identify a measured parallelizable or coalescible cost;
|
||||
- owner batching again serializes four writers below the synchronous baseline;
|
||||
- batching requires an arbitrary latency delay;
|
||||
- LSN assignment, dirty-map publication, or Sync needs ambiguous rollback;
|
||||
- WAL pressure can deadlock because the owner waits for the flusher while the
|
||||
flusher waits for owner-held state;
|
||||
- performance depends on disabling normal flusher/checkpoint/recovery work;
|
||||
- only explicit WriteBatch improves while ordinary Write remains unscaled.
|
||||
- D1 does not show meaningful extent-write or WAL-read amplification;
|
||||
- D1 realistic snapshots have too few contiguous runs for bounded coalescing
|
||||
to reduce extent operations materially;
|
||||
- operation reduction does not improve ordinary Write throughput or stability;
|
||||
- coalescing requires omitting dirty entries or advancing checkpoint over
|
||||
incomplete work;
|
||||
- bounded writeback cannot retain trim, multi-block, wrap, stale-slot, and
|
||||
overwrite semantics;
|
||||
- a WAL-slot mismatch can delete dirty state or permit checkpoint progress
|
||||
without durable obsolescence evidence;
|
||||
- pressure, Sync, Close, or recycle pins can deadlock with the flusher;
|
||||
- a failed partial cycle can become a visible checkpoint;
|
||||
- checkpoint metadata is not durable before the corresponding WAL bytes become
|
||||
reusable;
|
||||
- Close cannot fence new writes while still completing its promised final
|
||||
flush;
|
||||
- direct BASE and flusher overlap has no deterministic ownership rule;
|
||||
- performance depends on disabling normal flush, fsync, checkpoint, recovery,
|
||||
or retention work;
|
||||
- only explicit WriteBatch improves while ordinary Write remains unstable.
|
||||
|
||||
An honest rejection is a valid Phase 170 outcome. It must leave the default
|
||||
`walstore`, on-disk format, and all operation/frontend contracts intact.
|
||||
An honest rejection is a valid Phase 171 outcome. It must leave the current
|
||||
disk format, default flusher, and all frontend/replication/operation contracts
|
||||
intact.
|
||||
|
||||
## Exit Criteria
|
||||
|
||||
```text
|
||||
default-product baseline and headroom proof
|
||||
-> bounded existing-format staged owner
|
||||
-> exact LSN/visibility/Sync/failure semantics
|
||||
-> unchanged flusher/recovery/retention/rebuild contracts
|
||||
checkpoint/Close/BASE correctness hardening plus full-pipeline evidence
|
||||
-> bounded contiguous extent writeback
|
||||
-> concurrency and optional WAL-read decision
|
||||
-> unchanged recovery/retention/rebuild/replication semantics
|
||||
-> same-run Linux performance decision
|
||||
-> mounted RF1/RF3 only if admitted
|
||||
-> promote or remove
|
||||
```
|
||||
|
||||
The milestone succeeds through an evidence-backed product-path decision, not
|
||||
through another backend name.
|
||||
The milestone succeeds by proving or disproving a complete shipped-path
|
||||
improvement, not by reducing one counter in isolation.
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
# Finished Plan: Phase 170 Default WALStore Staged Commit Pipeline
|
||||
|
||||
Status: complete as an evidence-backed pre-implementation rejection. D1
|
||||
validated the benchmark mechanism and denied admission to D2. No staged owner
|
||||
or product selector was added; D2-D6 were intentionally skipped.
|
||||
|
||||
## Final Outcome
|
||||
|
||||
Phase 170 tested whether the shipped `walstore` could gain concurrent ordinary
|
||||
Write throughput by routing several existing-format records through the
|
||||
already implemented `walWriter.appendBatch` seam.
|
||||
|
||||
The exact m02 gate used the normal background flusher, five rotated one-second
|
||||
samples, 1/2/4/8 writers, one explicit final Sync per sample, and an untimed
|
||||
final flusher drain that had to settle checkpoint to head:
|
||||
|
||||
```text
|
||||
ordinary writers=1 87.97 MiB/s
|
||||
ordinary writers=4 64.09 MiB/s
|
||||
ordinary writers=8 50.12 MiB/s
|
||||
explicit batch writers=1 137.48 MiB/s
|
||||
explicit batch writers=4 47.22 MiB/s
|
||||
explicit batch writers=8 50.51 MiB/s
|
||||
ordinary four/single 0.729x
|
||||
batch four/ordinary four 0.737x
|
||||
ordinary WriteAt calls/entry 1.000
|
||||
batch WriteAt calls/entry 0.06250
|
||||
paired batch gains 2/5
|
||||
ordinary four-writer range 2.936x
|
||||
batch four-writer range 3.500x
|
||||
```
|
||||
|
||||
The batch primitive did exactly what its implementation promises: it preserved
|
||||
independent current-format records while reducing adjacent WAL writes to about
|
||||
one positioned write per 16 entries. That syscall reduction did not produce a
|
||||
stable four-writer gain. Four-writer batch throughput was lower than ordinary
|
||||
Write, only two paired runs improved, and both paths had unacceptable run
|
||||
range.
|
||||
|
||||
## What Was Proved
|
||||
|
||||
- The default product path can be measured with normal flusher/checkpoint work
|
||||
included rather than with a non-sustainable disabled-flusher control.
|
||||
- Benchmark timing and accounting distinguish API-call latency/allocation
|
||||
metrics from per-record encode/copy/checksum metrics.
|
||||
- Every accepted sample performs one explicit Sync and finishes with no dirty
|
||||
entries and complete checkpoint coverage.
|
||||
- Existing-format `appendBatch` reliably reduces WAL `WriteAt` calls.
|
||||
- The current ordinary path has a concurrency deficit: four-writer throughput
|
||||
is `0.729x` one writer and commit-lock wait rises from about `87 ns` to
|
||||
`29 us` per API call.
|
||||
- Coalescing only the append syscall is not a sufficient answer under the
|
||||
complete WAL-to-extent workload.
|
||||
|
||||
The exact evidence is recorded in
|
||||
`internal/docs/qa-assignments/phase170-d1-walstore-headroom-qa-signoff.md`.
|
||||
|
||||
## Why D2-D6 Were Skipped
|
||||
|
||||
The proposed owner would have added queueing, owned payload copies, LSN-range
|
||||
assignment, Sync fencing, terminal drain, and new failure coordination around
|
||||
a primitive whose concurrent advantage was not reproducible. It would also
|
||||
have had to avoid a pressure deadlock between WAL admission and the flusher's
|
||||
checkpoint lock.
|
||||
|
||||
Implementing those semantics after the D1 denial would repeat the pattern from
|
||||
Phases 168 and 169: substantial correctness machinery around a performance
|
||||
hypothesis that already failed its cheapest valid control. The stop rule is
|
||||
the engineering result, not an incomplete implementation.
|
||||
|
||||
## Surviving Product State
|
||||
|
||||
- `walstore` remains the default backend and its synchronous Write path is
|
||||
unchanged.
|
||||
- Phase 167 `parallel-walstore` remains explicit and opt-in.
|
||||
- No staged owner, queue, new disk format, selector, or recovery branch was
|
||||
added.
|
||||
- The Phase 170 benchmark and instrumentation remain as reusable evidence for
|
||||
later default-path work.
|
||||
- Existing frontend, replication, recovery, and Operation Layer contracts are
|
||||
unchanged.
|
||||
|
||||
## Next Direction
|
||||
|
||||
The gate's large run-to-run range and syscall-heavy profile point below the
|
||||
append batching seam. The default flusher currently reads WAL records
|
||||
individually, writes each dirty extent block separately, and competes with
|
||||
foreground append and fsync on the same file. Phase 171 will measure that
|
||||
writeback amplification directly, then may port the bounded contiguous
|
||||
checkpoint-write mechanism already proven in Phase 167 into the shipped
|
||||
`walstore` flusher.
|
||||
|
||||
That work optimizes the full persistent pipeline rather than adding another
|
||||
append owner.
|
||||
@@ -128,11 +128,12 @@ This is the short internal roadmap. Keep it current and readable.
|
||||
Kubernetes initiator, so it cannot honestly prove two remote surviving
|
||||
paths. The implementation and blocked gate remain tracked independently.
|
||||
- Phase 167 closed as an opt-in Parallel Write Engine research result. Phase
|
||||
168 then rejected native `io_uring` execution, and Phase 169 rejected a
|
||||
segmented group-commit format after its four-writer optimistic upper bound
|
||||
failed both scaling and positioned-control thresholds. Phase 170 works on
|
||||
the default `walstore` pipeline and existing-format `appendBatch` seam rather
|
||||
than adding another backend.
|
||||
168 then rejected native `io_uring` execution, Phase 169 rejected a
|
||||
segmented group-commit format, and Phase 170 rejected a default-WAL staged
|
||||
append owner before implementation because existing-format batching reduced
|
||||
WAL writes but did not produce stable concurrent throughput. Phase 171 now
|
||||
measures and optimizes the shipped `walstore` checkpoint/writeback half
|
||||
rather than adding another backend or append queue.
|
||||
|
||||
Do not skip from scripts directly to mutating operator lifecycle. Helm has
|
||||
stabilized the installation contract, and Phase 35 added read-only CRD status,
|
||||
@@ -595,10 +596,16 @@ rebuild, delete safety, or cleanup must start as a separate gated phase.
|
||||
optimistic upper bound grouped `1.348` entries/segment but four writers
|
||||
reached only `0.772x` one writer and `0.990x` the positioned control. The
|
||||
implementation was removed before checkpoint/rebuild integration.
|
||||
- Active next: Phase 170 profiles and stages the default `walstore` write
|
||||
pipeline. It may use the existing-format `walWriter.appendBatch` seam only
|
||||
if measured CRC/copy/global-lock headroom justifies a bounded owner. Direct
|
||||
I/O, fixed buffers, FUA, and device atomic writes remain later
|
||||
- Closed experiment: Phase 170's default-WAL headroom gate proved that explicit
|
||||
16-record batching reduced WAL `WriteAt` calls from `1.0` to `0.0625` per
|
||||
entry, but four-writer throughput was only `0.737x` ordinary Write, paired
|
||||
gain passed only `2/5` samples, and run ranges exceeded `2.9x`. The staged
|
||||
owner was stopped before implementation.
|
||||
- Active next: Phase 171 instruments and optimizes the default `walstore`
|
||||
checkpoint/writeback path. It may port bounded contiguous extent writes from
|
||||
the Phase 167 research backend only if full-pipeline evidence shows
|
||||
writeback amplification and the complete flusher/recovery contract remains
|
||||
intact. Direct I/O, fixed buffers, FUA, and device atomic writes remain later
|
||||
evidence-gated decisions.
|
||||
- Protocol hardening now has a dedicated working area under
|
||||
`internal/docs/protocol/`. New protocol semantics should update the control
|
||||
@@ -1237,9 +1244,15 @@ Approximate engineering effort if scope remains tight:
|
||||
the candidate paid full checkpoint/rebuild costs. The implementation was
|
||||
removed. The finished plan is
|
||||
`internal/docs/finished-plans/phase169_finishedplan_segmented_wal_group_commit.md`.
|
||||
- Phase 170 Default WALStore Staged Commit Pipeline is active. It starts from
|
||||
the shipped backend and existing WAL format, with an evidence gate before
|
||||
any queue/owner integration. The contract is `internal/docs/current-plan.md`.
|
||||
- Phase 170 Default WALStore Staged Commit Pipeline is closed as a
|
||||
pre-implementation rejection. Existing-format batching reduced WAL
|
||||
`WriteAt` calls by about 16x but did not provide stable four-writer
|
||||
throughput headroom, so no owner or selector was added. The finished plan is
|
||||
`internal/docs/finished-plans/phase170_finishedplan_default_walstore_staged_commit.md`.
|
||||
- Phase 171 Default WALStore Checkpoint Pipeline is active. It starts by
|
||||
measuring foreground/background I/O separately, then may add bounded
|
||||
contiguous extent writeback to the shipped flusher before any mounted or RF3
|
||||
claim. The contract is `internal/docs/current-plan.md`.
|
||||
- Phase 41-44 are the Operation Layer v0.5 release train: lifecycle-owner
|
||||
foundation, real API/admission proof, first bounded finalizer mutation, and
|
||||
delete lifecycle close gate.
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
# Phase 170 D1 WALStore Headroom QA Sign-Off
|
||||
|
||||
Verdict: evidence mechanism PASS and staged commit owner STOP at exact commit
|
||||
`b9e4fda6599b7c81cbf1800a89f3e9189e7cc034`.
|
||||
|
||||
## Environment
|
||||
|
||||
```text
|
||||
environment=m02
|
||||
go_version=go1.25.0 linux/amd64
|
||||
source_archive_sha256=d4dd771b46de572cde944c41f77808b0edd2818c33b156cc28374eefde216144
|
||||
qa_archive_sha256=ef8469ada1daa552fedb1a4d23d5c3763ebb59d258eee2c1becd8537ea38bbd9
|
||||
benchmark_time=1s
|
||||
repetitions=5
|
||||
writers=1,2,4,8
|
||||
```
|
||||
|
||||
The gate ran 40 benchmark rows with the normal background flusher enabled.
|
||||
Every row completed one explicit final Sync, drained the flusher after timing,
|
||||
reported `dirty_entries=0`, and reached
|
||||
`checkpoint_lsn=head_lsn`. The storage regression suite passed.
|
||||
|
||||
## Decision Evidence
|
||||
|
||||
```text
|
||||
ordinary_writers_1_mibps_median=87.97
|
||||
ordinary_writers_4_mibps_median=64.09
|
||||
ordinary_writers_8_mibps_median=50.12
|
||||
batch_writers_1_mibps_median=137.48
|
||||
batch_writers_4_mibps_median=47.22
|
||||
batch_writers_8_mibps_median=50.51
|
||||
ordinary_four_writer_scaling_ratio=0.729
|
||||
batch_four_vs_ordinary_four_ratio=0.737
|
||||
ordinary_writers_4_range_ratio=2.936
|
||||
batch_writers_4_range_ratio=3.500
|
||||
paired_batch_gain_pass_count=2
|
||||
paired_batch_gain_stable=false
|
||||
ordinary_writers_4_writeat_calls_per_entry_median=1.000
|
||||
batch_writers_4_writeat_calls_per_entry_median=0.06250
|
||||
writeat_shape_stable=true
|
||||
batch_throughput_headroom=false
|
||||
existing_format_headroom=false
|
||||
d2_owner_admitted=false
|
||||
next_recommendation=stop_before_staged_owner
|
||||
phase170_walstore_headroom_status=ok
|
||||
```
|
||||
|
||||
The explicit batch control reduced WAL `WriteAt` calls by about 16x, but that
|
||||
mechanical coalescing did not produce stable concurrent throughput headroom.
|
||||
The four-writer batch median was below ordinary Write, only two of five paired
|
||||
samples passed the gain threshold, and both four-writer ranges exceeded the
|
||||
`1.35x` stability limit.
|
||||
|
||||
The ordinary path also exposed the current contention shape:
|
||||
|
||||
```text
|
||||
ordinary_writers_1_commit_lock_wait_ns_per_api_call_median=86.68
|
||||
ordinary_writers_4_commit_lock_wait_ns_per_api_call_median=29264
|
||||
ordinary_writers_4_p99_ns_per_api_call_median=2211028
|
||||
cpu_top_flat_syscall6_percent=39.22
|
||||
qualitative_strace_pwrite64_calls=30948
|
||||
qualitative_strace_fsync_calls=18
|
||||
```
|
||||
|
||||
This is evidence of contention and writeback amplification, but not evidence
|
||||
that another append owner will fix it. The Phase 170 stop rule therefore
|
||||
applies before D2 implementation.
|
||||
|
||||
## Artifacts
|
||||
|
||||
- Run root:
|
||||
`C:\work\qa-phase170-d1-b9e4fda-20260730-010058`
|
||||
- Summary:
|
||||
`artifacts/source/results/phase170-walstore-headroom-gate/phase170-walstore-headroom-summary.txt`
|
||||
- QA archive:
|
||||
`C:\work\qa-phase170-d1-b9e4fda-20260730-010058\qa-artifacts.tar.gz`
|
||||
|
||||
QA removed the scoped remote directory, found no residual process, and left
|
||||
all three Kubernetes nodes Ready. The shared development worktree was not
|
||||
modified.
|
||||
Reference in new issue
Block a user