diff --git a/seaweed-block/core/storage/walstore_fixed_work_test.go b/seaweed-block/core/storage/walstore_fixed_work_test.go index 79379b95d9..b4597a9274 100644 --- a/seaweed-block/core/storage/walstore_fixed_work_test.go +++ b/seaweed-block/core/storage/walstore_fixed_work_test.go @@ -61,6 +61,11 @@ type phase173FixedWorkResult struct { FinalSyncNanos int64 `json:"final_sync_ns"` FinalDrainNanos int64 `json:"final_drain_ns"` FinalSyncCalls uint64 `json:"final_sync_calls"` + MeasuredAllocBytes uint64 `json:"measured_alloc_bytes"` + MeasuredMallocs uint64 `json:"measured_mallocs"` + MeasuredFrees uint64 `json:"measured_frees"` + MeasuredHeapAllocStart uint64 `json:"measured_heap_alloc_start"` + MeasuredHeapAllocEnd uint64 `json:"measured_heap_alloc_end"` SyncedLSN uint64 `json:"synced_lsn"` CheckpointLSN uint64 `json:"checkpoint_lsn"` HeadLSN uint64 `json:"head_lsn"` @@ -403,6 +408,8 @@ func runPhase173FixedWork( _ = stopProfiles() } }() + var memoryBefore runtime.MemStats + runtime.ReadMemStats(&memoryBefore) foreground, latencies, err := runPhase173Operations(s, cfg, cfg.APIOperations, 0, payloads, true) if err != nil { return phase173FixedWorkResult{}, fmt.Errorf("phase173 foreground: %w", err) @@ -418,6 +425,8 @@ func runPhase173FixedWork( return phase173FixedWorkResult{}, fmt.Errorf("phase173 final drain: %w", err) } finalDrain := time.Since(drainStart) + var memoryAfter runtime.MemStats + runtime.ReadMemStats(&memoryAfter) if profilesActive { if err := stopProfiles(); err != nil { return phase173FixedWorkResult{}, err @@ -501,6 +510,11 @@ func runPhase173FixedWork( FinalSyncNanos: finalSync.Nanoseconds(), FinalDrainNanos: finalDrain.Nanoseconds(), FinalSyncCalls: s.syncs.Load() - syncBefore, + MeasuredAllocBytes: memoryAfter.TotalAlloc - memoryBefore.TotalAlloc, + MeasuredMallocs: memoryAfter.Mallocs - memoryBefore.Mallocs, + MeasuredFrees: memoryAfter.Frees - memoryBefore.Frees, + MeasuredHeapAllocStart: memoryBefore.HeapAlloc, + MeasuredHeapAllocEnd: memoryAfter.HeapAlloc, SyncedLSN: syncedLSN, CheckpointLSN: checkpointLSN, HeadLSN: headLSN, diff --git a/seaweed-block/internal/docs/qa-assignments/phase173-d2-shipped-path-attribution-qa.md b/seaweed-block/internal/docs/qa-assignments/phase173-d2-shipped-path-attribution-qa.md index c9e9167fe1..2cf9da840e 100644 --- a/seaweed-block/internal/docs/qa-assignments/phase173-d2-shipped-path-attribution-qa.md +++ b/seaweed-block/internal/docs/qa-assignments/phase173-d2-shipped-path-attribution-qa.md @@ -39,7 +39,10 @@ signals sent to those root-owned tools. The gate does not need Kubernetes. - `strace_product_counter_reconciliation=true` - `perf_scope_exact=true` - `perf_required_events_present=true` -- `profile_scope_exact=true` +- `cpu_profile_scope_exact=true` +- `memory_delta_scope_exact=true` +- `heap_profile_scope=post_window_after_gc` +- `allocs_profile_scope=process_cumulative_reference` - `iostat_device_observed=true` - `checkpoint_frontiers_equal=true` - `complete_drain=true` @@ -65,6 +68,12 @@ and correctness reads, detaches the tool, and only then permits `Close`. Store create/recover/warmup and final-close metadata I/O are therefore outside the exact attribution window. +The CPU profile and memory counter deltas cover foreground work through final +drain. The heap profile is taken after that window and a forced GC. Go's allocs +profile is process-cumulative, so it is retained only as a function-level +reference and is not labeled exact; the `measured_alloc_*` JSON and summary +fields are the exact-window allocation evidence. + ## Verdict - `PASS`: all product counters reconcile across the four independent runs, diff --git a/seaweed-block/scripts/run-phase173-shipped-path-attribution-gate.sh b/seaweed-block/scripts/run-phase173-shipped-path-attribution-gate.sh index 3a2b73a9bb..8dd2b0bb64 100644 --- a/seaweed-block/scripts/run-phase173-shipped-path-attribution-gate.sh +++ b/seaweed-block/scripts/run-phase173-shipped-path-attribution-gate.sh @@ -141,7 +141,8 @@ write_summary "contract=phase173-fixed-work-v1" write_summary "scope=walstore_engine_checkpoint_path" write_summary "shape=${SHAPE}" write_summary "writers=${WRITERS}" -write_summary "measurement_window=post_warmup_foreground_through_final_drain_and_correctness" +write_summary "counter_window=post_warmup_foreground_through_final_drain" +write_summary "trace_window=post_warmup_foreground_through_final_drain_and_correctness" write_summary "architecture_candidate_selected=false" write_summary "optimization_code_present=false" @@ -183,7 +184,7 @@ run_fixed_work "d2-precondition" "${precondition_log}" extract_result "${precondition_log}" "${ARTIFACT_DIR}/precondition-result.json" sync -iostat -xz 1 3 >"${ARTIFACT_DIR}/iostat.txt" 2>&1 & +iostat -xyz 1 3 >"${ARTIFACT_DIR}/iostat.txt" 2>&1 & iostat_pid=$! sleep 0.2 plain_log="${ARTIFACT_DIR}/logs/plain.log" @@ -209,7 +210,10 @@ done write_summary "cpu_profile=profiles/measured/cpu.pprof" write_summary "heap_profile=profiles/measured/heap.pprof" write_summary "allocs_profile=profiles/measured/allocs.pprof" -write_summary "profile_scope_exact=true" +write_summary "cpu_profile_scope_exact=true" +write_summary "memory_delta_scope_exact=true" +write_summary "heap_profile_scope=post_window_after_gc" +write_summary "allocs_profile_scope=process_cumulative_reference" strace_control="${ARTIFACT_DIR}/control/strace" strace_log="${ARTIFACT_DIR}/logs/strace.log" @@ -306,6 +310,8 @@ for row in rows: raise SystemExit(f"checkpoint write/sync accounting failed: {row}") if row["extent_sync_ops"] != row["flush_cycles"]: raise SystemExit(f"extent sync/cycle accounting failed: {row}") + if row["measured_alloc_bytes"] <= 0 or row["measured_mallocs"] <= 0: + raise SystemExit(f"measured allocation evidence is empty: {row}") trace = open(trace_path, encoding="utf-8", errors="replace").read() counts = {name: len(re.findall(rf"\b{name}\(", trace)) for name in ("pread64", "pwrite64", "fsync", "fdatasync")} @@ -321,10 +327,19 @@ if counts["fsync"] + counts["fdatasync"] != expected_sync: raise SystemExit(f"strace sync={counts['fsync'] + counts['fdatasync']} want {expected_sync}") perf_text = open(perf_csv, encoding="utf-8", errors="replace").read() -for event in ("task-clock", "cycles", "instructions", "cache-misses", "context-switches", "page-faults"): +perf_values = {} +for event in ("task-clock", "cycles", "instructions", "cache-misses", "context-switches", "cpu-migrations", "page-faults"): matching = [line for line in perf_text.splitlines() if event in line] if not matching or any("