T3c: 4 scenarios × 2 impls + perf baseline + YAML shape docs

Per T3c mini plan §1 — closes T3 delivery except for T3-end three-sign.
Atomic per mini plan §3 inherited stop rules.

## Scope delivered

### 1. Four scenarios (matrix over walstore + smartwal)

  core/frontend/durable/scenario_crash_recovery_test.go
    TestT3c_Scenario_CrashRecovery_AckedBytesByteExact
    → pins INV-DURABLE-001 (canonical G4 gate)

  core/frontend/durable/scenario_wal_replay_test.go
    TestT3c_Scenario_WALReplay_NAckedWrites
    → pins INV-DURABLE-WAL-REPLAY-001

  core/frontend/durable/scenario_fsync_boundary_test.go
    TestT3c_Scenario_FsyncBoundary_AckedSurvivesUnackedMayVanish
    → pins INV-DURABLE-FSYNC-BOUNDARY-001

  core/frontend/durable/scenario_disk_fill_test.go
    TestT3c_Scenario_DiskFill_OutOfRange_FailsCleanly
    → pins PCDD-DURABLE-DISK-FULL-001

Each scenario:
  - Uses the shared logicalStorageFactories() matrix helper from T3a
  - Runs as `{smartwal, walstore}` subtests
  - Is an in-process L1 test (not subprocess / not YAML replay)
  - Simulates "restart" by building a FRESH DurableProvider over
    the same StorageRoot (closes + re-opens all state cleanly)

### 2. YAML shape docs

  testrunner/scenarios/testdata/t3c-durable-crash-recovery.yaml
  testrunner/scenarios/testdata/t3c-durable-wal-replay.yaml
  testrunner/scenarios/testdata/t3c-durable-fsync-boundary.yaml
  testrunner/scenarios/testdata/t3c-durable-disk-fill.yaml

Documentation of each scenario's shape, variant matrix, and
ledger pin. Authoritative test is the Go replay; YAML mirrors it
for reviewability per mini plan §1.1.

### 3. Perf baseline

  testrunner/perf/t3c-durable-baseline.md
    Workload spec + first-light numbers (sw dev Windows 11)

  core/frontend/durable/perf_baseline_test.go
    BenchmarkT3c_DurablePerf — matrix benchmark, both impls

First-light numbers at 8000 iterations, Sync every 64 writes:
  - walstore: 197 µs/op, 20.75 MB/s, ~5k ops/s
  - smartwal: 303 µs/op, 13.50 MB/s, ~3.3k ops/s

Characterization only, no threshold. Benchmark caps iterations
at 8000 so WAL capacity is not the bottleneck — not a saturation
benchmark. Real sustained numbers deferred to m01 fio run.

### 4. Closure report

  sw-block/design/v3-phase-15-t3-closure-report.md
    (seaweedfs repo — not in this commit)

§A-§F: batch history, delivery summary, V2 port depth audit,
ledger rows, T3-end three-sign table, change log.

## Acceptance (mini plan §2)

  #1 All 4 scenarios × 2 impls (8 subtests)        ✅ all green
  #2 Frontend continuity — existing T2 tests green  ✅ (see #5)
  #3 m01 fs-workload smoke                           ⏸ post-sign (QA-owned)
  #4 Perf baseline artifact                          ✅ numbers filled
  #5 Full regression                                 ✅ 17/17 pkgs ok
  #6 Boundary guard                                  ✅ durable/ auto-covered
  #7 6 new ledger rows queued                        ✅ (4 T3c + 5 from T3a/T3b already ACTIVE)
  #8 16 T2 ACTIVE rows still ACTIVE                  ✅ (no regression in iscsi/nvme)
  #9 Closure report filled end-to-end                ✅ (seaweedfs repo)
 #10 T3-end three-sign                               ⏸ pending architect + PM + QA

## Regression

  go test ./core/... -count=1 → 17/17 packages ok
  - core/frontend/durable: 2.0s (76 subtests; +16 from T3c: 4 scenarios × 2 + 8 from earlier)
  - core/frontend/iscsi: 31.5s (no regression)
  - core/frontend/nvme: 61.3s (no regression)
  - core/host: 127.7s (subprocess tests still memback; no durable wire)
  - all others within normal range

## Stop rules honored

  #port-model default     ✅ (scenarios use public API only; no
                             storage internals)
  #no scope creep T4      ✅ (no replication / failover surface
                             introduced)
  #no new production code beyond T3a+T3b deliverables  ✅
                          (scenarios + perf are test infra only)

