From 96ab45bea5e2fd17fa0f54a0e26edab8e8f03b17 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Mon, 6 Jul 2026 16:04:13 -0700 Subject: [PATCH] phase149: profile multiblock wal record count --- .../walstore_multiblock_profile_test.go | 82 +++++++++++++++++ .../docs/releases/nvme-tcp-supported-lab.md | 23 +++++ seaweed-block/docs/roadmap.md | 4 +- seaweed-block/internal/docs/current-plan.md | 60 ++++++------ ...ishedplan_wal_multiblock_record_profile.md | 43 +++++++++ .../internal/docs/product-roadmap.md | 4 + ...al-multiblock-record-profile-qa-signoff.md | 80 ++++++++++++++++ ...e149-wal-multiblock-record-profile-gate.sh | 91 +++++++++++++++++++ 8 files changed, 357 insertions(+), 30 deletions(-) create mode 100644 seaweed-block/core/storage/walstore_multiblock_profile_test.go create mode 100644 seaweed-block/internal/docs/finished-plans/phase149_finishedplan_wal_multiblock_record_profile.md create mode 100644 seaweed-block/internal/docs/qa-assignments/phase149-wal-multiblock-record-profile-qa-signoff.md create mode 100644 seaweed-block/scripts/run-phase149-wal-multiblock-record-profile-gate.sh diff --git a/seaweed-block/core/storage/walstore_multiblock_profile_test.go b/seaweed-block/core/storage/walstore_multiblock_profile_test.go new file mode 100644 index 0000000000..c0887fba00 --- /dev/null +++ b/seaweed-block/core/storage/walstore_multiblock_profile_test.go @@ -0,0 +1,82 @@ +package storage + +import ( + "bytes" + "path/filepath" + "testing" +) + +func TestWALStore_MultiBlockProfile_RecordCountReduction(t *testing.T) { + const ( + numBlocks = 4096 + blockSize = 4096 + batches = 128 + blocksPerBatch = 16 + ) + + type profile struct { + instr WriteInstrumentationStatus + } + + run := func(t *testing.T, multiblock bool) profile { + t.Helper() + path := filepath.Join(t.TempDir(), "store.bin") + s, err := CreateWALStore(path, numBlocks, blockSize) + if err != nil { + t.Fatalf("CreateWALStore: %v", err) + } + defer s.Close() + s.flusher.Stop() + s.enableMultiBlockRecordsForTest(multiblock) + + var lastBlocks [][]byte + var lastStart uint32 + for b := 0; b < batches; b++ { + start := uint32(b * blocksPerBatch) + blocks := make([][]byte, blocksPerBatch) + for i := range blocks { + blocks[i] = makeBlock(blockSize, byte((b+i)%251+1)) + } + if _, err := s.WriteBatch(start, blocks); err != nil { + t.Fatalf("WriteBatch multiblock=%v batch=%d: %v", multiblock, b, err) + } + lastBlocks = blocks + lastStart = start + } + for i, want := range lastBlocks { + got, err := s.Read(lastStart + uint32(i)) + if err != nil { + t.Fatalf("Read multiblock=%v block=%d: %v", multiblock, i, err) + } + if !bytes.Equal(got, want) { + t.Fatalf("Read multiblock=%v block=%d mismatch", multiblock, i) + } + } + return profile{instr: s.WriteInstrumentation()} + } + + single := run(t, false) + multi := run(t, true) + + t.Logf("phase149_single_block_wal_encode_ops=%d", single.instr.WALEncodeOps) + t.Logf("phase149_multiblock_wal_encode_ops=%d", multi.instr.WALEncodeOps) + t.Logf("phase149_single_block_wal_append_ops=%d", single.instr.WALAppendOps) + t.Logf("phase149_multiblock_wal_append_ops=%d", multi.instr.WALAppendOps) + t.Logf("phase149_single_block_wal_writeat_calls=%d", single.instr.WALAppendWriteAtCalls) + t.Logf("phase149_multiblock_wal_writeat_calls=%d", multi.instr.WALAppendWriteAtCalls) + + if single.instr.WALEncodeOps == 0 || multi.instr.WALEncodeOps == 0 { + t.Fatalf("missing encode ops: single=%d multi=%d", single.instr.WALEncodeOps, multi.instr.WALEncodeOps) + } + if multi.instr.WALEncodeOps >= single.instr.WALEncodeOps { + t.Fatalf("multi-block encode ops=%d, want < single=%d", multi.instr.WALEncodeOps, single.instr.WALEncodeOps) + } + expectedMulti := uint64(batches) + if multi.instr.WALEncodeOps != expectedMulti { + t.Fatalf("multi-block encode ops=%d want %d", multi.instr.WALEncodeOps, expectedMulti) + } + expectedSingle := uint64(batches * blocksPerBatch) + if single.instr.WALEncodeOps != expectedSingle { + t.Fatalf("single-block encode ops=%d want %d", single.instr.WALEncodeOps, expectedSingle) + } +} diff --git a/seaweed-block/docs/releases/nvme-tcp-supported-lab.md b/seaweed-block/docs/releases/nvme-tcp-supported-lab.md index ce9502f3f6..90c0c3c7d9 100644 --- a/seaweed-block/docs/releases/nvme-tcp-supported-lab.md +++ b/seaweed-block/docs/releases/nvme-tcp-supported-lab.md @@ -90,6 +90,7 @@ The supported-lab claim is intentionally narrow: | 146 | WAL materialization effectiveness profile | PASS | | 147 | WAL multi-block record design gate | PASS | | 148 | WAL multi-block record local prototype | PASS | +| 149 | WAL multi-block record local profile | PASS | Key QA sign-offs: @@ -122,6 +123,7 @@ Key QA sign-offs: - `internal/docs/qa-assignments/phase146-wal-record-materialization-effectiveness-qa-signoff.md` - `internal/docs/qa-assignments/phase147-wal-multiblock-record-design-qa-signoff.md` - `internal/docs/qa-assignments/phase148-wal-multiblock-record-local-prototype-qa-signoff.md` +- `internal/docs/qa-assignments/phase149-wal-multiblock-record-profile-qa-signoff.md` ## Performance Baseline @@ -562,6 +564,27 @@ cleanup_status=ok This is not wired to Kubernetes and not enabled by default. +Phase 149 profiled the local prototype: + +```text +phase149_wal_multiblock_record_profile_status=ok +profile_scope=local_storage +single_block_wal_encode_ops=2048 +multiblock_wal_encode_ops=128 +single_block_wal_append_ops=128 +multiblock_wal_append_ops=128 +single_block_wal_writeat_calls=128 +multiblock_wal_writeat_calls=128 +record_count_reduction_visible=true +phase149_decision=wire_runtime_opt_in +next_recommendation=phase150_wal_multiblock_runtime_opt_in +cleanup_status=ok +``` + +This confirms the prototype reduces record/encode count in local storage, while +write-at call count is unchanged. A mounted NVMe/TCP profile is still required +before any user-facing performance statement. + Phase 127 closes the source/component side of the ANA Change Notice gap: ```text diff --git a/seaweed-block/docs/roadmap.md b/seaweed-block/docs/roadmap.md index 75228090d5..1e9939aea5 100644 --- a/seaweed-block/docs/roadmap.md +++ b/seaweed-block/docs/roadmap.md @@ -117,7 +117,9 @@ Seaweed Block can already demonstrate a narrow Kubernetes block-storage loop: record prototype. The current WAL format remains unchanged until local encode/decode, dirty-read, recovery-split, and flusher-split tests pass. Phase 148 closes that local correctness gate; the next step is profiling - record-count reduction before any runtime or Kubernetes opt-in. + record-count reduction before any runtime or Kubernetes opt-in. Phase 149 + proves that reduction locally (`2048` encode ops to `128`) and keeps the next + step bounded to a disabled-by-default runtime opt-in. - Kubernetes NVMe/TCP mounted reconnect is source-gated through changed desired path-set evidence: CSI-node can connect a newly published desired NVMe path, prune the stale old host path for the same NQN, preserve pod diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 944e0f3ed0..4ab075512d 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -1,49 +1,51 @@ -# Current Plan: Phase 149 WAL Multi-Block Record Profile Gate +# Current Plan: Phase 150 WAL Multi-Block Runtime Opt-In Status: planning. -Phase 148 closed the local multi-block WAL record prototype: +Phase 149 closed the local multi-block WAL profile gate: ```text -phase148_wal_multiblock_record_local_prototype_status=ok +phase149_wal_multiblock_record_profile_status=ok default_wal_format_unchanged=true feature_gate_default=false -multiblock_encode_decode=pass -multiblock_dirty_read=pass -multiblock_recovery_split=pass -multiblock_flusher_split=pass single_block_compatibility=pass current_recovery_compatibility=pass -phase148_decision=profile_next -next_recommendation=phase149_wal_multiblock_record_profile_gate +profile_scope=local_storage +single_block_wal_encode_ops=2048 +multiblock_wal_encode_ops=128 +single_block_wal_append_ops=128 +multiblock_wal_append_ops=128 +single_block_wal_writeat_calls=128 +multiblock_wal_writeat_calls=128 +record_count_reduction_visible=true +phase149_decision=wire_runtime_opt_in +next_recommendation=phase150_wal_multiblock_runtime_opt_in cleanup_status=ok ``` ## Goal -Profile the multi-block WAL prototype under a controlled opt-in and decide -whether it is worth wiring into a mounted NVMe/TCP lab gate. The default path -must remain single-block WAL records. +Wire the multi-block WAL record prototype as an explicit disabled-by-default +runtime opt-in so a later mounted NVMe/TCP profile can exercise it. The default +path must remain single-block WAL records. ## Required Evidence ```text -phase149_wal_multiblock_record_profile_status=ok +phase150_wal_multiblock_runtime_opt_in_status=ok frontend_transport=tcp roce_claim_allowed=false nvme_rdma_claim_allowed=false performance_slo_claim_allowed=false default_wal_format_unchanged=true feature_gate_default=false +runtime_opt_in_name= +runtime_opt_in_default=false +helm_default_omits_opt_in=true +explicit_opt_in_reaches_walstore=true single_block_compatibility=pass current_recovery_compatibility=pass -profile_scope= -single_block_wal_encode_ops= -multiblock_wal_encode_ops= -record_count_reduction_visible= -dirty_read_verified=true -recovery_verified=true -phase149_decision= +phase150_decision= next_recommendation= cleanup_status=ok ``` @@ -53,18 +55,18 @@ cleanup_status=ok - Do not enable multi-block records by default. - Do not claim throughput/SLO from this phase. - Do not raise the default H2C size. -- If this phase stays local-storage only, do not imply mounted NVMe/TCP - improvement. +- Do not treat the opt-in as release-supported until a mounted NVMe/TCP gate + passes. ## Candidate Work -1. Add a local storage profile comparing single-block and multi-block record - counts for the same contiguous WriteBatch workload. -2. Keep correctness checks in the same gate: dirty read and recovery must pass. -3. If the record-count reduction is clear, recommend a runtime opt-in wiring - phase. If not, defer the prototype. +1. Add a WALStore option field and plumb it from durable/blockvolume only behind + an explicit flag or config. +2. Keep default Helm/render path unchanged. +3. Add tests proving default false and explicit opt-in true. +4. Keep all Phase 148 correctness and compatibility tests green. ## Exit Criteria -Phase 149 can close when it either justifies wiring a runtime opt-in for mounted -NVMe/TCP profiling, or defers multi-block records with concrete evidence. +Phase 150 can close when the runtime opt-in is wired and default-off, with no +public performance claim. Phase 151 should run the mounted NVMe/TCP profile. diff --git a/seaweed-block/internal/docs/finished-plans/phase149_finishedplan_wal_multiblock_record_profile.md b/seaweed-block/internal/docs/finished-plans/phase149_finishedplan_wal_multiblock_record_profile.md new file mode 100644 index 0000000000..c9275fce46 --- /dev/null +++ b/seaweed-block/internal/docs/finished-plans/phase149_finishedplan_wal_multiblock_record_profile.md @@ -0,0 +1,43 @@ +# Phase 149 Finished Plan: WAL Multi-Block Record Profile Gate + +Status: **closed 2026-07-06, local gate PASS**. + +## Problem + +Phase 148 proved the multi-block WAL record prototype locally, but it still +needed evidence that the prototype attacks a real structural cost before wiring +any runtime opt-in. + +## Work + +Phase 149 added: + +- `core/storage/walstore_multiblock_profile_test.go`; +- `scripts/run-phase149-wal-multiblock-record-profile-gate.sh`. + +The gate compares default single-block WAL records against opt-in multi-block +records for the same contiguous WriteBatch workload. + +## Evidence + +```text +phase149_wal_multiblock_record_profile_status=ok +profile_scope=local_storage +single_block_wal_encode_ops=2048 +multiblock_wal_encode_ops=128 +single_block_wal_append_ops=128 +multiblock_wal_append_ops=128 +single_block_wal_writeat_calls=128 +multiblock_wal_writeat_calls=128 +record_count_reduction_visible=true +phase149_decision=wire_runtime_opt_in +next_recommendation=phase150_wal_multiblock_runtime_opt_in +cleanup_status=ok +``` + +## Conclusion + +The record-count reduction is visible locally. Because write-at calls are +unchanged, the next phase should only wire a disabled-by-default runtime opt-in +for mounted NVMe/TCP profiling. This is still not a performance/SLO or default +behavior claim. diff --git a/seaweed-block/internal/docs/product-roadmap.md b/seaweed-block/internal/docs/product-roadmap.md index 18e33ffc5e..e8c02ceab5 100644 --- a/seaweed-block/internal/docs/product-roadmap.md +++ b/seaweed-block/internal/docs/product-roadmap.md @@ -488,6 +488,10 @@ rebuild, delete safety, or cleanup must start as a separate gated phase. flusher-split, and `ScanLBAs` coverage. It is not wired into Kubernetes or the default blockvolume path; Phase 149 must profile record-count reduction before runtime opt-in wiring. +- Phase 149 is closed for the local profile. The same WriteBatch workload drops + WAL encode ops from `2048` to `128`, while append/write-at calls remain `128`. + This justifies wiring a disabled-by-default runtime opt-in for mounted NVMe/TCP + profiling, but it is still not a performance/SLO claim. - 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 diff --git a/seaweed-block/internal/docs/qa-assignments/phase149-wal-multiblock-record-profile-qa-signoff.md b/seaweed-block/internal/docs/qa-assignments/phase149-wal-multiblock-record-profile-qa-signoff.md new file mode 100644 index 0000000000..6e62501897 --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase149-wal-multiblock-record-profile-qa-signoff.md @@ -0,0 +1,80 @@ +# Phase 149 QA Sign-off: WAL Multi-Block Record Profile Gate + +Status: **PASS**. + +Branch: `phase149-wal-multiblock-record-profile-gate`. + +## Scope + +Phase 149 profiles the Phase 148 local multi-block WAL prototype. It does not +wire the feature into blockvolume/Kubernetes, does not change defaults, and does +not claim mounted NVMe/TCP performance. + +## Checks + +```text +bash -n scripts/run-phase149-wal-multiblock-record-profile-gate.sh +bash scripts/run-phase149-wal-multiblock-record-profile-gate.sh +go test ./core/storage -run TestWALStore_MultiBlockProfile_RecordCountReduction -count=1 -v +go test ./core/storage ./core/frontend/durable -count=1 +``` + +Result: + +```text +ok github.com/seaweedfs/seaweed-block/core/storage +ok github.com/seaweedfs/seaweed-block/core/frontend/durable +``` + +## Summary + +```text +phase149_wal_multiblock_record_profile_status=ok +frontend_transport=tcp +roce_claim_allowed=false +nvme_rdma_claim_allowed=false +performance_slo_claim_allowed=false +default_wal_format_unchanged=true +feature_gate_default=false +single_block_compatibility=pass +current_recovery_compatibility=pass +profile_scope=local_storage +single_block_wal_encode_ops=2048 +multiblock_wal_encode_ops=128 +single_block_wal_append_ops=128 +multiblock_wal_append_ops=128 +single_block_wal_writeat_calls=128 +multiblock_wal_writeat_calls=128 +record_count_reduction_visible=true +dirty_read_verified=true +recovery_verified=true +phase149_decision=wire_runtime_opt_in +next_recommendation=phase150_wal_multiblock_runtime_opt_in +cleanup_status=ok +``` + +## Interpretation + +The prototype reduces WAL encode record count for the tested contiguous +WriteBatch workload: + +```text +single-block encode ops: 2048 +multi-block encode ops: 128 +``` + +Append/write-at calls are unchanged: + +```text +single-block write-at calls: 128 +multi-block write-at calls: 128 +``` + +This confirms the Phase 147 hypothesis: multi-block records target per-record +encode/checksum/recovery overhead, not pwrite call count. + +## Verdict + +Phase 149 passes. The next phase may wire an explicit disabled-by-default +runtime opt-in so the prototype can be profiled under mounted NVMe/TCP. Do not +enable by default or make a performance/SLO claim. diff --git a/seaweed-block/scripts/run-phase149-wal-multiblock-record-profile-gate.sh b/seaweed-block/scripts/run-phase149-wal-multiblock-record-profile-gate.sh new file mode 100644 index 0000000000..f274d4f5d3 --- /dev/null +++ b/seaweed-block/scripts/run-phase149-wal-multiblock-record-profile-gate.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${ROOT}/results/phase149-wal-multiblock-record-profile-gate}" +SUMMARY="${ARTIFACT_DIR}/phase149-wal-multiblock-record-profile-summary.txt" +if [[ -n "${SW_BLOCK_GO_BIN:-}" ]]; then + GO_BIN="${SW_BLOCK_GO_BIN}" +elif command -v go.exe >/dev/null 2>&1; then + GO_BIN="go.exe" +else + GO_BIN="go" +fi + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +extract_log_value() { + local file="$1" + local key="$2" + awk -F= -v key="$key" '$0 ~ key"=" {value=$2} END {gsub(/[^0-9].*/, "", value); if (value != "") print value}' "$file" +} + +require_log_value() { + local file="$1" + local key="$2" + local value + value="$(extract_log_value "$file" "$key")" + if [[ -z "${value}" ]]; then + echo "missing ${key} in ${file}" >&2 + exit 1 + fi + printf '%s' "${value}" +} + +write_summary "phase149_wal_multiblock_record_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 "default_wal_format_unchanged=true" +write_summary "feature_gate_default=false" + +cd "${ROOT}" +"${GO_BIN}" test ./core/storage -run 'TestWALStore_MultiBlock(Profile|DirtyRead|RecoverSplits|FlusherSplits)' -count=1 -v \ + >"${ARTIFACT_DIR}/go-test-multiblock-profile.log" \ + 2>&1 + +SINGLE_ENCODE_OPS="$(require_log_value "${ARTIFACT_DIR}/go-test-multiblock-profile.log" phase149_single_block_wal_encode_ops)" +MULTI_ENCODE_OPS="$(require_log_value "${ARTIFACT_DIR}/go-test-multiblock-profile.log" phase149_multiblock_wal_encode_ops)" +SINGLE_APPEND_OPS="$(require_log_value "${ARTIFACT_DIR}/go-test-multiblock-profile.log" phase149_single_block_wal_append_ops)" +MULTI_APPEND_OPS="$(require_log_value "${ARTIFACT_DIR}/go-test-multiblock-profile.log" phase149_multiblock_wal_append_ops)" +SINGLE_WRITEAT_CALLS="$(require_log_value "${ARTIFACT_DIR}/go-test-multiblock-profile.log" phase149_single_block_wal_writeat_calls)" +MULTI_WRITEAT_CALLS="$(require_log_value "${ARTIFACT_DIR}/go-test-multiblock-profile.log" phase149_multiblock_wal_writeat_calls)" + +"${GO_BIN}" test ./core/storage ./core/frontend/durable -count=1 \ + >"${ARTIFACT_DIR}/go-test-compatibility.log" \ + 2>&1 + +python3 - "$SINGLE_ENCODE_OPS" "$MULTI_ENCODE_OPS" <<'PY' >"${ARTIFACT_DIR}/record-count-visible.txt" +import sys +single = int(sys.argv[1]) +multi = int(sys.argv[2]) +print(str(multi > 0 and single >= multi * 4).lower()) +PY +RECORD_COUNT_VISIBLE="$(cat "${ARTIFACT_DIR}/record-count-visible.txt")" +if [[ "${RECORD_COUNT_VISIBLE}" != "true" ]]; then + echo "record_count_reduction_visible=${RECORD_COUNT_VISIBLE}, want true" >&2 + exit 1 +fi + +write_summary "single_block_compatibility=pass" +write_summary "current_recovery_compatibility=pass" +write_summary "profile_scope=local_storage" +write_summary "single_block_wal_encode_ops=${SINGLE_ENCODE_OPS}" +write_summary "multiblock_wal_encode_ops=${MULTI_ENCODE_OPS}" +write_summary "single_block_wal_append_ops=${SINGLE_APPEND_OPS}" +write_summary "multiblock_wal_append_ops=${MULTI_APPEND_OPS}" +write_summary "single_block_wal_writeat_calls=${SINGLE_WRITEAT_CALLS}" +write_summary "multiblock_wal_writeat_calls=${MULTI_WRITEAT_CALLS}" +write_summary "record_count_reduction_visible=${RECORD_COUNT_VISIBLE}" +write_summary "dirty_read_verified=true" +write_summary "recovery_verified=true" +write_summary "phase149_decision=wire_runtime_opt_in" +write_summary "next_recommendation=phase150_wal_multiblock_runtime_opt_in" +write_summary "cleanup_status=ok" +write_summary "phase149_wal_multiblock_record_profile_status=ok"