phase138: profile wal writeat shape

This commit is contained in:
pingqiu committed 2026-07-05 15:40:29 -07:00
1 parent d63922fb95
commit 0c974eb30b
15 files changed
+628 -43

No files matched your search

@@ -435,6 +435,9 @@ func TestDurableProvider_DurableStatuses_ReportWriteBatchProfile(t *testing.T) {
if prof.WALAppendOps == 0 || prof.WALAppendBytes == 0 || prof.WALAppendDurationNanos == 0 {
t.Fatalf("WAL append profile missing: %+v", prof)
}
if prof.WALAppendWriteAtCalls == 0 || prof.WALAppendWriteAtBytes == 0 || prof.WALAppendWriteAtMaxBytes == 0 {
t.Fatalf("WAL append write-at shape profile missing: %+v", prof)
}
if prof.DirtyMapUpdateOps == 0 || prof.DirtyMapUpdateDurationNanos == 0 {
t.Fatalf("dirty-map profile missing: %+v", prof)
}
@@ -251,6 +251,11 @@ func (b *StorageBackend) durableStatus(volumeID, path, impl string) VolumeStatus
writeProfile.WALAppendOps = storageProfile.WALAppendOps
writeProfile.WALAppendBytes = storageProfile.WALAppendBytes
writeProfile.WALAppendDurationNanos = storageProfile.WALAppendDurationNanos
writeProfile.WALAppendWriteAtCalls = storageProfile.WALAppendWriteAtCalls
writeProfile.WALAppendWriteAtBytes = storageProfile.WALAppendWriteAtBytes
writeProfile.WALAppendWriteAtMaxBytes = storageProfile.WALAppendWriteAtMaxBytes
writeProfile.WALAppendWrapCount = storageProfile.WALAppendWrapCount
writeProfile.WALAppendPaddingBytes = storageProfile.WALAppendPaddingBytes
writeProfile.DirtyMapUpdateOps = storageProfile.DirtyMapUpdateOps
writeProfile.DirtyMapUpdateDurationNanos = storageProfile.DirtyMapUpdateDurationNanos
}
@@ -31,6 +31,11 @@ type WriteProfileStatus struct {
WALAppendOps uint64
WALAppendBytes uint64
WALAppendDurationNanos uint64
WALAppendWriteAtCalls uint64
WALAppendWriteAtBytes uint64
WALAppendWriteAtMaxBytes uint64
WALAppendWrapCount uint64
WALAppendPaddingBytes uint64
DirtyMapUpdateOps uint64
DirtyMapUpdateDurationNanos uint64
BackendSyncOps uint64
+13 -2
View File
@@ -82,6 +82,9 @@ func (w *walWriter) append(entry *walEntry) (walRelOffset uint64, err error) {
if err := w.writePadding(remaining, physHead); err != nil {
return 0, fmt.Errorf("walWriter.append: padding: %w", err)
}
if w.instr != nil {
w.instr.recordWALAppendWrap(remaining)
}
w.logicalHead += remaining
physHead = 0
}
@@ -195,6 +198,9 @@ func (w *walWriter) appendBatch(entries []*walEntry) ([]uint64, error) {
if err := appendPendingBytes(physHead, padding); err != nil {
return offsets, err
}
if w.instr != nil {
w.instr.recordWALAppendWrap(remaining)
}
localHead += remaining
physHead = 0
}
@@ -263,8 +269,13 @@ func (w *walWriter) writePadding(size, physPos uint64) error {
if len(buf) == 0 {
return nil
}
_, err = w.fd.WriteAt(buf, int64(w.walOffset+physPos))
return err
if _, err := w.fd.WriteAt(buf, int64(w.walOffset+physPos)); err != nil {
return err
}
if w.instr != nil {
w.instr.recordWALAppendWriteAt(len(buf))
}
return nil
}
func encodeWALPadding(size uint64) ([]byte, error) {
@@ -20,6 +20,11 @@ type WriteInstrumentationStatus struct {
WALAppendOps uint64
WALAppendBytes uint64
WALAppendDurationNanos uint64
WALAppendWriteAtCalls uint64
WALAppendWriteAtBytes uint64
WALAppendWriteAtMaxBytes uint64
WALAppendWrapCount uint64
WALAppendPaddingBytes uint64
DirtyMapUpdateOps uint64
DirtyMapUpdateDurationNanos uint64
}
@@ -43,6 +48,11 @@ type writeInstrumentation struct {
walAppendOps atomic.Uint64
walAppendBytes atomic.Uint64
walAppendDurationNanos atomic.Uint64
walAppendWriteAtCalls atomic.Uint64
walAppendWriteAtBytes atomic.Uint64
walAppendWriteAtMaxBytes atomic.Uint64
walAppendWrapCount atomic.Uint64
walAppendPaddingBytes atomic.Uint64
dirtyMapUpdateOps atomic.Uint64
dirtyMapUpdateDurationNanos atomic.Uint64
}
@@ -88,6 +98,30 @@ func (i *writeInstrumentation) recordWALAppend(bytes int, d time.Duration) {
i.walAppendOps.Add(1)
i.walAppendBytes.Add(uint64(bytes))
i.walAppendDurationNanos.Add(storageDurationNanos(d))
i.recordWALAppendWriteAt(bytes)
}
func (i *writeInstrumentation) recordWALAppendWriteAt(bytes int) {
if i == nil || bytes <= 0 {
return
}
v := uint64(bytes)
i.walAppendWriteAtCalls.Add(1)
i.walAppendWriteAtBytes.Add(v)
for {
old := i.walAppendWriteAtMaxBytes.Load()
if v <= old || i.walAppendWriteAtMaxBytes.CompareAndSwap(old, v) {
return
}
}
}
func (i *writeInstrumentation) recordWALAppendWrap(paddingBytes uint64) {
if i == nil || paddingBytes == 0 {
return
}
i.walAppendWrapCount.Add(1)
i.walAppendPaddingBytes.Add(paddingBytes)
}
func (i *writeInstrumentation) recordDirtyMapUpdate(ops int, d time.Duration) {
@@ -115,6 +149,11 @@ func (i *writeInstrumentation) snapshot() WriteInstrumentationStatus {
WALAppendOps: i.walAppendOps.Load(),
WALAppendBytes: i.walAppendBytes.Load(),
WALAppendDurationNanos: i.walAppendDurationNanos.Load(),
WALAppendWriteAtCalls: i.walAppendWriteAtCalls.Load(),
WALAppendWriteAtBytes: i.walAppendWriteAtBytes.Load(),
WALAppendWriteAtMaxBytes: i.walAppendWriteAtMaxBytes.Load(),
WALAppendWrapCount: i.walAppendWrapCount.Load(),
WALAppendPaddingBytes: i.walAppendPaddingBytes.Load(),
DirtyMapUpdateOps: i.dirtyMapUpdateOps.Load(),
DirtyMapUpdateDurationNanos: i.dirtyMapUpdateDurationNanos.Load(),
}
@@ -79,6 +79,7 @@ The supported-lab claim is intentionally narrow:
| 135 | Post-batch write-path retriage and next-bottleneck classification | PASS |
| 136 | WAL append/copy/checksum profile and backend-internal bottleneck classification | PASS |
| 137 | WAL record encode/copy reduction and next append-shape bottleneck classification | PASS |
| 138 | WAL append write-at shape profile and small-write classification | PASS |
Key QA sign-offs:
@@ -100,6 +101,7 @@ Key QA sign-offs:
- `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`
- `internal/docs/qa-assignments/phase137-reduce-wal-record-encode-copy-qa-signoff.md`
- `internal/docs/qa-assignments/phase138-wal-writeat-shape-profile-qa-signoff.md`
## Performance Baseline
@@ -318,6 +320,26 @@ The next measured cost is WAL append/write-at shape. The product still makes no
published performance/SLO, RoCE, or NVMe/RDMA claim from this source-gated lab
evidence.
Phase 138 split that append/write-at shape:
```text
phase138_wal_writeat_shape_profile_status=ok
wal_append_duration_ms=380
wal_append_writeat_calls=17979
wal_append_writeat_bytes=593543918
wal_append_writeat_max_bytes=33072
wal_append_writeat_avg_bytes=33013
wal_append_wrap_count=8
wal_append_padding_bytes=13136
post_phase138_bottleneck=wal_append_small_writes
next_recommendation=phase139_wal_append_batch_shape_coalescing
cleanup_status=ok
```
The write-at shape is many small writes of about 33KB, with negligible
wrap/padding. This keeps the next work inside WAL batching/coalescing rather
than transport work.
Phase 127 closes the source/component side of the ANA Change Notice gap:
```text
+9
View File
@@ -777,6 +777,15 @@ Recommended order from here:
512MiB gate reduced `wal_encode + wal_copy` from the Phase 136 baseline
`1346ms` to `363ms`; the next named bottleneck is `wal_append`, so Phase
138 should inspect WAL pwrite shape/coalescing.
96. Phase 138: WAL WriteAt Shape Profile. **Closed 2026-07-05,
runner PASS**
Added product-owned append write-at shape counters:
calls/bytes/max/avg plus wrap count and padding bytes. The live 512MiB gate
showed `wal_append_writeat_calls=17979`,
`wal_append_writeat_avg_bytes=33013`, and
`wal_append_writeat_max_bytes=33072`, with only 8 wraps and 13KB padding.
The append bottleneck is therefore small-write/coalescing shape, not
wrap/padding or NVMe/RDMA.
The internal release-train contract is
`internal/docs/ref/operation-layer-v0.5-release-train.md`. Phases 41-44 close
+40 -41
View File
@@ -1,42 +1,39 @@
# Current Plan: Phase 138 WAL WriteAt Shape Profile
# Current Plan: Phase 139 WAL Append Batch Shape Coalescing
Status: planning.
Phase 137 reduced the WAL encode/copy seam and moved the backend-internal
bottleneck to append/write-at:
Phase 138 split the WAL append/write-at shape:
```text
phase137_reduce_wal_record_encode_copy_status=ok
phase138_wal_writeat_shape_profile_status=ok
target_write_observed=true
backend_write_bytes=588075008
backend_storage_batch_calls=17953
backend_storage_batch_blocks=143555
backend_storage_batching_effective=true
phase136_wal_encode_copy_duration_ms=1346
wal_encode_copy_duration_ms=363
wal_copy_duration_ms=93
wal_encode_duration_ms=270
wal_checksum_duration_ms=110
wal_append_duration_ms=375
dirty_map_update_duration_ms=74
post_phase137_bottleneck=wal_append
next_recommendation=phase138_wal_writeat_shape_profile
wal_append_duration_ms=380
wal_append_writeat_calls=17979
wal_append_writeat_bytes=593543918
wal_append_writeat_max_bytes=33072
wal_append_writeat_avg_bytes=33013
wal_append_wrap_count=8
wal_append_padding_bytes=13136
post_phase138_bottleneck=wal_append_small_writes
next_recommendation=phase139_wal_append_batch_shape_coalescing
cleanup_status=ok
```
This means the next useful work is still not NVMe/RDMA. It is to split WAL
append/write-at cost into pwrite count, coalesced write size, wrap/padding
behavior, and syscall/write latency.
This means the next useful work is still not NVMe/RDMA. The WAL writer is
issuing many small pwrite calls around 33KB; the next phase should explain or
improve the batch/coalescing shape feeding `walWriter.appendBatch`.
## Goal
```text
mounted NVMe/TCP write still reaches durable backend
-> backend batching remains active
-> WAL append/write-at shape is visible
-> pwrite count and bytes are visible
-> coalesced write size distribution is visible
-> wrap/padding behavior is visible
-> WAL append write-at average/max size improves or the upstream request shape is named
-> write-at calls per MiB decrease or are explained by frontend request shape
-> no WAL recovery semantics are weakened
-> next bottleneck is named from counters after the change
-> cleanup remains clean
@@ -45,7 +42,7 @@ mounted NVMe/TCP write still reaches durable backend
## Required Evidence
```text
phase138_wal_writeat_shape_profile_status=ok
phase139_wal_append_batch_shape_coalescing_status=ok
frontend_transport=tcp
roce_claim_allowed=false
nvme_rdma_claim_allowed=false
@@ -59,10 +56,11 @@ wal_append_writeat_calls=<count>
wal_append_writeat_bytes=<bytes>
wal_append_writeat_max_bytes=<bytes>
wal_append_writeat_avg_bytes=<bytes>
wal_append_wrap_count=<count>
wal_append_padding_bytes=<bytes>
phase137_wal_append_duration_ms=375
post_phase138_bottleneck=<wal_append_syscall|wal_append_small_writes|wal_wrap_padding|wal_encode|wal_checksum|dirty_map|unknown>
phase138_wal_append_writeat_avg_bytes=33013
phase138_wal_append_writeat_max_bytes=33072
phase138_wal_append_writeat_calls=17979
phase139_shape_result=<improved|frontend_request_limited|blocked>
post_phase139_bottleneck=<wal_append_small_writes|wal_append_syscall|wal_encode|wal_checksum|dirty_map|unknown>
next_recommendation=<specific next phase>
cleanup_status=ok
```
@@ -76,25 +74,26 @@ cleanup_status=ok
cuFile/cuObject, or NIXL.
- Do not weaken WAL recovery semantics: every write still needs an LSN and a
recoverable record.
- Keep this phase to append/write-at observation unless the instrumentation
itself exposes a trivial bug.
- Keep the scope inside WAL batch/coalescing shape and the upstream full-block
write run shape.
## Candidate Work
1. Add product counters around WAL append write-at shape:
write-at call count, total bytes, max bytes, average bytes.
2. Count circular-WAL wrap/padding events and padding bytes.
3. Keep the existing Phase 137 encode/copy counters so the new shape is
comparable.
4. Add a Phase 138 wrapper/scenario that reruns the Phase 137 profile and
classifies whether append cost is syscall count, small-write shape, wrap
behavior, or something else.
5. Do not optimize pwrite shape in this phase unless the counter insertion
exposes a one-line bug.
1. Inspect the upstream write request size reaching `StorageBackend.writeBytes`
and `WriteBatch`.
2. If the frontend/request shape only feeds 8 full blocks at a time, surface
that as the limiting shape instead of guessing in `walWriter`.
3. If the backend can safely coalesce multiple adjacent batches without
changing ack/recovery semantics, implement the smallest bounded coalescing
step and gate it.
4. Add a Phase 139 wrapper/scenario that compares write-at average/max size and
calls against Phase 138.
5. If coalescing is blocked by frontend request shape, close with an explicit
`frontend_request_limited` result and a concrete next phase.
## Exit Criteria
Phase 138 can close when the live supported-lab gate names the append/write-at
shape from product-owned counters and cleanup is clean. If pwrite shape is not
the reason append dominates, close with the measured distribution and a concrete
next experiment.
Phase 139 can close when the live supported-lab gate either improves the
write-at shape or proves the current 33KB shape is imposed by frontend request
size. The close report must name the next bottleneck from product-owned
counters and keep cleanup clean.
@@ -0,0 +1,70 @@
# Phase 138 Finished Plan: WAL WriteAt Shape Profile
Status: **closed 2026-07-05, live gate PASS**.
## Problem
Phase 137 reduced the WAL encode/copy seam and moved the dominant
backend-internal cost to WAL append/write-at. The product still did not expose
whether that cost came from syscall count, small coalesced write size, or
circular-WAL wrap/padding behavior.
## Work
Phase 138 added product-owned write-at shape counters to `/status/durable`:
- WAL append write-at call count.
- WAL append write-at bytes.
- WAL append write-at max bytes.
- Derived average write-at bytes.
- WAL wrap count.
- WAL padding bytes.
The phase did not optimize the write path. It only made the shape visible.
## Gate
Phase 138 added:
- `scripts/run-phase138-wal-writeat-shape-profile-gate.sh`
- `testops/scenarios/nvme-tcp-wal-writeat-shape-profile-chain.yaml`
The gate reruns the 512MiB mounted NVMe/TCP profile, requires active backend
batching, asserts the new write-at counters are populated, and classifies the
next bottleneck.
## Evidence
```text
phase138_wal_writeat_shape_profile_status=ok
target_write_observed=true
backend_write_bytes=588075008
backend_storage_batch_calls=17953
backend_storage_batch_blocks=143555
backend_storage_batching_effective=true
wal_append_duration_ms=380
wal_append_writeat_calls=17979
wal_append_writeat_bytes=593543918
wal_append_writeat_max_bytes=33072
wal_append_writeat_avg_bytes=33013
wal_append_wrap_count=8
wal_append_padding_bytes=13136
post_phase138_bottleneck=wal_append_small_writes
next_recommendation=phase139_wal_append_batch_shape_coalescing
cleanup_status=ok
```
Run bundle:
```text
results\20260705-153411-45ea
22 actions: 22 passed, 0 failed
```
## Conclusion
The measured shape is small coalesced writes: about 33KB average and max
write-at size, with negligible wrap/padding. Phase 139 should improve or
further explain the batch/coalescing shape that feeds the WAL writer. This is
still a source/lab profile, not a published performance, RoCE, or NVMe/RDMA
claim.
@@ -429,6 +429,12 @@ rebuild, delete safety, or cleanup must start as a separate gated phase.
was removed and batch append now encodes directly into the coalesced pending
buffer. The live gate reduced `wal_encode + wal_copy` from `1346ms` to
`363ms`; the next backend work should inspect WAL append/write-at shape.
- Phase 138 is closed for WAL append/write-at shape profiling. The live gate
showed the append path is issuing many small pwrite calls:
`wal_append_writeat_calls=17979`,
`wal_append_writeat_avg_bytes=33013`, and
`wal_append_writeat_max_bytes=33072`, while wrap/padding was negligible. The
next backend work should inspect batch/coalescing shape.
- 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
@@ -1046,6 +1052,8 @@ Approximate engineering effort if scope remains tight:
`wal_encode` / record-copy cost as the next backend step.
- Phase 137 is closed for WAL record encode/copy reduction and names
`wal_append` / write-at shape as the next backend step.
- Phase 138 is closed for WAL write-at shape profiling and names small
write/coalescing shape 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,78 @@
# Phase 138 WAL WriteAt Shape Profile QA Sign-Off
Verdict: **PASS**.
Validated source tree: local `phase138-wal-writeat-shape-profile` working tree,
synced to `m02:/tmp/seaweed_block` as clean `HEAD` plus Phase 138 overlay only.
The known unrelated dirty NVMe files were not copied into the lab tree.
Run:
```powershell
C:\work\swblock.exe run testops/scenarios/nvme-tcp-wal-writeat-shape-profile-chain.yaml `
-output results\phase138-wal-writeat-shape-run1.json `
-html results\phase138-wal-writeat-shape-run1.html
```
Run bundle:
```text
results\20260705-153411-45ea
22 actions: 22 passed, 0 failed
```
## Evidence
```text
phase138_wal_writeat_shape_profile_status=ok
frontend_transport=tcp
roce_claim_allowed=false
nvme_rdma_claim_allowed=false
performance_slo_claim_allowed=false
profile_size_mib=512
phase137_wal_append_duration_ms=375
unit_wal_writeat_shape_regression_passed=true
target_write_observed=true
target_write_bytes=588075008
backend_write_bytes=588075008
backend_storage_batch_calls=17953
backend_storage_batch_blocks=143555
backend_storage_batching_effective=true
wal_append_ops=17979
wal_append_bytes=593543918
wal_append_duration_ms=380
wal_append_writeat_calls=17979
wal_append_writeat_bytes=593543918
wal_append_writeat_max_bytes=33072
wal_append_writeat_avg_bytes=33013
wal_append_wrap_count=8
wal_append_padding_bytes=13136
wal_copy_duration_ms=96
wal_encode_duration_ms=275
wal_checksum_duration_ms=112
dirty_map_update_duration_ms=73
post_phase138_bottleneck=wal_append_small_writes
next_recommendation=phase139_wal_append_batch_shape_coalescing
cleanup_status=ok
```
## Finding
The append bottleneck is a small-write shape, not wrap/padding:
- `wal_append_writeat_calls=17979`.
- Average write-at size is only `33013` bytes.
- Max write-at size is only `33072` bytes.
- Wrap/padding happened only `8` times with `13136` bytes total padding.
The next phase should inspect and improve the batch/coalescing shape feeding the
WAL writer. This phase is observation only; it does not claim a performance SLO,
RoCE, or NVMe/RDMA.
## Cleanup
The gate reused the Phase 126 cleanup verifier and finished clean:
```text
cleanup_status=ok
```
@@ -208,6 +208,12 @@ wal_checksum_ns = int(field(profile, "WALChecksumDurationNanos", "walChecksumDur
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)
wal_append_writeat_calls = int(field(profile, "WALAppendWriteAtCalls", "walAppendWriteAtCalls", default=0) or 0)
wal_append_writeat_bytes = int(field(profile, "WALAppendWriteAtBytes", "walAppendWriteAtBytes", default=0) or 0)
wal_append_writeat_max_bytes = int(field(profile, "WALAppendWriteAtMaxBytes", "walAppendWriteAtMaxBytes", default=0) or 0)
wal_append_writeat_avg_bytes = int(wal_append_writeat_bytes / wal_append_writeat_calls) if wal_append_writeat_calls else 0
wal_append_wrap_count = int(field(profile, "WALAppendWrapCount", "walAppendWrapCount", default=0) or 0)
wal_append_padding_bytes = int(field(profile, "WALAppendPaddingBytes", "walAppendPaddingBytes", 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)
@@ -241,6 +247,12 @@ with open(summary_out, "w") as f:
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"wal_append_writeat_calls={wal_append_writeat_calls}\n")
f.write(f"wal_append_writeat_bytes={wal_append_writeat_bytes}\n")
f.write(f"wal_append_writeat_max_bytes={wal_append_writeat_max_bytes}\n")
f.write(f"wal_append_writeat_avg_bytes={wal_append_writeat_avg_bytes}\n")
f.write(f"wal_append_wrap_count={wal_append_wrap_count}\n")
f.write(f"wal_append_padding_bytes={wal_append_padding_bytes}\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")
@@ -143,6 +143,12 @@ WAL_CHECKSUM_MS="$(require_summary_value "${BLOCK_SUMMARY}" wal_checksum_duratio
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)"
WAL_APPEND_WRITEAT_CALLS="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_writeat_calls)"
WAL_APPEND_WRITEAT_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_writeat_bytes)"
WAL_APPEND_WRITEAT_MAX_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_writeat_max_bytes)"
WAL_APPEND_WRITEAT_AVG_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_writeat_avg_bytes)"
WAL_APPEND_WRAP_COUNT="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_wrap_count)"
WAL_APPEND_PADDING_BYTES="$(require_summary_value "${BLOCK_SUMMARY}" wal_append_padding_bytes)"
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)"
@@ -162,6 +168,10 @@ 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 "${WAL_APPEND_WRITEAT_CALLS}" 1 "wal_append_writeat_calls"
assert_int_ge "${WAL_APPEND_WRITEAT_BYTES}" 1 "wal_append_writeat_bytes"
assert_int_ge "${WAL_APPEND_WRITEAT_MAX_BYTES}" 1 "wal_append_writeat_max_bytes"
assert_int_ge "${WAL_APPEND_WRITEAT_AVG_BYTES}" 1 "wal_append_writeat_avg_bytes"
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}")"
@@ -197,6 +207,12 @@ 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 "wal_append_writeat_calls=${WAL_APPEND_WRITEAT_CALLS}"
write_summary "wal_append_writeat_bytes=${WAL_APPEND_WRITEAT_BYTES}"
write_summary "wal_append_writeat_max_bytes=${WAL_APPEND_WRITEAT_MAX_BYTES}"
write_summary "wal_append_writeat_avg_bytes=${WAL_APPEND_WRITEAT_AVG_BYTES}"
write_summary "wal_append_wrap_count=${WAL_APPEND_WRAP_COUNT}"
write_summary "wal_append_padding_bytes=${WAL_APPEND_PADDING_BYTES}"
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}"
@@ -0,0 +1,189 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="${1:-$(pwd)}"
ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${ROOT}/results/phase138-wal-writeat-shape-profile-gate}"
SUMMARY="${ARTIFACT_DIR}/phase138-wal-writeat-shape-profile-summary.txt"
PHASE126_DIR="${ARTIFACT_DIR}/phase126-profile"
SEQ_MIB="${SW_BLOCK_PHASE138_SEQ_MIB:-512}"
PHASE137_WAL_APPEND_MS="${SW_BLOCK_PHASE137_WAL_APPEND_MS:-375}"
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_writeat_shape() {
python3 - "$@" <<'PY'
import sys
calls = int(sys.argv[1])
avg_bytes = int(sys.argv[2])
wraps = int(sys.argv[3])
padding = int(sys.argv[4])
append_ms = int(sys.argv[5])
if append_ms <= 0:
print("unknown")
elif wraps > 0 and padding > 0 and avg_bytes >= 65536:
print("wal_wrap_padding")
elif avg_bytes > 0 and avg_bytes < 65536:
print("wal_append_small_writes")
elif calls > 0:
print("wal_append_syscall")
else:
print("unknown")
PY
}
recommendation_for_shape() {
case "$1" in
wal_append_small_writes)
printf '%s' "phase139_wal_append_batch_shape_coalescing"
;;
wal_append_syscall)
printf '%s' "phase139_wal_append_syscall_latency_profile"
;;
wal_wrap_padding)
printf '%s' "phase139_wal_wrap_padding_reduction"
;;
wal_encode)
printf '%s' "phase139_wal_encode_allocation_profile"
;;
wal_checksum)
printf '%s' "phase139_checksum_strategy_profile"
;;
dirty_map)
printf '%s' "phase139_dirty_map_update_profile"
;;
*)
printf '%s' "phase139_deeper_backend_trace"
;;
esac
}
write_summary "phase138_wal_writeat_shape_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}"
write_summary "phase137_wal_append_duration_ms=${PHASE137_WAL_APPEND_MS}"
cd "${ROOT}"
go test ./core/storage ./core/frontend/durable \
>"${ARTIFACT_DIR}/go-test-storage-durable.log" \
2>&1
write_summary "unit_wal_writeat_shape_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_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)"
WAL_APPEND_WRITEAT_CALLS="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_writeat_calls)"
WAL_APPEND_WRITEAT_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_writeat_bytes)"
WAL_APPEND_WRITEAT_MAX_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_writeat_max_bytes)"
WAL_APPEND_WRITEAT_AVG_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_writeat_avg_bytes)"
WAL_APPEND_WRAP_COUNT="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_wrap_count)"
WAL_APPEND_PADDING_BYTES="$(require_summary_value "${PHASE126_SUMMARY}" wal_append_padding_bytes)"
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_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 "${WAL_APPEND_WRITEAT_CALLS}" 1 "wal_append_writeat_calls"
assert_int_ge "${WAL_APPEND_WRITEAT_BYTES}" 1 "wal_append_writeat_bytes"
assert_int_ge "${WAL_APPEND_WRITEAT_MAX_BYTES}" 1 "wal_append_writeat_max_bytes"
assert_int_ge "${WAL_APPEND_WRITEAT_AVG_BYTES}" 1 "wal_append_writeat_avg_bytes"
if [[ "${CLEANUP_STATUS}" != "ok" ]]; then
echo "cleanup_status=${CLEANUP_STATUS}, want ok" >&2
exit 1
fi
POST_PHASE138_BOTTLENECK="$(classify_writeat_shape "${WAL_APPEND_WRITEAT_CALLS}" "${WAL_APPEND_WRITEAT_AVG_BYTES}" "${WAL_APPEND_WRAP_COUNT}" "${WAL_APPEND_PADDING_BYTES}" "${WAL_APPEND_MS}")"
NEXT_RECOMMENDATION="$(recommendation_for_shape "${POST_PHASE138_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 \
wal_append_writeat_calls \
wal_append_writeat_bytes \
wal_append_writeat_max_bytes \
wal_append_writeat_avg_bytes \
wal_append_wrap_count \
wal_append_padding_bytes \
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_phase138_bottleneck=${POST_PHASE138_BOTTLENECK}"
write_summary "next_recommendation=${NEXT_RECOMMENDATION}"
write_summary "cleanup_status=${CLEANUP_STATUS}"
write_summary "phase138_wal_writeat_shape_profile_status=ok"
@@ -0,0 +1,119 @@
name: nvme-tcp-wal-writeat-shape-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 }}-phase138-wal-writeat-shape && mkdir -p /mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase138-wal-writeat-shape"
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 }}-phase138-wal-writeat-shape SW_BLOCK_PHASE138_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-phase138-wal-writeat-shape-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 }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-profile-summary.txt"
pattern: "^phase138_wal_writeat_shape_profile_status=ok$"
save_as: phase138_status_ok
- action: assert_greater
actual: "{{ phase138_status_ok }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-profile-summary.txt"
pattern: "^unit_wal_writeat_shape_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 }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-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 }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-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 }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-profile-summary.txt"
pattern: "^wal_append_writeat_calls=[1-9][0-9]*$"
save_as: writeat_calls
- action: assert_greater
actual: "{{ writeat_calls }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-profile-summary.txt"
pattern: "^wal_append_writeat_max_bytes=[1-9][0-9]*$"
save_as: writeat_max
- action: assert_greater
actual: "{{ writeat_max }}"
threshold: "0"
- action: grep_log
node: m02
path: "/mnt/smb/work/share/g15d-k8s/{{ run_id }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-profile-summary.txt"
pattern: "^post_phase138_bottleneck=\\(wal_append_syscall\\|wal_append_small_writes\\|wal_wrap_padding\\|wal_encode\\|wal_checksum\\|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 }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-profile-summary.txt"
pattern: "^next_recommendation=phase139_"
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 }}-phase138-wal-writeat-shape/phase138-wal-writeat-shape-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 }}-phase138-wal-writeat-shape"
name: "remote-phases"
ignore_error: true