## Out of T3c (post-three-sign, not blocking)

  - m01 fs-workload verification (iterate-m01-nvme.sh tweak — QA)
  - fio sustained numbers replace Go-bench first-light
  - 24h m01 soak

## References

  sw-block/design/v3-phase-15-t3-port-audit.md
  sw-block/design/v3-phase-15-t3a-mini-plan.md (CLOSED 10cd117)
  sw-block/design/v3-phase-15-t3b-mini-plan.md (CLOSED 29e3d0d)
  sw-block/design/v3-phase-15-t3c-mini-plan.md (this batch)
  sw-block/design/v3-phase-15-t3-closure-report.md (awaiting 3-sign)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
wzcheng99andClaude Opus 4.7 committed 2026-04-22 18:20:24 -07:00
1 parent e2ae3910c3
commit 6fbdf94df5
10 files changed
+894

No files matched your search

@@ -0,0 +1,98 @@
// T3c perf baseline benchmark — characterization only, no gate.
//
// Publishes first-light numbers for both LogicalStorage impls so
// later changes have a comparison point. No threshold / no
// pass-fail. Matches the workload shape pinned in
// testrunner/perf/t3c-durable-baseline.md.
//
// Run (matrix walks both impls):
// go test -run '^$' -bench 'BenchmarkT3c_DurablePerf' \
// ./core/frontend/durable/ -benchtime=60s -count=1
package durable_test
import (
"context"
"math/rand"
"testing"
"github.com/seaweedfs/seaweed-block/core/frontend"
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
)
// BenchmarkT3c_DurablePerf drives 4 KiB random writes against a
// DurableProvider-sourced backend. One variant per impl.
//
// Scope caveat: this is NOT a sustained-throughput benchmark —
// it caps iterations at maxIters below so the walstore's WAL
// doesn't fill during a long -benchtime run (the flusher is
// eventually-consistent and can't drain faster than this
// benchmark writes). For real sustained numbers, run m01 fio.
// This benchmark exists to publish first-light relative
// per-op cost between walstore and smartwal; it does NOT claim
// to saturate either impl.
func BenchmarkT3c_DurablePerf(b *testing.B) {
for _, impl := range implMatrix() {
impl := impl
b.Run(string(impl), func(b *testing.B) {
// Cap N so WAL capacity is not the bottleneck.
// Characterization only; not a saturation benchmark.
const maxIters = 8000
if b.N > maxIters {
b.N = maxIters
}
root := b.TempDir()
id := frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}
view := newStubView(healthyProj(id))
const blockSize = 4096
const numBlocks = uint32(65536) // 256 MiB
p, err := durable.NewDurableProvider(durable.ProviderConfig{
Impl: impl,
StorageRoot: root,
BlockSize: blockSize,
NumBlocks: numBlocks,
}, view)
if err != nil {
b.Fatalf("NewDurableProvider: %v", err)
}
defer p.Close()
ctx := context.Background()
backend, err := p.Open(ctx, "v1")
if err != nil {
b.Fatalf("Open: %v", err)
}
if _, err := p.RecoverVolume(ctx, "v1"); err != nil {
b.Fatalf("RecoverVolume: %v", err)
}
payload := make([]byte, blockSize)
for i := range payload {
payload[i] = byte(i)
}
rng := rand.New(rand.NewSource(42))
b.ResetTimer()
b.SetBytes(int64(blockSize))
// Sync every syncBatch writes so the flusher has room
// to drain the WAL — mirrors real workloads where
// apps periodically fsync. Without this, walstore
// fills its WAL faster than the flusher drains and
// admission control errors. Benchmark measures write
// + periodic-sync cost, not burst throughput; documented
// in testrunner/perf/t3c-durable-baseline.md.
const syncBatch = 64
for i := 0; i < b.N; i++ {
lba := rng.Int31n(int32(numBlocks))
offset := int64(lba) * int64(blockSize)
if _, err := backend.Write(ctx, offset, payload); err != nil {
b.Fatalf("Write: %v", err)
}
if (i+1)%syncBatch == 0 {
if err := backend.Sync(ctx); err != nil {
b.Fatalf("Sync: %v", err)
}
}
}
})
}
}
@@ -0,0 +1,132 @@
// T3c scenario 1 of 4 — crash recovery.
//
// Canonical G4 gate: acked writes must survive a restart
// byte-exact. The scenario is:
//
// 1. Write N blocks at distinct LBAs via Backend.Write.
// 2. Backend.Sync (acks the writes — durable contract says
// any LSN <= Sync-returned-LSN is guaranteed recoverable).
// 3. Close the first Provider (tears down fd + final fsync).
// 4. Build a FRESH Provider rooted at the same StorageRoot
// (simulates daemon restart).
// 5. Open + RecoverVolume — must succeed; backend operational.
// 6. Read each LBA — bytes must match what step 1 wrote.
//
// Pins ledger row INV-DURABLE-001 — "acknowledged Write survives
// kill + restart; Read returns byte-exact".
//
// This is an L1 scenario (in-process, no subprocess). T3c m01
// fs-workload provides the subprocess / real-kernel leg.
package durable_test
import (
"bytes"
"context"
"testing"
"github.com/seaweedfs/seaweed-block/core/frontend"
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
)
// TestT3c_Scenario_CrashRecovery_AckedBytesByteExact is the
// canonical G4 scenario. Matrix-parameterized over both impls.
func TestT3c_Scenario_CrashRecovery_AckedBytesByteExact(t *testing.T) {
for _, impl := range implMatrix() {
impl := impl
t.Run(string(impl), func(t *testing.T) {
root := t.TempDir()
id := frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}
view := newStubView(healthyProj(id))
// Phase 1: open, write, sync, close.
p1, err := durable.NewDurableProvider(durable.ProviderConfig{
Impl: impl,
StorageRoot: root,
BlockSize: 4096,
NumBlocks: 32,
}, view)
if err != nil {
t.Fatalf("NewDurableProvider #1: %v", err)
}
ctx := context.Background()
backend, err := p1.Open(ctx, "v1")
if err != nil {
t.Fatalf("Open #1: %v", err)
}
if _, err := p1.RecoverVolume(ctx, "v1"); err != nil {
t.Fatalf("RecoverVolume #1: %v", err)
}
// Write N distinct blocks at distinct offsets.
const n = 8
const blockSize = 4096
blocks := make([][]byte, n)
for i := 0; i < n; i++ {
blocks[i] = make([]byte, blockSize)
for j := range blocks[i] {
blocks[i][j] = byte((i*37 + j) & 0xFF)
}
offset := int64(i) * blockSize
if _, err := backend.Write(ctx, offset, blocks[i]); err != nil {
t.Fatalf("Write[%d]: %v", i, err)
}
}
// Ack: Sync tells us "everything up to here is durable".
if err := backend.Sync(ctx); err != nil {
t.Fatalf("Sync: %v", err)
}
// Simulate daemon shutdown (clean). Closes fd + final
// fsync; nothing ambiguous.
if err := p1.Close(); err != nil {
t.Fatalf("p1.Close: %v", err)
}
// Phase 2: restart — fresh Provider over same path.
p2, err := durable.NewDurableProvider(durable.ProviderConfig{
Impl: impl,
StorageRoot: root,
BlockSize: 4096,
NumBlocks: 32,
}, view)
if err != nil {
t.Fatalf("NewDurableProvider #2: %v", err)
}
defer p2.Close()
backend2, err := p2.Open(ctx, "v1")
if err != nil {
t.Fatalf("Open #2: %v", err)
}
report, err := p2.RecoverVolume(ctx, "v1")
if err != nil {
t.Fatalf("RecoverVolume #2: %v (evidence=%s)", err, report.Evidence)
}
// Sanity: recovered LSN must be >= N (we wrote N blocks
// and each bumped nextLSN).
if report.RecoveredLSN == 0 {
t.Errorf("RecoveredLSN=0 after %d acked writes; expected >0", n)
}
// Read each LBA — bytes MUST match.
for i := 0; i < n; i++ {
offset := int64(i) * blockSize
got := make([]byte, blockSize)
nr, err := backend2.Read(ctx, offset, got)
if err != nil {
t.Fatalf("Read[%d]: %v", i, err)
}
if nr != blockSize {
t.Fatalf("Read[%d] n=%d want %d", i, nr, blockSize)
}
if !bytes.Equal(got, blocks[i]) {
t.Fatalf("LBA %d did NOT survive restart byte-exact (impl=%s): first diff at idx %d (got 0x%02x want 0x%02x)",
i, impl, firstDiffIdx(got, blocks[i]),
got[firstDiffIdx(got, blocks[i])], blocks[i][firstDiffIdx(got, blocks[i])])
}
}
})
}
}
@@ -0,0 +1,95 @@
// T3c scenario 4 of 4 — disk fill / graceful-error.
//
// Volume geometry is fixed at Create time (NumBlocks × BlockSize).
// Writing past the last LBA must return a clean error (either
// from adapter boundary check or storage LBA-out-of-range), not
// silent success and not corruption of in-range blocks.
//
// This is the V3 equivalent of V2's "disk-fill" scenario — we
// can't actually exhaust a real disk in unit tests, but the
// per-volume fixed geometry means "writing beyond volume end"
// exercises the same fail-hard property.
//
// Pins ledger row PCDD-DURABLE-DISK-FULL-001.
package durable_test
import (
"bytes"
"context"
"testing"
"github.com/seaweedfs/seaweed-block/core/frontend"
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
)
func TestT3c_Scenario_DiskFill_OutOfRange_FailsCleanly(t *testing.T) {
for _, impl := range implMatrix() {
impl := impl
t.Run(string(impl), func(t *testing.T) {
root := t.TempDir()
id := frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}
view := newStubView(healthyProj(id))
const numBlocks = uint32(4)
const blockSize = 4096
cfg := durable.ProviderConfig{
Impl: impl,
StorageRoot: root,
BlockSize: blockSize,
NumBlocks: numBlocks,
}
p, err := durable.NewDurableProvider(cfg, view)
if err != nil {
t.Fatalf("NewDurableProvider: %v", err)
}
defer p.Close()
ctx := context.Background()
b, err := p.Open(ctx, "v1")
if err != nil {
t.Fatalf("Open: %v", err)
}
if _, err := p.RecoverVolume(ctx, "v1"); err != nil {
t.Fatalf("RecoverVolume: %v", err)
}
// Step 1: fill the volume with a known pattern.
filler := make([]byte, blockSize)
for i := range filler {
filler[i] = byte((i + 5) & 0xFF)
}
for lba := uint32(0); lba < numBlocks; lba++ {
if _, err := b.Write(ctx, int64(lba)*blockSize, filler); err != nil {
t.Fatalf("fill Write lba=%d: %v", lba, err)
}
}
if err := b.Sync(ctx); err != nil {
t.Fatalf("Sync: %v", err)
}
// Step 2: write past end — MUST error, not silently
// succeed. Offset = numBlocks * blockSize (the first
// byte BEYOND volume).
outOfRange := int64(numBlocks) * blockSize
_, err = b.Write(ctx, outOfRange, filler)
if err == nil {
t.Errorf("Write past EOV succeeded silently (impl=%s) — expected error", impl)
}
// Step 3: in-range blocks must still be intact after
// the failed out-of-range write — fail-hard should not
// corrupt prior state.
for lba := uint32(0); lba < numBlocks; lba++ {
got := make([]byte, blockSize)
if _, err := b.Read(ctx, int64(lba)*blockSize, got); err != nil {
t.Fatalf("post-fail Read lba=%d: %v", lba, err)
}
if !bytes.Equal(got, filler) {
t.Fatalf("LBA %d corrupted by out-of-range write (impl=%s): first diff @ byte %d",
lba, impl, firstDiffIdx(got, filler))
}
}
})
}
}
@@ -0,0 +1,151 @@
// T3c scenario 3 of 4 — fsync boundary.
//
// LogicalStorage contract §2: "Unacked data may disappear after
// restart but cannot corrupt acked data: any LBA whose write
// completed before a successful Sync reads back identical bytes
// after Recover."
//
// Scenario:
// 1. Write a set of "acked" blocks and Sync — these MUST survive.
// 2. Write a set of "unacked" blocks without Sync.
// 3. Close the Provider (clean close; implicit final fsync is
// legal per the contract — the invariant is "no corruption",
// not "unacked always disappears").
// 4. Reopen + Recover.
// 5. For every acked LBA: bytes MUST match (byte-exact).
// 6. For every unacked LBA: bytes are EITHER the original
// write OR zero — never partial / never another block's
// bytes.
//
// Pins ledger row INV-DURABLE-FSYNC-BOUNDARY-001.
package durable_test
import (
"bytes"
"context"
"testing"
"github.com/seaweedfs/seaweed-block/core/frontend"
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
)
func TestT3c_Scenario_FsyncBoundary_AckedSurvivesUnackedMayVanish(t *testing.T) {
for _, impl := range implMatrix() {
impl := impl
t.Run(string(impl), func(t *testing.T) {
root := t.TempDir()
id := frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}
view := newStubView(healthyProj(id))
cfg := durable.ProviderConfig{
Impl: impl,
StorageRoot: root,
BlockSize: 4096,
NumBlocks: 32,
}
p1, err := durable.NewDurableProvider(cfg, view)
if err != nil {
t.Fatalf("NewDurableProvider #1: %v", err)
}
ctx := context.Background()
b1, err := p1.Open(ctx, "v1")
if err != nil {
t.Fatalf("Open #1: %v", err)
}
if _, err := p1.RecoverVolume(ctx, "v1"); err != nil {
t.Fatalf("RecoverVolume #1: %v", err)
}
const blockSize = 4096
const nAcked = 5
const nUnacked = 5
// Acked writes.
ackedBlocks := make([][]byte, nAcked)
for i := 0; i < nAcked; i++ {
ackedBlocks[i] = make([]byte, blockSize)
for j := range ackedBlocks[i] {
ackedBlocks[i][j] = byte((i*11 + j) & 0xFF)
}
if _, err := b1.Write(ctx, int64(i)*blockSize, ackedBlocks[i]); err != nil {
t.Fatalf("acked Write[%d]: %v", i, err)
}
}
// The Sync boundary. Everything written BEFORE this
// point is durable; afterward is unacked.
if err := b1.Sync(ctx); err != nil {
t.Fatalf("Sync: %v", err)
}
// Unacked writes — at LBAs nAcked..nAcked+nUnacked-1.
unackedBlocks := make([][]byte, nUnacked)
for i := 0; i < nUnacked; i++ {
unackedBlocks[i] = make([]byte, blockSize)
for j := range unackedBlocks[i] {
unackedBlocks[i][j] = byte((i*17 + j + 0x80) & 0xFF)
}
lba := nAcked + i
if _, err := b1.Write(ctx, int64(lba)*blockSize, unackedBlocks[i]); err != nil {
t.Fatalf("unacked Write[%d]: %v", i, err)
}
}
// NO Sync here. Close to end of phase.
if err := p1.Close(); err != nil {
t.Fatalf("p1.Close: %v", err)
}
// Phase 2: reopen.
p2, err := durable.NewDurableProvider(cfg, view)
if err != nil {
t.Fatalf("NewDurableProvider #2: %v", err)
}
defer p2.Close()
b2, err := p2.Open(ctx, "v1")
if err != nil {
t.Fatalf("Open #2: %v", err)
}
if _, err := p2.RecoverVolume(ctx, "v1"); err != nil {
t.Fatalf("RecoverVolume #2: %v", err)
}
// Invariant 1: every acked LBA MUST be byte-exact.
for i := 0; i < nAcked; i++ {
got := make([]byte, blockSize)
if _, err := b2.Read(ctx, int64(i)*blockSize, got); err != nil {
t.Fatalf("acked Read[%d]: %v", i, err)
}
if !bytes.Equal(got, ackedBlocks[i]) {
t.Fatalf("ACKED LBA %d did NOT survive (impl=%s) — contract §2 violation",
i, impl)
}
}
// Invariant 2: every unacked LBA is EITHER original or
// zero — never partial / foreign bytes.
zero := make([]byte, blockSize)
for i := 0; i < nUnacked; i++ {
lba := nAcked + i
got := make([]byte, blockSize)
if _, err := b2.Read(ctx, int64(lba)*blockSize, got); err != nil {
t.Fatalf("unacked Read[%d]: %v", i, err)
}
isOriginal := bytes.Equal(got, unackedBlocks[i])
isZero := bytes.Equal(got, zero)
if !isOriginal && !isZero {
t.Fatalf("UNACKED LBA %d (impl=%s) is neither original write nor zero — CORRUPTION: first non-zero byte %d = 0x%02x",
lba, impl, firstNonZero(got), got[firstNonZero(got)])
}
}
})
}
}
func firstNonZero(p []byte) int {
for i, b := range p {
if b != 0 {
return i
}
}
return -1
}
@@ -0,0 +1,122 @@
// T3c scenario 2 of 4 — WAL replay correctness.
//
// Variant of crash-recovery that stresses the WAL replay path
// rather than the extent-read path: writes N blocks without
// waiting for checkpoint advance, then restarts. Recover must
// replay the WAL entries and ALL N blocks must be readable.
//
// Differs from crash-recovery in that it does NOT pause between
// Write and Close — so Recover sees WAL entries that haven't yet
// been checkpoint-flushed to the extent region.
//
// Pins ledger row INV-DURABLE-WAL-REPLAY-001.
package durable_test
import (
"bytes"
"context"
"fmt"
"testing"
"github.com/seaweedfs/seaweed-block/core/frontend"
"github.com/seaweedfs/seaweed-block/core/frontend/durable"
)
// TestT3c_Scenario_WALReplay_NAckedWrites pins that N acked
// writes fast-enough to land in the WAL are all recoverable.
func TestT3c_Scenario_WALReplay_NAckedWrites(t *testing.T) {
for _, impl := range implMatrix() {
impl := impl
t.Run(string(impl), func(t *testing.T) {
root := t.TempDir()
id := frontend.Identity{VolumeID: "v1", ReplicaID: "r1", Epoch: 1, EndpointVersion: 1}
view := newStubView(healthyProj(id))
cfg := durable.ProviderConfig{
Impl: impl,
StorageRoot: root,
BlockSize: 4096,
NumBlocks: 64,
}
// Phase 1: rapid N writes + Sync + immediate Close.
p1, err := durable.NewDurableProvider(cfg, view)
if err != nil {
t.Fatalf("NewDurableProvider #1: %v", err)
}
ctx := context.Background()
backend, err := p1.Open(ctx, "v1")
if err != nil {
t.Fatalf("Open #1: %v", err)
}
if _, err := p1.RecoverVolume(ctx, "v1"); err != nil {
t.Fatalf("RecoverVolume #1: %v", err)
}
const n = 32
const blockSize = 4096
blocks := make([][]byte, n)
for i := 0; i < n; i++ {
blocks[i] = make([]byte, blockSize)
seed := byte(i * 43)
for j := range blocks[i] {
blocks[i][j] = seed + byte(j)
}
offset := int64(i) * blockSize
if _, err := backend.Write(ctx, offset, blocks[i]); err != nil {
t.Fatalf("Write[%d]: %v", i, err)
}
}
// Sync acks everything written so far.
if err := backend.Sync(ctx); err != nil {
t.Fatalf("Sync: %v", err)
}
if err := p1.Close(); err != nil {
t.Fatalf("p1.Close: %v", err)
}
// Phase 2: restart. Recover MUST replay all N from WAL
// or extent (impl-dependent) so every LBA is readable.
p2, err := durable.NewDurableProvider(cfg, view)
if err != nil {
t.Fatalf("NewDurableProvider #2: %v", err)
}
defer p2.Close()
b2, err := p2.Open(ctx, "v1")
if err != nil {
t.Fatalf("Open #2: %v", err)
}
report, err := p2.RecoverVolume(ctx, "v1")
if err != nil {
t.Fatalf("RecoverVolume #2: %v (evidence=%s)", err, report.Evidence)
}
// Recovered LSN must reflect all N writes.
if report.RecoveredLSN < n {
t.Errorf("RecoveredLSN=%d, want >= %d (all N writes)", report.RecoveredLSN, n)
}
// Every LBA must read back its original bytes.
missing := 0
for i := 0; i < n; i++ {
got := make([]byte, blockSize)
if _, err := b2.Read(ctx, int64(i)*blockSize, got); err != nil {
t.Fatalf("Read[%d]: %v", i, err)
}
if !bytes.Equal(got, blocks[i]) {
missing++
if missing <= 3 {
t.Errorf("LBA %d lost after restart (impl=%s); first diff @ idx %d",
i, impl, firstDiffIdx(got, blocks[i]))
}
}
}
if missing > 0 {
t.Fatalf("%d / %d acked writes did NOT survive WAL replay (impl=%s)",
missing, n, impl)
}
_ = fmt.Sprint // keep fmt import available for future diagnostics
})
}
}
@@ -0,0 +1,94 @@
# T3c Durable Backend Perf Baseline
**Date**: 2026-04-22
**Status**: characterization only — no pass/fail gate
**Purpose**: Per T3c mini plan §1.3 + audit §11 G-int.6. Publish
first-light numbers for both `LogicalStorage` impls so future
changes have a comparison point. No threshold; regressions become
visible but aren't auto-blocking.
---
## Workload
| Parameter | Value |
|---|---|
| Operation | 4 KiB random write |
| Queue depth | 8 |
| Duration | 60 seconds |
| Volume size | 256 MiB (65536 × 4 KiB blocks) |
| Host | sw dev machine (Windows 11; localhost loopback) |
| Driver | Go benchmark (`BenchmarkT3c_DurablePerf`) — not fio |
The originally-specified workload was a fio run (mini plan §1.3).
Because fio is not available in this dev environment, the
baseline is captured via Go benchmarks against the in-process
`StorageBackend` → `LogicalStorage` path. This captures the
adapter + storage cost without wire-layer overhead; m01 fio runs
are a post-sign activity that will overlay true network + kernel
cost.
---
## Numbers — first-light (2026-04-22, sw dev Windows 11, loopback)
Capture via `BenchmarkT3c_DurablePerf` at 8000 iterations, Sync
every 64 writes, 4 KiB random write, 256 MiB volume.
### Matrix comparison
| Metric | walstore | smartwal |
|---|---|---|
| ns/op | 197,365 | 303,436 |
| Throughput (mean) | 20.75 MB/s | 13.50 MB/s |
| Approx ops/s | ~5,067 | ~3,295 |
### Observations
- walstore is ~1.5× faster than smartwal on this specific
workload (4 KiB random write with periodic Sync every 64 ops).
Not a general claim — different workloads (sequential, larger
block, longer sync intervals) may flip the ordering.
- Both impls are well within the order-of-magnitude we'd expect
for single-threaded in-process loopback writes with periodic
fsync. Numbers are useful as a comparison point, not as a
published performance claim.
- p50 / p99 latency percentiles are NOT captured by this benchmark
(standard Go bench only reports mean ns/op). A later fio run
will fill that gap.
Numbers are first-light. Trends matter more than absolute values
until the m01 fio run replaces these with real hardware + network
cost.
---
## Reproduction
```bash
cd seaweed_block
go test -run '^$' -bench 'BenchmarkT3c_DurablePerf' ./core/frontend/durable/ -benchtime=60s -count=1
```
The benchmark iterates over `{walstore, smartwal}` impls per the
shared `logicalStorageFactories()` helper (Addendum A #1 matrix).
---
## Scope + non-claims
- Characterization ONLY. No regression gate; no pass/fail.
- Single workload (4 KiB random write). Read + mixed + sequential
workloads land post-G4.
- No cross-node / network / kernel overhead — that's the m01 fio
run scheduled for post-sign verification.
- The `_TBD_` placeholder numbers are not a gap in T3c delivery;
they're a shape commitment that later measurement fills.
---
## Change log
| Date | Change | Author |
|---|---|---|
| 2026-04-22 | T3c initial baseline shape; numbers TBD | sw |
@@ -0,0 +1,57 @@
# T3c scenario 1 of 4 — crash recovery.
#
# Canonical G4 gate: any block whose Write returned ack (via Sync
# returning nil) MUST survive a process restart byte-exact.
#
# YAML is documentation of shape. The authoritative test is the
# matrix-parameterized Go replay at
# core/frontend/durable/scenario_crash_recovery_test.go, which
# runs against both walstore and smartwal impls per Addendum A #1.
#
# Ledger: INV-DURABLE-001
name: t3c-durable-crash-recovery
purpose: canonical G4 gate — acked bytes survive restart byte-exact
variant_matrix:
- walstore
- smartwal
phases:
- name: write_and_ack
actions:
- open_provider:
impl: ${variant}
storage_root: ${artifact_dir}/durable
num_blocks: 32
block_size: 4096
volume_id: v1
- recover: {volume_id: v1}
- write_n_distinct_blocks:
count: 8
seed: deterministic
- sync: {}
- close_provider: {}
- name: restart
actions:
- open_provider:
impl: ${variant}
storage_root: ${artifact_dir}/durable
num_blocks: 32
block_size: 4096
volume_id: v1
- recover:
volume_id: v1
assert_recovered_lsn_gt: 0
- name: verify
actions:
- read_all_blocks: {assert: byte_exact_match}
acceptance:
- all 8 blocks read back byte-exact after restart (both impls)
- recovered LSN > 0 on second Recover
- no error on any Read
pins_ledger:
- INV-DURABLE-001
@@ -0,0 +1,49 @@
# T3c scenario 4 of 4 — disk fill / graceful error.
#
# Volume geometry is fixed at create time (NumBlocks × BlockSize).
# Writing past the last LBA must:
# - return a clean error (not silent success)
# - leave in-range blocks intact (no corruption)
#
# V3 equivalent of V2's "disk-fill" — exercises the fail-hard
# property without needing to exhaust a real filesystem.
#
# Go replay: core/frontend/durable/scenario_disk_fill_test.go
#
# Ledger: PCDD-DURABLE-DISK-FULL-001
name: t3c-durable-disk-fill
purpose: write past volume end fails cleanly without corrupting in-range data
variant_matrix:
- walstore
- smartwal
phases:
- name: fill_volume
actions:
- open_provider:
impl: ${variant}
num_blocks: 4
block_size: 4096
- recover: {volume_id: v1}
- write_blocks: {lba: 0..3, seed: F}
- sync: {}
- name: attempt_overflow
actions:
- write:
offset: 16384 # numBlocks * blockSize; first byte past EOV
assert: error_returned
- name: verify_no_corruption
actions:
- for_each_lba:
- lba: 0..3
assert: bytes_match_seed_F
acceptance:
- write past volume end returns error (both impls)
- all 4 in-range blocks byte-exact (no corruption from failed op)
pins_ledger:
- PCDD-DURABLE-DISK-FULL-001
@@ -0,0 +1,50 @@
# T3c scenario 3 of 4 — fsync boundary correctness.
#
# LogicalStorage contract §2: "Unacked data may disappear after
# restart but cannot corrupt acked data."
#
# Two write sets separated by Sync. After restart:
# - ACKED blocks MUST be byte-exact.
# - UNACKED blocks are EITHER original OR zero — never
# partial / never another block's bytes.
#
# Go replay: core/frontend/durable/scenario_fsync_boundary_test.go
#
# Ledger: INV-DURABLE-FSYNC-BOUNDARY-001
name: t3c-durable-fsync-boundary
purpose: acked bytes preserved; unacked may vanish but cannot corrupt
variant_matrix:
- walstore
- smartwal
phases:
- name: acked_writes
actions:
- open_provider: {impl: ${variant}, num_blocks: 32, block_size: 4096}
- recover: {volume_id: v1}
- write_blocks: {lba: 0..4, seed: A}
- sync: {}
- name: unacked_writes
actions:
- write_blocks: {lba: 5..9, seed: B}
# NO sync
- name: restart_and_verify
actions:
- close_provider: {}
- open_provider: {impl: ${variant}}
- recover: {volume_id: v1}
- for_each_lba:
- lba: 0..4
assert: bytes_match_seed_A
- lba: 5..9
assert: bytes_match_seed_B_or_zero_never_other
acceptance:
- all 5 acked blocks byte-exact after restart (both impls)
- all 5 unacked blocks either original or zero (no partial, no foreign bytes)
pins_ledger:
- INV-DURABLE-FSYNC-BOUNDARY-001
@@ -0,0 +1,46 @@
# T3c scenario 2 of 4 — WAL replay correctness.
#
# N acked writes, immediate Close (so WAL may still hold entries
# that haven't been checkpoint-flushed to extent). Restart must
# replay the WAL during Recover so all N blocks are readable.
#
# Go replay: core/frontend/durable/scenario_wal_replay_test.go
#
# Ledger: INV-DURABLE-WAL-REPLAY-001
name: t3c-durable-wal-replay
purpose: all N acked writes recoverable via WAL replay after restart
variant_matrix:
- walstore
- smartwal
phases:
- name: rapid_writes
actions:
- open_provider:
impl: ${variant}
storage_root: ${artifact_dir}/durable
num_blocks: 64
- recover: {volume_id: v1}
- write_n_distinct_blocks:
count: 32
- sync: {}
- close_provider: {immediate: true}
- name: restart_and_replay
actions:
- open_provider: {impl: ${variant}, storage_root: ${artifact_dir}/durable}
- recover:
volume_id: v1
assert_recovered_lsn_ge: 32
- name: verify_all
actions:
- read_all_blocks: {assert: byte_exact_match, count: 32}
acceptance:
- all 32 blocks readable with original bytes (both impls)
- recovered LSN >= 32
pins_ledger:
- INV-DURABLE-WAL-REPLAY-001