phase136: profile wal write internals

This commit is contained in:
pingqiu committed 2026-07-04 16:07:00 -07:00
1 parent 986cca6d94
commit 07b14b7800
17 files changed
+859 -67

No files matched your search

@@ -422,6 +422,23 @@ func TestDurableProvider_DurableStatuses_ReportWriteBatchProfile(t *testing.T) {
if prof.BackendStorageBatchCalls != 1 || prof.BackendStorageBatchBlocks != 2 {
t.Fatalf("backend batch profile mismatch: %+v", prof)
}
if impl == durable.ImplWALStore {
if prof.WALCopyOps == 0 || prof.WALCopyBytes == 0 || prof.WALCopyDurationNanos == 0 {
t.Fatalf("WAL copy profile missing: %+v", prof)
}
if prof.WALEncodeOps == 0 || prof.WALEncodeBytes == 0 || prof.WALEncodeDurationNanos == 0 {
t.Fatalf("WAL encode profile missing: %+v", prof)
}
if prof.WALChecksumOps == 0 || prof.WALChecksumBytes == 0 || prof.WALChecksumDurationNanos == 0 {
t.Fatalf("WAL checksum profile missing: %+v", prof)
}
if prof.WALAppendOps == 0 || prof.WALAppendBytes == 0 || prof.WALAppendDurationNanos == 0 {
t.Fatalf("WAL append profile missing: %+v", prof)
}
if prof.DirtyMapUpdateOps == 0 || prof.DirtyMapUpdateDurationNanos == 0 {
t.Fatalf("dirty-map profile missing: %+v", prof)
}
}
})
}
}
@@ -236,6 +236,24 @@ func (b *StorageBackend) durableStatus(volumeID, path, impl string) VolumeStatus
b.mu.Unlock()
durableLSN, retainedLSN, headLSN := b.storage.Boundaries()
evidence, _ := b.opEvidence.Load().(string)
writeProfile := b.profile.snapshot()
if instrumented, ok := b.storage.(storage.WriteInstrumented); ok {
storageProfile := instrumented.WriteInstrumentation()
writeProfile.WALCopyOps = storageProfile.WALCopyOps
writeProfile.WALCopyBytes = storageProfile.WALCopyBytes
writeProfile.WALCopyDurationNanos = storageProfile.WALCopyDurationNanos
writeProfile.WALEncodeOps = storageProfile.WALEncodeOps
writeProfile.WALEncodeBytes = storageProfile.WALEncodeBytes
writeProfile.WALEncodeDurationNanos = storageProfile.WALEncodeDurationNanos
writeProfile.WALChecksumOps = storageProfile.WALChecksumOps
writeProfile.WALChecksumBytes = storageProfile.WALChecksumBytes
writeProfile.WALChecksumDurationNanos = storageProfile.WALChecksumDurationNanos
writeProfile.WALAppendOps = storageProfile.WALAppendOps
writeProfile.WALAppendBytes = storageProfile.WALAppendBytes
writeProfile.WALAppendDurationNanos = storageProfile.WALAppendDurationNanos
writeProfile.DirtyMapUpdateOps = storageProfile.DirtyMapUpdateOps
writeProfile.DirtyMapUpdateDurationNanos = storageProfile.DirtyMapUpdateDurationNanos
}
return VolumeStatus{
VolumeID: volumeID,
Path: path,
@@ -251,7 +269,7 @@ func (b *StorageBackend) durableStatus(volumeID, path, impl string) VolumeStatus
HeadLSN: headLSN,
Evidence: evidence,
Closed: closed,
WriteProfile: b.profile.snapshot(),
WriteProfile: writeProfile,
}
}
@@ -9,18 +9,32 @@ import (
// It is not a performance API; callers use it to prove which product-owned
// path observed the write and roughly where time accumulated.
type WriteProfileStatus struct {
TargetWriteOps uint64
TargetWriteBytes uint64
TargetWriteDurationNanos uint64
BackendWriteOps uint64
BackendWriteBytes uint64
BackendWriteDurationNanos uint64
BackendStorageWriteCalls uint64
BackendStorageWriteBlocks uint64
BackendStorageBatchCalls uint64
BackendStorageBatchBlocks uint64
BackendSyncOps uint64
BackendSyncDurationNanos uint64
TargetWriteOps uint64
TargetWriteBytes uint64
TargetWriteDurationNanos uint64
BackendWriteOps uint64
BackendWriteBytes uint64
BackendWriteDurationNanos uint64
BackendStorageWriteCalls uint64
BackendStorageWriteBlocks uint64
BackendStorageBatchCalls uint64
BackendStorageBatchBlocks uint64
WALCopyOps uint64
WALCopyBytes uint64
WALCopyDurationNanos uint64
WALEncodeOps uint64
WALEncodeBytes uint64
WALEncodeDurationNanos uint64
WALChecksumOps uint64
WALChecksumBytes uint64
WALChecksumDurationNanos uint64
WALAppendOps uint64
WALAppendBytes uint64
WALAppendDurationNanos uint64
DirtyMapUpdateOps uint64
DirtyMapUpdateDurationNanos uint64
BackendSyncOps uint64
BackendSyncDurationNanos uint64
}
type writeProfile struct {
+13
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"hash/crc32"
"time"
)
// WAL entry kinds.
@@ -61,6 +62,11 @@ type walEntry struct {
// bytes are CRC32 + EntrySize so a reader can detect torn writes by
// verifying both fields.
func (e *walEntry) encode() ([]byte, error) {
return e.encodeWithInstrumentation(nil)
}
func (e *walEntry) encodeWithInstrumentation(instr *writeInstrumentation) ([]byte, error) {
start := time.Now()
switch e.Type {
case walEntryWrite:
if len(e.Data) == 0 {
@@ -100,10 +106,17 @@ func (e *walEntry) encode() ([]byte, error) {
copy(buf[off:], e.Data)
off += len(e.Data)
}
checksumStart := time.Now()
checksum := crc32.ChecksumIEEE(buf[:off])
if instr != nil {
instr.recordWALChecksum(off, time.Since(checksumStart))
}
le.PutUint32(buf[off:], checksum)
off += 4
le.PutUint32(buf[off:], totalSize)
if instr != nil {
instr.recordWALEncode(len(buf), time.Since(start))
}
return buf, nil
}
+14 -3
View File
@@ -7,6 +7,7 @@ import (
"hash/crc32"
"os"
"sync"
"time"
)
var (
@@ -30,18 +31,20 @@ type walWriter struct {
walSize uint64 // size of the WAL region in bytes
logicalHead uint64 // monotonic write position
logicalTail uint64 // monotonic flush position
instr *writeInstrumentation
}
// newWALWriter constructs a writer over an open file. logicalHead and
// logicalTail come from the superblock when reopening; both 0 for a
// fresh store.
func newWALWriter(fd *os.File, walOffset, walSize, head, tail uint64) *walWriter {
func newWALWriter(fd *os.File, walOffset, walSize, head, tail uint64, instr *writeInstrumentation) *walWriter {
return &walWriter{
fd: fd,
walOffset: walOffset,
walSize: walSize,
logicalHead: head,
logicalTail: tail,
instr: instr,
}
}
@@ -56,7 +59,7 @@ func (w *walWriter) used() uint64 { return w.logicalHead - w.logicalTail }
//
// Returns errWALFull when even the padding+entry would not fit.
func (w *walWriter) append(entry *walEntry) (walRelOffset uint64, err error) {
buf, err := entry.encode()
buf, err := entry.encodeWithInstrumentation(w.instr)
if err != nil {
return 0, fmt.Errorf("walWriter.append: encode: %w", err)
}
@@ -86,9 +89,13 @@ func (w *walWriter) append(entry *walEntry) (walRelOffset uint64, err error) {
return 0, errWALFull
}
absOffset := int64(w.walOffset + physHead)
writeStart := time.Now()
if _, err := w.fd.WriteAt(buf, absOffset); err != nil {
return 0, fmt.Errorf("walWriter.append: pwrite at %d: %w", absOffset, err)
}
if w.instr != nil {
w.instr.recordWALAppend(len(buf), time.Since(writeStart))
}
writeOffset := physHead
w.logicalHead += entryLen
return writeOffset, nil
@@ -103,7 +110,7 @@ func (w *walWriter) appendBatch(entries []*walEntry) ([]uint64, error) {
}
bufs := make([][]byte, len(entries))
for i, entry := range entries {
buf, err := entry.encode()
buf, err := entry.encodeWithInstrumentation(w.instr)
if err != nil {
return nil, fmt.Errorf("walWriter.appendBatch: encode entry %d: %w", i, err)
}
@@ -128,9 +135,13 @@ func (w *walWriter) appendBatch(entries []*walEntry) ([]uint64, error) {
if len(pending) == 0 {
return nil
}
writeStart := time.Now()
if _, err := w.fd.WriteAt(pending, int64(w.walOffset+pendingStart)); err != nil {
return fmt.Errorf("walWriter.appendBatch: pwrite at %d: %w", w.walOffset+pendingStart, err)
}
if w.instr != nil {
w.instr.recordWALAppend(len(pending), time.Since(writeStart))
}
pending = nil
return nil
}
+15 -2
View File
@@ -102,6 +102,7 @@ type WALStore struct {
recycleFloorSrc RecycleFloorSource
syncs atomic.Uint64 // total fsync operations performed (test/diagnostic)
instr writeInstrumentation
}
// CreateWALStore initializes a new store file at path. Fails if path
@@ -183,14 +184,12 @@ func OpenWALStore(path string) (*WALStore, error) {
// the dirty map, and the group committer; it does NOT replay the WAL
// (that is Recover's job).
func openInitialized(path string, f *os.File, sb *superblock) (*WALStore, error) {
wal := newWALWriter(f, sb.WALOffset, sb.WALSize, sb.WALHead, sb.WALTail)
dm := newDirtyMap(64) // 64 shards is plenty for Phase 07 demo workloads
s := &WALStore{
path: path,
fd: f,
sb: sb,
wal: wal,
dm: dm,
extentBase: sb.WALOffset + sb.WALSize,
nextLSN: sb.WALCheckpointLSN + 1,
@@ -199,6 +198,8 @@ func openInitialized(path string, f *os.File, sb *superblock) (*WALStore, error)
walHead: sb.WALHead,
checkpointLSN: sb.WALCheckpointLSN,
}
wal := newWALWriter(f, sb.WALOffset, sb.WALSize, sb.WALHead, sb.WALTail, &s.instr)
s.wal = wal
if s.nextLSN < 1 {
s.nextLSN = 1
}
@@ -392,8 +393,10 @@ func (s *WALStore) Write(lba uint32, data []byte) (uint64, error) {
s.nextLSN++
s.mu.Unlock()
copyStart := time.Now()
dataCopy := make([]byte, len(data))
copy(dataCopy, data)
s.instr.recordWALCopy(len(dataCopy), time.Since(copyStart))
entry := &walEntry{
LSN: lsn,
@@ -406,7 +409,9 @@ func (s *WALStore) Write(lba uint32, data []byte) (uint64, error) {
if err != nil {
return 0, fmt.Errorf("storage: WAL append: %w", err)
}
dirtyStart := time.Now()
s.dm.put(uint64(lba), walRelOff, lsn, uint32(len(dataCopy)))
s.instr.recordDirtyMapUpdate(1, time.Since(dirtyStart))
s.mu.Lock()
if lsn > s.walHead {
@@ -452,8 +457,10 @@ func (s *WALStore) WriteBatch(startLBA uint32, blocks [][]byte) ([]uint64, error
entries := make([]*walEntry, len(blocks))
lsns := make([]uint64, len(blocks))
for i, data := range blocks {
copyStart := time.Now()
dataCopy := make([]byte, len(data))
copy(dataCopy, data)
s.instr.recordWALCopy(len(dataCopy), time.Since(copyStart))
lsn := firstLSN + uint64(i)
lsns[i] = lsn
entries[i] = &walEntry{
@@ -468,9 +475,11 @@ func (s *WALStore) WriteBatch(startLBA uint32, blocks [][]byte) ([]uint64, error
if err != nil {
return nil, fmt.Errorf("storage: WAL batch append: %w", err)
}
dirtyStart := time.Now()
for i, walRelOff := range offsets {
s.dm.put(uint64(startLBA+uint32(i)), walRelOff, lsns[i], uint32(len(blocks[i])))
}
s.instr.recordDirtyMapUpdate(len(offsets), time.Since(dirtyStart))
s.mu.Lock()
lastLSN := lsns[len(lsns)-1]
@@ -484,6 +493,10 @@ func (s *WALStore) WriteBatch(startLBA uint32, blocks [][]byte) ([]uint64, error
return lsns, nil
}
func (s *WALStore) WriteInstrumentation() WriteInstrumentationStatus {
return s.instr.snapshot()
}
// Read returns the current bytes at lba. Dirty entries are served
// from the WAL; clean LBAs are served from the extent.
func (s *WALStore) Read(lba uint32) ([]byte, error) {
@@ -0,0 +1,121 @@
package storage
import (
"sync/atomic"
"time"
)
// WriteInstrumentationStatus is a read-only snapshot of storage-internal write
// costs. It is diagnostic evidence only; it must not affect write semantics.
type WriteInstrumentationStatus struct {
WALCopyOps uint64
WALCopyBytes uint64
WALCopyDurationNanos uint64
WALEncodeOps uint64
WALEncodeBytes uint64
WALEncodeDurationNanos uint64
WALChecksumOps uint64
WALChecksumBytes uint64
WALChecksumDurationNanos uint64
WALAppendOps uint64
WALAppendBytes uint64
WALAppendDurationNanos uint64
DirtyMapUpdateOps uint64
DirtyMapUpdateDurationNanos uint64
}
// WriteInstrumented is an optional LogicalStorage extension used by durable
// status/report gates to expose storage-internal write cost evidence.
type WriteInstrumented interface {
WriteInstrumentation() WriteInstrumentationStatus
}
type writeInstrumentation struct {
walCopyOps atomic.Uint64
walCopyBytes atomic.Uint64
walCopyDurationNanos atomic.Uint64
walEncodeOps atomic.Uint64
walEncodeBytes atomic.Uint64
walEncodeDurationNanos atomic.Uint64
walChecksumOps atomic.Uint64
walChecksumBytes atomic.Uint64
walChecksumDurationNanos atomic.Uint64
walAppendOps atomic.Uint64
walAppendBytes atomic.Uint64
walAppendDurationNanos atomic.Uint64
dirtyMapUpdateOps atomic.Uint64
dirtyMapUpdateDurationNanos atomic.Uint64
}
func storageDurationNanos(d time.Duration) uint64 {
if d <= 0 {
return 1
}
return uint64(d.Nanoseconds())
}
func (i *writeInstrumentation) recordWALCopy(bytes int, d time.Duration) {
if i == nil || bytes <= 0 {
return
}
i.walCopyOps.Add(1)
i.walCopyBytes.Add(uint64(bytes))
i.walCopyDurationNanos.Add(storageDurationNanos(d))
}
func (i *writeInstrumentation) recordWALEncode(bytes int, d time.Duration) {
if i == nil || bytes <= 0 {
return
}
i.walEncodeOps.Add(1)
i.walEncodeBytes.Add(uint64(bytes))
i.walEncodeDurationNanos.Add(storageDurationNanos(d))
}
func (i *writeInstrumentation) recordWALChecksum(bytes int, d time.Duration) {
if i == nil || bytes <= 0 {
return
}
i.walChecksumOps.Add(1)
i.walChecksumBytes.Add(uint64(bytes))
i.walChecksumDurationNanos.Add(storageDurationNanos(d))
}
func (i *writeInstrumentation) recordWALAppend(bytes int, d time.Duration) {
if i == nil || bytes <= 0 {
return
}
i.walAppendOps.Add(1)
i.walAppendBytes.Add(uint64(bytes))
i.walAppendDurationNanos.Add(storageDurationNanos(d))
}
func (i *writeInstrumentation) recordDirtyMapUpdate(ops int, d time.Duration) {
if i == nil || ops <= 0 {
return
}
i.dirtyMapUpdateOps.Add(uint64(ops))
i.dirtyMapUpdateDurationNanos.Add(storageDurationNanos(d))
}
func (i *writeInstrumentation) snapshot() WriteInstrumentationStatus {
if i == nil {
return WriteInstrumentationStatus{}
}
return WriteInstrumentationStatus{
WALCopyOps: i.walCopyOps.Load(),
WALCopyBytes: i.walCopyBytes.Load(),
WALCopyDurationNanos: i.walCopyDurationNanos.Load(),
WALEncodeOps: i.walEncodeOps.Load(),
WALEncodeBytes: i.walEncodeBytes.Load(),
WALEncodeDurationNanos: i.walEncodeDurationNanos.Load(),
WALChecksumOps: i.walChecksumOps.Load(),
WALChecksumBytes: i.walChecksumBytes.Load(),
WALChecksumDurationNanos: i.walChecksumDurationNanos.Load(),
WALAppendOps: i.walAppendOps.Load(),
WALAppendBytes: i.walAppendBytes.Load(),
WALAppendDurationNanos: i.walAppendDurationNanos.Load(),
DirtyMapUpdateOps: i.dirtyMapUpdateOps.Load(),
DirtyMapUpdateDurationNanos: i.dirtyMapUpdateDurationNanos.Load(),
}
}
@@ -77,6 +77,7 @@ The supported-lab claim is intentionally narrow:
| 133 | Live Kubernetes stale host-path pruning after desired path replacement | PASS |
| 134 | Durable backend full-block write batching with product-owned counters | PASS |
| 135 | Post-batch write-path retriage and next-bottleneck classification | PASS |
| 136 | WAL append/copy/checksum profile and backend-internal bottleneck classification | PASS |
Key QA sign-offs:
@@ -96,6 +97,7 @@ Key QA sign-offs:
- `internal/docs/qa-assignments/phase133-nvme-k8s-stale-path-prune-qa-signoff.md`
- `internal/docs/qa-assignments/phase134-durable-backend-write-batching-qa-signoff.md`
- `internal/docs/qa-assignments/phase135-nvme-tcp-post-batch-retriage-qa-signoff.md`
- `internal/docs/qa-assignments/phase136-wal-append-copy-checksum-profile-qa-signoff.md`
## Performance Baseline
@@ -259,6 +261,40 @@ The result keeps NVMe/RDMA deferred: batching is active, network and sync are
not dominant, and the next evidence-backed step is to split WAL
append/copy/checksum/dirty-map cost inside the durable backend.
Phase 136 added those backend-internal counters and reran the same mounted
NVMe/TCP profile:
```text
phase136_wal_append_copy_checksum_profile_status=ok
target_write_observed=true
target_write_bytes=588075008
backend_write_bytes=588075008
backend_storage_batching_effective=true
backend_storage_batch_calls=17952
backend_storage_batch_blocks=143552
wal_copy_ops=143573
wal_copy_bytes=588075008
wal_copy_duration_ms=593
wal_encode_ops=143573
wal_encode_bytes=593530782
wal_encode_duration_ms=753
wal_checksum_ops=143573
wal_checksum_bytes=592382198
wal_checksum_duration_ms=100
wal_append_ops=17981
wal_append_bytes=593543918
wal_append_duration_ms=338
dirty_map_update_ops=143573
dirty_map_update_duration_ms=67
post_phase136_bottleneck=wal_encode
next_recommendation=phase137_reduce_wal_record_encode_copy
cleanup_status=ok
```
The named backend-internal cost is WAL record encode/copy. This keeps the next
work item inside the durable backend; it still does not create an NVMe/RDMA,
RoCE, throughput, latency, or production SLO claim.
Phase 127 closes the source/component side of the ANA Change Notice gap:
```text
+9
View File
@@ -760,6 +760,15 @@ Recommended order from here:
local-path write was `1075.63 MiB/s`. The live gate classified the
post-batch bottleneck as `backend_write` and recommends Phase 136
`wal_append_copy_checksum_profile`.
94. Phase 136: WAL Append / Copy / Checksum Profile. **Closed 2026-07-04,
runner PASS**
Added product-owned `/status/durable` counters for WAL copy, record encode,
checksum, append/write-at, and dirty-map update. The comparable 512MiB
mounted NVMe/TCP gate kept backend batching active
(`backend_storage_batch_calls=17952`) and named `wal_encode` as the largest
backend-internal cost (`753ms`), with copy close behind (`593ms`). The next
evidence-backed phase is reducing WAL record encode/copy cost, not NVMe/RDMA
or a performance/SLO claim.
The internal release-train contract is
`internal/docs/ref/operation-layer-v0.5-release-train.md`. Phases 41-44 close
+50 -49
View File
@@ -1,45 +1,46 @@
# Current Plan: Phase 136 WAL Append / Copy / Checksum Profile
# Current Plan: Phase 137 Reduce WAL Record Encode / Copy Cost
Status: planning.
Phase 135 reran the 512MiB supported-lab NVMe/TCP write profile after Phase 134
batching. The batch path was active, but wall-clock write behavior remained in
the same range as Phase 126:
Phase 136 split the durable backend write path below the batch seam with
product-owned `/status/durable` counters:
```text
phase135_nvme_tcp_post_batch_retriage_status=ok
block_nvme_seq_write_mibps=172.80
local_path_seq_write_mibps=1075.63
block_vs_local_write_ratio=0.161
backend_write_duration_ms=25953
backend_storage_write_calls=17971
backend_storage_write_blocks=143573
backend_storage_batch_calls=17953
backend_storage_batch_blocks=143555
backend_sync_duration_ms=42
post_batch_bottleneck=backend_write
next_recommendation=phase136_wal_append_copy_checksum_profile
phase136_wal_append_copy_checksum_profile_status=ok
target_write_observed=true
backend_write_bytes=588075008
backend_storage_batch_calls=17952
backend_storage_batch_blocks=143552
backend_storage_batching_effective=true
wal_copy_duration_ms=593
wal_encode_duration_ms=753
wal_checksum_duration_ms=100
wal_append_duration_ms=338
dirty_map_update_duration_ms=67
post_phase136_bottleneck=wal_encode
next_recommendation=phase137_reduce_wal_record_encode_copy
cleanup_status=ok
```
This means the next useful work is not NVMe/RDMA. It is to split backend write
cost below the batch seam.
This means the next useful work is still not NVMe/RDMA. It is to reduce the WAL
record encode/copy cost while preserving WAL recovery semantics and the current
one-record-per-block durability model.
## Goal
```text
mounted NVMe/TCP write still reaches durable backend
-> backend write time is split into named internal costs
-> WAL record encode/copy/checksum cost is visible
-> WAL append/write-at cost is visible
-> dirty-map/update/bookkeeping cost is visible
-> next bottleneck is named from counters
-> backend batching remains active
-> WAL record encode/copy cost is reduced or isolated further
-> no WAL recovery semantics are weakened
-> next bottleneck is named from counters after the change
-> cleanup remains clean
```
## Required Evidence
```text
phase136_wal_append_copy_checksum_profile_status=ok
phase137_reduce_wal_record_encode_copy_status=ok
frontend_transport=tcp
roce_claim_allowed=false
nvme_rdma_claim_allowed=false
@@ -49,45 +50,45 @@ backend_storage_batching_effective=true
wal_encode_ops=<count>
wal_encode_bytes=<bytes>
wal_encode_duration_ms=<duration>
wal_append_ops=<count>
wal_append_bytes=<bytes>
wal_append_duration_ms=<duration>
wal_checksum_ops=<count>
wal_checksum_bytes=<bytes>
wal_checksum_duration_ms=<duration>
dirty_map_update_ops=<count>
dirty_map_update_duration_ms=<duration>
post_phase136_bottleneck=<wal_encode|wal_append|checksum|dirty_map|other|unknown>
wal_copy_ops=<count>
wal_copy_bytes=<bytes>
wal_copy_duration_ms=<duration>
phase136_wal_encode_duration_ms=753
phase136_wal_copy_duration_ms=593
post_phase137_bottleneck=<wal_encode|wal_copy|wal_append|wal_checksum|dirty_map|unknown>
next_recommendation=<specific next phase>
cleanup_status=ok
```
## Boundaries
- Do not optimize in this phase unless the counter insertion itself exposes a
trivial bug.
- Do not add broad tracing frameworks or logging in the data path.
- Do not change frontend protocol behavior, CSI semantics, authority behavior,
failover, or reconnect logic.
- Do not add broad tracing frameworks or data-path logging.
- Do not claim performance improvement, SLO, RoCE, NVMe/RDMA, GPU Direct,
cuFile/cuObject, or NIXL.
- Do not weaken WAL recovery semantics: every write still needs an LSN and a
recoverable record.
- Keep the change inside WAL record construction/copy shape unless evidence
proves the bottleneck moved.
## Candidate Work
1. Add low-overhead atomic duration/byte/op counters around `walEntry.encode`,
checksum work, `walWriter.append/appendBatch`, and dirty-map updates.
2. Expose those counters through `/status/durable` under `WriteProfile`.
3. Extend the Phase 135 wrapper or add a Phase 136 wrapper that asserts the new
fields are populated during a mounted NVMe/TCP write.
4. Classify the next bottleneck:
- WAL encode/copy/checksum dominates -> reduce record copy/checksum work;
- WAL append/write-at dominates -> inspect pwrite shape/write amplification;
- dirty-map dominates -> inspect map/shard/update path;
1. Reduce avoidable record-buffer copying in the WAL encode path.
2. Preserve the record format and recovery behavior unless a separate migration
plan is written.
3. Add a local regression proving encoded records still decode/recover.
4. Add a Phase 137 wrapper/scenario that reruns the Phase 136 profile and
compares against the Phase 136 encode/copy baseline.
5. Classify the next bottleneck after the change:
- encode/copy still dominates -> split encode allocation/copy further;
- append dominates -> inspect pwrite/coalescing shape;
- checksum dominates -> inspect checksum strategy;
- unknown -> add the missing counter instead of guessing.
## Exit Criteria
Phase 136 can close when the live supported-lab gate names the backend-internal
dominant cost from product-owned counters and cleanup is clean. If no single
cost dominates, close with the measured distribution and a concrete next
experiment.
Phase 137 can close when the live supported-lab gate either reduces the
Phase 136 WAL encode/copy cost or proves the cost is not reducible without a
larger WAL format change. The close report must name the next bottleneck from
product-owned counters and keep cleanup clean.
@@ -0,0 +1,79 @@
# Phase 136 Finished Plan: WAL Append / Copy / Checksum Profile
Status: **closed 2026-07-04, live gate PASS**.
## Problem
Phase 135 proved that durable backend batching is active but did not materially
move the supported-lab NVMe/TCP write result. The remaining bottleneck was still
inside backend write work, but the product did not yet expose enough evidence
to separate WAL record encode/copy, checksum, append/write-at, and dirty-map
bookkeeping.
## Work
Phase 136 added low-overhead product counters around the `walstore` write path:
- WAL data copy ops/bytes/duration.
- WAL record encode ops/bytes/duration.
- WAL checksum ops/bytes/duration.
- WAL append/write-at ops/bytes/duration.
- Dirty-map update ops/duration.
The counters are exposed through `/status/durable` in `WriteProfile` and are
validated by local regression tests plus a live mounted NVMe/TCP gate.
## Gate
Phase 136 added:
- `scripts/run-phase136-wal-append-copy-checksum-profile-gate.sh`
- `testops/scenarios/nvme-tcp-wal-append-copy-checksum-profile-chain.yaml`
The gate reuses the Phase 126 512MiB profile shape, requires active backend
batching, asserts all WAL-internal counters are populated, and emits a concrete
next-phase recommendation.
## Evidence
```text
phase136_wal_append_copy_checksum_profile_status=ok
profile_size_mib=512
target_write_observed=true
target_write_bytes=588075008
backend_write_bytes=588075008
backend_storage_batch_calls=17952
backend_storage_batch_blocks=143552
backend_storage_batching_effective=true
wal_copy_ops=143573
wal_copy_bytes=588075008
wal_copy_duration_ms=593
wal_encode_ops=143573
wal_encode_bytes=593530782
wal_encode_duration_ms=753
wal_checksum_ops=143573
wal_checksum_bytes=592382198
wal_checksum_duration_ms=100
wal_append_ops=17981
wal_append_bytes=593543918
wal_append_duration_ms=338
dirty_map_update_ops=143573
dirty_map_update_duration_ms=67
post_phase136_bottleneck=wal_encode
next_recommendation=phase137_reduce_wal_record_encode_copy
cleanup_status=ok
```
Run bundle:
```text
results\20260704-160121-60c2
24 actions: 24 passed, 0 failed
```
## Conclusion
The backend-internal bottleneck is now named from live product evidence:
`wal_encode`, with data copy close behind. Phase 137 should reduce WAL record
encode/copy cost and keep the same mounted NVMe/TCP profiling gate. This phase
does not claim a throughput improvement, SLO, RoCE, or NVMe/RDMA.
@@ -418,6 +418,12 @@ rebuild, delete safety, or cleanup must start as a separate gated phase.
the Phase 126 range (`172.80 MiB/s` versus `177.72 MiB/s`) while local-path
write was `1075.63 MiB/s`. The next backend work should split WAL
append/copy/checksum/dirty-map costs before any NVMe/RDMA work.
- Phase 136 is closed for WAL append/copy/checksum profiling. The product now
exposes `/status/durable` counters for WAL copy, record encode, checksum,
append/write-at, and dirty-map update. The live 512MiB gate kept batching
active and named `wal_encode` as the largest backend-internal cost
(`753ms`), with WAL copy close behind (`593ms`). The next backend work
should reduce WAL record encode/copy cost.
- Later protocol candidates: complete a real NVMe/RDMA target, characterize
NVMe/TCP performance, or bridge to object/NIXL acceleration where the product
surface is object/storage rather than block PVC. Keep these separate so
@@ -1031,6 +1037,8 @@ Approximate engineering effort if scope remains tight:
`backend_storage_*` counters.
- Phase 135 is closed for post-batch NVMe/TCP write-path retriage and names
WAL append/copy/checksum profiling as the next backend step.
- Phase 136 is closed for WAL append/copy/checksum profiling and names
`wal_encode` / record-copy cost as the next backend step.
- 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.
@@ -0,0 +1,80 @@
# Phase 136 WAL Append / Copy / Checksum Profile QA Sign-Off
Verdict: **PASS**.
Validated source tree: local `phase136-wal-append-profile` working tree, synced
to `m02:/tmp/seaweed_block` as clean `HEAD` plus Phase 136 overlay only. The
known unrelated dirty NVMe test/runtime files were not copied into the lab tree.
Run:
```powershell
C:\work\swblock.exe run testops/scenarios/nvme-tcp-wal-append-copy-checksum-profile-chain.yaml `
-output results\phase136-wal-profile-run1.json `
-html results\phase136-wal-profile-run1.html
```
Run bundle:
```text
results\20260704-160121-60c2
24 actions: 24 passed, 0 failed
```
## Evidence
```text
phase136_wal_append_copy_checksum_profile_status=ok
frontend_transport=tcp
roce_claim_allowed=false
nvme_rdma_claim_allowed=false
performance_slo_claim_allowed=false
profile_size_mib=512
unit_wal_profile_regression_passed=true
target_write_observed=true
target_write_bytes=588075008
backend_write_bytes=588075008
backend_storage_batch_calls=17952
backend_storage_batch_blocks=143552
backend_storage_batching_effective=true
wal_copy_ops=143573
wal_copy_bytes=588075008
wal_copy_duration_ms=593
wal_encode_ops=143573
wal_encode_bytes=593530782
wal_encode_duration_ms=753
wal_checksum_ops=143573
wal_checksum_bytes=592382198
wal_checksum_duration_ms=100
wal_append_ops=17981
wal_append_bytes=593543918
wal_append_duration_ms=338
dirty_map_update_ops=143573
dirty_map_update_duration_ms=67
post_phase136_bottleneck=wal_encode
next_recommendation=phase137_reduce_wal_record_encode_copy
cleanup_status=ok
```
## Finding
The live 512MiB mounted NVMe/TCP path still reaches the durable backend and
the Phase 134 batch path is still active. The new product-owned counters split
the backend-internal cost:
- WAL record encode is the largest measured internal cost: `753ms`.
- WAL data copy is close behind: `593ms`.
- WAL append/write-at is smaller but visible: `338ms`.
- Checksum and dirty-map update are not dominant in this run.
The next phase should reduce WAL record encode/copy cost before returning to
NVMe/RDMA, RoCE, or broader transport work. This is profiling evidence, not a
performance/SLO claim.
## Cleanup
The gate reused the Phase 126 cleanup verifier and finished clean:
```text
cleanup_status=ok
```
@@ -196,6 +196,20 @@ backend_storage_write_calls = int(field(profile, "BackendStorageWriteCalls", "ba
backend_storage_write_blocks = int(field(profile, "BackendStorageWriteBlocks", "backendStorageWriteBlocks", default=0) or 0)
backend_storage_batch_calls = int(field(profile, "BackendStorageBatchCalls", "backendStorageBatchCalls", default=0) or 0)
backend_storage_batch_blocks = int(field(profile, "BackendStorageBatchBlocks", "backendStorageBatchBlocks", default=0) or 0)
wal_copy_ops = int(field(profile, "WALCopyOps", "walCopyOps", default=0) or 0)
wal_copy_bytes = int(field(profile, "WALCopyBytes", "walCopyBytes", default=0) or 0)
wal_copy_ns = int(field(profile, "WALCopyDurationNanos", "walCopyDurationNanos", default=0) or 0)
wal_encode_ops = int(field(profile, "WALEncodeOps", "walEncodeOps", default=0) or 0)
wal_encode_bytes = int(field(profile, "WALEncodeBytes", "walEncodeBytes", default=0) or 0)
wal_encode_ns = int(field(profile, "WALEncodeDurationNanos", "walEncodeDurationNanos", default=0) or 0)
wal_checksum_ops = int(field(profile, "WALChecksumOps", "walChecksumOps", default=0) or 0)
wal_checksum_bytes = int(field(profile, "WALChecksumBytes", "walChecksumBytes", default=0) or 0)
wal_checksum_ns = int(field(profile, "WALChecksumDurationNanos", "walChecksumDurationNanos", default=0) or 0)
wal_append_ops = int(field(profile, "WALAppendOps", "walAppendOps", default=0) or 0)
wal_append_bytes = int(field(profile, "WALAppendBytes", "walAppendBytes", default=0) or 0)
wal_append_ns = int(field(profile, "WALAppendDurationNanos", "walAppendDurationNanos", default=0) or 0)
dirty_map_update_ops = int(field(profile, "DirtyMapUpdateOps", "dirtyMapUpdateOps", default=0) or 0)
dirty_map_update_ns = int(field(profile, "DirtyMapUpdateDurationNanos", "dirtyMapUpdateDurationNanos", default=0) or 0)
sync_ops = int(field(profile, "BackendSyncOps", "backendSyncOps", default=0) or 0)
sync_ns = int(field(profile, "BackendSyncDurationNanos", "backendSyncDurationNanos", default=0) or 0)
def ms(ns):
@@ -215,6 +229,20 @@ with open(summary_out, "w") as f:
f.write(f"backend_storage_write_blocks={backend_storage_write_blocks}\n")
f.write(f"backend_storage_batch_calls={backend_storage_batch_calls}\n")
f.write(f"backend_storage_batch_blocks={backend_storage_batch_blocks}\n")
f.write(f"wal_copy_ops={wal_copy_ops}\n")
f.write(f"wal_copy_bytes={wal_copy_bytes}\n")
f.write(f"wal_copy_duration_ms={ms(wal_copy_ns)}\n")
f.write(f"wal_encode_ops={wal_encode_ops}\n")
f.write(f"wal_encode_bytes={wal_encode_bytes}\n")
f.write(f"wal_encode_duration_ms={ms(wal_encode_ns)}\n")
f.write(f"wal_checksum_ops={wal_checksum_ops}\n")
f.write(f"wal_checksum_bytes={wal_checksum_bytes}\n")
f.write(f"wal_checksum_duration_ms={ms(wal_checksum_ns)}\n")
f.write(f"wal_append_ops={wal_append_ops}\n")
f.write(f"wal_append_bytes={wal_append_bytes}\n")
f.write(f"wal_append_duration_ms={ms(wal_append_ns)}\n")
f.write(f"dirty_map_update_ops={dirty_map_update_ops}\n")
f.write(f"dirty_map_update_duration_ms={ms(dirty_map_update_ns)}\n")
f.write(f"backend_sync_ops={sync_ops}\n")
f.write(f"backend_sync_duration_ms={ms(sync_ns)}\n")
PY
@@ -131,6 +131,20 @@ BACKEND_STORAGE_WRITE_CALLS="$(require_summary_value "${BLOCK_SUMMARY}" backend_
BACKEND_STORAGE_WRITE_BLOCKS="$(require_summary_value "${BLOCK_SUMMARY}" backend_storage_write_blocks)"
BACKEND_STORAGE_BATCH_CALLS="$(require_summary_value "${BLOCK_SUMMARY}" backend_storage_batch_calls)"
BACKEND_STORAGE_BATCH_BLOCKS="$(require_summary_value "${BLOCK_SUMMARY}" backend_storage_batch_blocks)"
WAL_COPY_OPS="$(require_summary_value "${BLOCK_SUMMARY}" wal_copy_ops)"
WAL_COPY_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_copy_bytes)"
WAL_COPY_MS="$(require_summary_value "${BLOCK_SUMMARY}" wal_copy_duration_ms)"
WAL_ENCODE_OPS="$(require_summary_value "${BLOCK_SUMMARY}" wal_encode_ops)"
WAL_ENCODE_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_encode_bytes)"
WAL_ENCODE_MS="$(require_summary_value "${BLOCK_SUMMARY}" wal_encode_duration_ms)"
WAL_CHECKSUM_OPS="$(require_summary_value "${BLOCK_SUMMARY}" wal_checksum_ops)"
WAL_CHECKSUM_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_checksum_bytes)"
WAL_CHECKSUM_MS="$(require_summary_value "${BLOCK_SUMMARY}" wal_checksum_duration_ms)"
WAL_APPEND_OPS="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_ops)"
WAL_APPEND_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_bytes)"
WAL_APPEND_MS="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_duration_ms)"
DIRTY_MAP_UPDATE_OPS="$(require_summary_value "${BLOCK_SUMMARY}" dirty_map_update_ops)"
DIRTY_MAP_UPDATE_MS="$(require_summary_value "${BLOCK_SUMMARY}" dirty_map_update_duration_ms)"
SYNC_OPS="$(require_summary_value "${BLOCK_SUMMARY}" backend_sync_ops)"
SYNC_MS="$(require_summary_value "${BLOCK_SUMMARY}" backend_sync_duration_ms)"
@@ -144,6 +158,11 @@ assert_int_ge "${TARGET_BYTES}" "${SEQ_BYTES}" "target_write_bytes"
assert_int_ge "${BACKEND_BYTES}" "${SEQ_BYTES}" "backend_write_bytes"
assert_int_ge "${BACKEND_STORAGE_WRITE_CALLS}" 1 "backend_storage_write_calls"
assert_int_ge "${BACKEND_STORAGE_WRITE_BLOCKS}" 1 "backend_storage_write_blocks"
assert_int_ge "${WAL_COPY_OPS}" 1 "wal_copy_ops"
assert_int_ge "${WAL_ENCODE_OPS}" 1 "wal_encode_ops"
assert_int_ge "${WAL_CHECKSUM_OPS}" 1 "wal_checksum_ops"
assert_int_ge "${WAL_APPEND_OPS}" 1 "wal_append_ops"
assert_int_ge "${DIRTY_MAP_UPDATE_OPS}" 1 "dirty_map_update_ops"
WRITE_OBSERVATION="$(classify_write_path "${TARGET_MS}" "${BACKEND_MS}" "${SYNC_MS}" "${SYNC_OPS}")"
NEXT_RECOMMENDATION="$(recommendation_for "${WRITE_OBSERVATION}")"
@@ -166,6 +185,20 @@ write_summary "backend_storage_write_calls=${BACKEND_STORAGE_WRITE_CALLS}"
write_summary "backend_storage_write_blocks=${BACKEND_STORAGE_WRITE_BLOCKS}"
write_summary "backend_storage_batch_calls=${BACKEND_STORAGE_BATCH_CALLS}"
write_summary "backend_storage_batch_blocks=${BACKEND_STORAGE_BATCH_BLOCKS}"
write_summary "wal_copy_ops=${WAL_COPY_OPS}"
write_summary "wal_copy_bytes=${WAL_COPY_BYTES}"
write_summary "wal_copy_duration_ms=${WAL_COPY_MS}"
write_summary "wal_encode_ops=${WAL_ENCODE_OPS}"
write_summary "wal_encode_bytes=${WAL_ENCODE_BYTES}"
write_summary "wal_encode_duration_ms=${WAL_ENCODE_MS}"
write_summary "wal_checksum_ops=${WAL_CHECKSUM_OPS}"
write_summary "wal_checksum_bytes=${WAL_CHECKSUM_BYTES}"
write_summary "wal_checksum_duration_ms=${WAL_CHECKSUM_MS}"
write_summary "wal_append_ops=${WAL_APPEND_OPS}"
write_summary "wal_append_bytes=${WAL_APPEND_BYTES}"
write_summary "wal_append_duration_ms=${WAL_APPEND_MS}"
write_summary "dirty_map_update_ops=${DIRTY_MAP_UPDATE_OPS}"
write_summary "dirty_map_update_duration_ms=${DIRTY_MAP_UPDATE_MS}"
write_summary "backend_sync_ops=${SYNC_OPS}"
write_summary "backend_sync_duration_ms=${SYNC_MS}"
write_summary "write_path_observation=${WRITE_OBSERVATION}"
@@ -0,0 +1,184 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="${1:-$(pwd)}"
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${ROOT}/results/phase136-wal-append-copy-checksum-profile-gate}"
SUMMARY="${ARTIFACT_DIR}/phase136-wal-append-copy-checksum-profile-summary.txt"
PHASE126_DIR="${ARTIFACT_DIR}/phase126-profile"
SEQ_MIB="${SW_BLOCK_PHASE136_SEQ_MIB:-512}"
mkdir -p "${ARTIFACT_DIR}" "${PHASE126_DIR}"
: >"${SUMMARY}"
write_summary() {
echo "$*" | tee -a "${SUMMARY}" >/dev/null
}
summary_value() {
local file="$1"
local key="$2"
awk -F= -v key="$key" '$1 == key {value = substr($0, length(key) + 2)} END {if (value != "") print value}' "$file"
}
require_summary_value() {
local file="$1"
local key="$2"
local value
value="$(summary_value "$file" "$key")"
if [[ -z "${value}" ]]; then
echo "missing summary key ${key} in ${file}" >&2
exit 1
fi
printf '%s' "${value}"
}
assert_int_ge() {
local actual="$1"
local want="$2"
local label="$3"
python3 - "$actual" "$want" "$label" <<'PY'
import sys
actual = int(sys.argv[1])
want = int(sys.argv[2])
label = sys.argv[3]
if actual < want:
raise SystemExit(f"{label}={actual}, want >= {want}")
PY
}
classify_backend_internal_cost() {
python3 - "$@" <<'PY'
import sys
items = {
"wal_copy": int(sys.argv[1]),
"wal_encode": int(sys.argv[2]),
"wal_checksum": int(sys.argv[3]),
"wal_append": int(sys.argv[4]),
"dirty_map": int(sys.argv[5]),
}
name, value = max(items.items(), key=lambda kv: kv[1])
print(name if value > 0 else "unknown")
PY
}
recommendation_for_internal_cost() {
case "$1" in
wal_copy)
printf '%s' "phase137_reduce_backend_data_copy"
;;
wal_encode)
printf '%s' "phase137_reduce_wal_record_encode_copy"
;;
wal_checksum)
printf '%s' "phase137_checksum_strategy_profile"
;;
wal_append)
printf '%s' "phase137_wal_writeat_shape_profile"
;;
dirty_map)
printf '%s' "phase137_dirty_map_update_profile"
;;
*)
printf '%s' "phase137_deeper_backend_trace"
;;
esac
}
write_summary "phase136_wal_append_copy_checksum_profile_status=running"
write_summary "frontend_transport=tcp"
write_summary "roce_claim_allowed=false"
write_summary "nvme_rdma_claim_allowed=false"
write_summary "performance_slo_claim_allowed=false"
write_summary "profile_size_mib=${SEQ_MIB}"
cd "${ROOT}"
go test ./core/frontend/durable ./core/storage/... \
>"${ARTIFACT_DIR}/go-test-durable-storage.log" \
2>&1
write_summary "unit_wal_profile_regression_passed=true"
SW_BLOCK_ARTIFACT_DIR="${PHASE126_DIR}" \
SW_BLOCK_PHASE126_SEQ_MIB="${SEQ_MIB}" \
bash "${ROOT}/scripts/run-phase126-block-nvme-tcp-backend-write-instrumentation-gate.sh" "${ROOT}" \
>"${ARTIFACT_DIR}/phase126-profile.stdout.txt" \
2>"${ARTIFACT_DIR}/phase126-profile.stderr.txt"
PHASE126_SUMMARY="${PHASE126_DIR}/phase126-block-nvme-tcp-backend-write-instrumentation-summary.txt"
if [[ "$(require_summary_value "${PHASE126_SUMMARY}" phase126_block_nvme_tcp_backend_write_instrumentation_status)" != "ok" ]]; then
echo "phase126 profile dependency did not finish ok" >&2
exit 1
fi
TARGET_OBSERVED="$(require_summary_value "${PHASE126_SUMMARY}" target_write_observed)"
BACKEND_STORAGE_BATCH_CALLS="$(require_summary_value "${PHASE126_SUMMARY}" backend_storage_batch_calls)"
WAL_COPY_OPS="$(require_summary_value "${PHASE126_SUMMARY}" wal_copy_ops)"
WAL_COPY_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_copy_bytes)"
WAL_COPY_MS="$(require_summary_value "${PHASE126_SUMMARY}" wal_copy_duration_ms)"
WAL_ENCODE_OPS="$(require_summary_value "${PHASE126_SUMMARY}" wal_encode_ops)"
WAL_ENCODE_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_encode_bytes)"
WAL_ENCODE_MS="$(require_summary_value "${PHASE126_SUMMARY}" wal_encode_duration_ms)"
WAL_CHECKSUM_OPS="$(require_summary_value "${PHASE126_SUMMARY}" wal_checksum_ops)"
WAL_CHECKSUM_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_checksum_bytes)"
WAL_CHECKSUM_MS="$(require_summary_value "${PHASE126_SUMMARY}" wal_checksum_duration_ms)"
WAL_APPEND_OPS="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_ops)"
WAL_APPEND_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_bytes)"
WAL_APPEND_MS="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_duration_ms)"
DIRTY_MAP_UPDATE_OPS="$(require_summary_value "${PHASE126_SUMMARY}" dirty_map_update_ops)"
DIRTY_MAP_UPDATE_MS="$(require_summary_value "${PHASE126_SUMMARY}" dirty_map_update_duration_ms)"
CLEANUP_STATUS="$(require_summary_value "${PHASE126_SUMMARY}" cleanup_status)"
if [[ "${TARGET_OBSERVED}" != "true" ]]; then
echo "target_write_observed=${TARGET_OBSERVED}, want true" >&2
exit 1
fi
assert_int_ge "${BACKEND_STORAGE_BATCH_CALLS}" 1 "backend_storage_batch_calls"
assert_int_ge "${WAL_COPY_OPS}" 1 "wal_copy_ops"
assert_int_ge "${WAL_COPY_BYTES}" 1 "wal_copy_bytes"
assert_int_ge "${WAL_COPY_MS}" 1 "wal_copy_duration_ms"
assert_int_ge "${WAL_ENCODE_OPS}" 1 "wal_encode_ops"
assert_int_ge "${WAL_ENCODE_BYTES}" 1 "wal_encode_bytes"
assert_int_ge "${WAL_ENCODE_MS}" 1 "wal_encode_duration_ms"
assert_int_ge "${WAL_CHECKSUM_OPS}" 1 "wal_checksum_ops"
assert_int_ge "${WAL_CHECKSUM_BYTES}" 1 "wal_checksum_bytes"
assert_int_ge "${WAL_CHECKSUM_MS}" 1 "wal_checksum_duration_ms"
assert_int_ge "${WAL_APPEND_OPS}" 1 "wal_append_ops"
assert_int_ge "${WAL_APPEND_BYTES}" 1 "wal_append_bytes"
assert_int_ge "${WAL_APPEND_MS}" 1 "wal_append_duration_ms"
assert_int_ge "${DIRTY_MAP_UPDATE_OPS}" 1 "dirty_map_update_ops"
assert_int_ge "${DIRTY_MAP_UPDATE_MS}" 1 "dirty_map_update_duration_ms"
if [[ "${CLEANUP_STATUS}" != "ok" ]]; then
echo "cleanup_status=${CLEANUP_STATUS}, want ok" >&2
exit 1
fi
POST_PHASE136_BOTTLENECK="$(classify_backend_internal_cost "${WAL_COPY_MS}" "${WAL_ENCODE_MS}" "${WAL_CHECKSUM_MS}" "${WAL_APPEND_MS}" "${DIRTY_MAP_UPDATE_MS}")"
NEXT_RECOMMENDATION="$(recommendation_for_internal_cost "${POST_PHASE136_BOTTLENECK}")"
for key in \
target_write_observed \
target_write_bytes \
backend_write_bytes \
backend_storage_batch_calls \
backend_storage_batch_blocks \
wal_copy_ops \
wal_copy_bytes \
wal_copy_duration_ms \
wal_encode_ops \
wal_encode_bytes \
wal_encode_duration_ms \
wal_checksum_ops \
wal_checksum_bytes \
wal_checksum_duration_ms \
wal_append_ops \
wal_append_bytes \
wal_append_duration_ms \
dirty_map_update_ops \
dirty_map_update_duration_ms; do
write_summary "${key}=$(require_summary_value "${PHASE126_SUMMARY}" "${key}")"
done
write_summary "backend_storage_batching_effective=true"
write_summary "post_phase136_bottleneck=${POST_PHASE136_BOTTLENECK}"
write_summary "next_recommendation=${NEXT_RECOMMENDATION}"
write_summary "cleanup_status=${CLEANUP_STATUS}"
write_summary "phase136_wal_append_copy_checksum_profile_status=ok"
@@ -0,0 +1,127 @@
name: nvme-tcp-wal-append-copy-checksum-profile-chain
timeout: 90m
env:
product_root: "/tmp/seaweed_block"
ssh_key: "C:\\work\\dev_server\\testdev_key"
topology:
nodes:
m02:
host: 192.168.1.184
user: testdev
key: "{{ ssh_key }}"
phases:
- name: pre_clean
actions:
- action: pre_run_cleanup
node: m02
kill_patterns: "blockmaster,blockvolume,blockcsi,iscsi-target"
nvme_disconnect: "true"
iscsi_logout_prefix: "iqn.2026-05.io.seaweedfs"
- action: exec
node: m02
timeout: 5m
cmd: "helm status sw-block --namespace kube-system >/dev/null 2>&1 && helm uninstall sw-block --namespace kube-system --wait --timeout 240s || true; kubectl -n default delete pod sw-block-phase126-block-perf sw-block-phase126-local-perf --ignore-not-found=true --wait=true --timeout=60s || true; kubectl -n default delete pvc sw-block-phase126-block-pvc sw-block-phase126-local-pvc --ignore-not-found=true --wait=true --timeout=60s || true; kubectl delete storageclass sw-block-phase126-block --ignore-not-found=true --wait=true --timeout=60s || true; kubectl get pv --no-headers | awk '/sw-block-phase126/ {print $1}' | xargs -r -n1 kubectl patch pv --type=merge -p '{\"metadata\":{\"finalizers\":[]}}' >/dev/null 2>&1 || true; kubectl get pv --no-headers | awk '/sw-block-phase126/ {print $1}' | xargs -r kubectl delete pv --wait=false >/dev/null 2>&1 || true; kubectl -n kube-system get swblockvolumes.block.seaweedfs.com -o name 2>/dev/null | xargs -r -n1 kubectl -n kube-system patch --type=merge -p '{\"metadata\":{\"finalizers\":[]}}' >/dev/null 2>&1 || true; kubectl -n kube-system delete swblockvolumes.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1 || true; kubectl -n kube-system delete swblockclusters.block.seaweedfs.com --all --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1 || true; kubectl delete validatingadmissionpolicy,validatingadmissionpolicybinding -l app.kubernetes.io/instance=sw-block --ignore-not-found=true >/dev/null 2>&1 || true; kubectl delete crd swblockclusters.block.seaweedfs.com swblockvolumes.block.seaweedfs.com swblockreplicaeligibilities.block.seaweedfs.com swblockreplicarebuilds.block.seaweedfs.com swblockreplicafailbacks.block.seaweedfs.com swblockfrontendpublications.block.seaweedfs.com --ignore-not-found=true --wait=true --timeout=60s >/dev/null 2>&1 || true; sudo -n nvme disconnect-all >/dev/null 2>&1 || true; rm -rf /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile"
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
- name: run_gate
actions:
- action: exec
node: m02
timeout: 82m
cmd: "cd {{ product_root }} && SW_BLOCK_ARTIFACT_DIR=/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile SW_BLOCK_PHASE136_SEQ_MIB=512 SW_BLOCK_PHASE125_FRONTEND_IP_MAP=m01=10.0.0.1,m02=10.0.0.3 SW_BLOCK_PHASE125_EXPECTED_ROUTE_DEV=enp1s0np0 SW_BLOCK_IMPORT_K3S_SSH_KEY=/opt/work/testdev_key bash scripts/run-phase136-wal-append-copy-checksum-profile-gate.sh {{ product_root }}"
env.KUBECONFIG: "/etc/rancher/k3s/k3s.yaml"
- name: assert_summary
actions:
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^phase136_wal_append_copy_checksum_profile_status=ok$"
save_as: phase136_status_ok
- action: assert_greater
actual: "{{ phase136_status_ok }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^unit_wal_profile_regression_passed=true$"
save_as: unit_passed
- action: assert_greater
actual: "{{ unit_passed }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^target_write_observed=true$"
save_as: target_observed
- action: assert_greater
actual: "{{ target_observed }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^backend_storage_batching_effective=true$"
save_as: batch_effective
- action: assert_greater
actual: "{{ batch_effective }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^wal_copy_duration_ms=[1-9][0-9]*$"
save_as: wal_copy_duration
- action: assert_greater
actual: "{{ wal_copy_duration }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^wal_encode_duration_ms=[1-9][0-9]*$"
save_as: wal_encode_duration
- action: assert_greater
actual: "{{ wal_encode_duration }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^wal_append_duration_ms=[1-9][0-9]*$"
save_as: wal_append_duration
- action: assert_greater
actual: "{{ wal_append_duration }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^post_phase136_bottleneck=\\(wal_copy\\|wal_encode\\|wal_checksum\\|wal_append\\|dirty_map\\|unknown\\)$"
save_as: bottleneck_named
- action: assert_greater
actual: "{{ bottleneck_named }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^next_recommendation=phase137_"
save_as: recommendation_named
- action: assert_greater
actual: "{{ recommendation_named }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile/phase136-wal-append-copy-checksum-profile-summary.txt"
pattern: "^cleanup_status=ok$"
save_as: cleanup_ok
- action: assert_greater
actual: "{{ cleanup_ok }}"
threshold: "0"
- name: collect
always: true
actions:
- action: collect_path
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase136-wal-profile"
name: "remote-phases"
ignore_error: true