From 4caf1b492b2b00659aeebb1894c25febc6da7e16 Mon Sep 17 00:00:00 2001 From: pingqiu Date: Thu, 30 Jul 2026 00:58:41 -0700 Subject: [PATCH] phase170: add default walstore headroom gate --- .../core/storage/walstore_contention_test.go | 153 ++++++- seaweed-block/internal/docs/current-plan.md | 8 +- .../phase170-d1-walstore-headroom-qa.md | 65 +++ .../run-phase170-walstore-headroom-gate.sh | 391 ++++++++++++++++++ 4 files changed, 611 insertions(+), 6 deletions(-) create mode 100644 seaweed-block/internal/docs/qa-assignments/phase170-d1-walstore-headroom-qa.md create mode 100644 seaweed-block/scripts/run-phase170-walstore-headroom-gate.sh diff --git a/seaweed-block/core/storage/walstore_contention_test.go b/seaweed-block/core/storage/walstore_contention_test.go index 8f2170ec96..9d7ffa3e0c 100644 --- a/seaweed-block/core/storage/walstore_contention_test.go +++ b/seaweed-block/core/storage/walstore_contention_test.go @@ -51,6 +51,7 @@ func BenchmarkPhase167WALStoreContention(b *testing.B) { b.Fatal(err) } b.Cleanup(func() { _ = s.Close() }) + b.ReportAllocs() data := make([][]byte, writers) for i := range data { @@ -86,14 +87,19 @@ func BenchmarkPhase167WALStoreContention(b *testing.B) { } close(start) wg.Wait() + var syncedLSN uint64 if firstErr == nil { - _, firstErr = s.Sync() + syncedLSN, firstErr = s.Sync() + } + if firstErr == nil { + s.flusher.Stop() } wallDuration := time.Since(wallStart) b.StopTimer() if firstErr != nil { b.Fatal(firstErr) } + assertWALStoreContentionDrained(b, s, syncedLSN) if b.N >= writers { for worker, ops := range workerOps { if ops == 0 { @@ -104,13 +110,154 @@ func BenchmarkPhase167WALStoreContention(b *testing.B) { status := s.WriteInstrumentation() reportLatencyPercentiles(b, latencies) - b.ReportMetric(float64(status.WALAppendLockWaitNanos)/float64(status.WALAppendLockWaitOps), "wal_lock_wait_ns/op") - b.ReportMetric(float64(status.WriteCommitLockWaitNanos)/float64(status.WriteCommitLockWaitOps), "commit_lock_wait_ns/op") + reportWALStoreContentionMetrics(b, s, status, uint64(b.N), 1) b.ReportMetric(float64(b.N)/wallDuration.Seconds(), "write_ops/s") }) } } +func BenchmarkPhase170WALStoreBatchContention(b *testing.B) { + const ( + blockSize = 4096 + numBlocks = 16384 + batchBlocks = 16 + ) + for _, writers := range []int{1, 2, 4, 8} { + b.Run(fmt.Sprintf("writers_%d", writers), func(b *testing.B) { + s, err := CreateWALStore(filepath.Join(b.TempDir(), "store.bin"), numBlocks, blockSize) + if err != nil { + b.Fatal(err) + } + b.Cleanup(func() { _ = s.Close() }) + b.ReportAllocs() + + data := make([][][]byte, writers) + for worker := range data { + data[worker] = make([][]byte, batchBlocks) + for block := range data[worker] { + data[worker][block] = make([]byte, blockSize) + data[worker][block][0] = byte(worker + block + 1) + } + } + latencies := make([]int64, b.N) + workerOps := make([]int, writers) + var firstErr error + var errOnce sync.Once + start := make(chan struct{}) + var wg sync.WaitGroup + + b.SetBytes(blockSize * batchBlocks) + b.ResetTimer() + wallStart := time.Now() + for worker := 0; worker < writers; worker++ { + wg.Add(1) + go func(worker int) { + defer wg.Done() + <-start + for idx := worker; idx < b.N; idx += writers { + startLBA := uint32((idx * batchBlocks) % (numBlocks - batchBlocks)) + opStart := time.Now() + _, writeErr := s.WriteBatch(startLBA, data[worker]) + latencies[idx] = time.Since(opStart).Nanoseconds() + if writeErr != nil { + errOnce.Do(func() { firstErr = writeErr }) + return + } + workerOps[worker]++ + } + }(worker) + } + close(start) + wg.Wait() + var syncedLSN uint64 + if firstErr == nil { + syncedLSN, firstErr = s.Sync() + } + if firstErr == nil { + s.flusher.Stop() + } + wallDuration := time.Since(wallStart) + b.StopTimer() + if firstErr != nil { + b.Fatal(firstErr) + } + assertWALStoreContentionDrained(b, s, syncedLSN) + if b.N >= writers { + for worker, ops := range workerOps { + if ops == 0 { + b.Fatalf("worker %d completed zero batches", worker) + } + } + } + + status := s.WriteInstrumentation() + logicalEntries := uint64(b.N * batchBlocks) + reportLatencyPercentiles(b, latencies) + reportWALStoreContentionMetrics(b, s, status, logicalEntries, batchBlocks) + b.ReportMetric(batchBlocks, "batch_blocks") + b.ReportMetric(float64(logicalEntries)/wallDuration.Seconds(), "block_ops/s") + }) + } +} + +func reportWALStoreContentionMetrics( + b *testing.B, + s *WALStore, + status WriteInstrumentationStatus, + logicalEntries uint64, + entriesPerAPICall int, +) { + b.Helper() + perOp := func(total, count uint64) float64 { + if count == 0 { + return 0 + } + return float64(total) / float64(count) + } + perEntry := func(total uint64) float64 { + if logicalEntries == 0 { + return 0 + } + return float64(total) / float64(logicalEntries) + } + + _, _, headLSN := s.Boundaries() + checkpointLSN := s.CheckpointLSN() + + b.ReportMetric(perOp(status.WALCopyDurationNanos, status.WALCopyOps), "wal_copy_ns/record") + b.ReportMetric(perOp(status.WALEncodeDurationNanos, status.WALEncodeOps), "wal_encode_ns/record") + b.ReportMetric(perOp(status.WALChecksumDurationNanos, status.WALChecksumOps), "wal_checksum_ns/record") + b.ReportMetric(perOp(status.WALAppendDurationNanos, status.WALAppendOps), "wal_append_ns/writeat") + b.ReportMetric(perOp(status.WALAppendLockWaitNanos, status.WALAppendLockWaitOps), "wal_lock_wait_ns/append_call") + b.ReportMetric(perOp(status.WriteCommitLockWaitNanos, status.WriteCommitLockWaitOps), "commit_lock_wait_ns/api_call") + b.ReportMetric(perOp(status.DirtyMapUpdateDurationNanos, status.DirtyMapUpdateOps), "dirty_map_ns/record") + b.ReportMetric(perEntry(status.WALAppendWriteAtCalls), "writeat_calls/entry") + b.ReportMetric(perEntry(status.WALAppendWriteAtBytes), "writeat_bytes/entry") + b.ReportMetric(float64(status.WALAppendWriteAtMaxBytes), "writeat_max_bytes") + b.ReportMetric(float64(status.WALAppendWrapCount), "wal_wraps") + b.ReportMetric(float64(status.WALAppendPaddingBytes), "wal_padding_bytes") + b.ReportMetric(float64(s.FlushCount()), "flushes") + b.ReportMetric(float64(s.dm.len()), "dirty_entries") + b.ReportMetric(float64(checkpointLSN), "checkpoint_lsn") + b.ReportMetric(float64(headLSN), "head_lsn") + b.ReportMetric(float64(checkpointLSN)/float64(headLSN), "checkpoint_coverage") + b.ReportMetric(float64(s.syncs.Load()), "explicit_sync_calls") + b.ReportMetric(float64(entriesPerAPICall), "entries/api_call") +} + +func assertWALStoreContentionDrained(b *testing.B, s *WALStore, syncedLSN uint64) { + b.Helper() + if dirty := s.dm.len(); dirty != 0 { + b.Fatalf("dirty entries after timed drain=%d", dirty) + } + checkpointLSN := s.CheckpointLSN() + _, _, headLSN := s.Boundaries() + if checkpointLSN != syncedLSN || headLSN != syncedLSN { + b.Fatalf("drained frontier checkpoint=%d head=%d synced=%d", + checkpointLSN, headLSN, syncedLSN) + } +} + func reportLatencyPercentiles(b *testing.B, samples []int64) { b.Helper() if len(samples) == 0 { diff --git a/seaweed-block/internal/docs/current-plan.md b/seaweed-block/internal/docs/current-plan.md index 6dc97d388d..dfee981433 100644 --- a/seaweed-block/internal/docs/current-plan.md +++ b/seaweed-block/internal/docs/current-plan.md @@ -120,7 +120,8 @@ reuse it, not create another codec. - Extend the existing `BenchmarkPhase167WALStoreContention` evidence rather than creating a synthetic backend. -- Run 4 KiB ordinary Write with 1/2/4/8 writers and explicit final Sync. +- Run 4 KiB ordinary Write with 1/2/4/8 writers, explicit final Sync, and a + timed final flusher drain that must settle checkpoint to head. - Run the existing explicit `WriteBatch` control to show whether fewer `WriteAt` calls have measurable value on the same machine. - Report median/range, p50/p95/p99, allocations, CPU profile, syscall counts, @@ -128,10 +129,11 @@ reuse it, not create another codec. Sync cadence. - Separate cumulative CPU work from wall-clock lock wait; do not sum overlapping concurrent durations into a false percentage. -- Admit D2 only if the baseline has a reproducible concurrency deficit and +- Admit D2 only if five-run range and paired-sample checks are stable and either record encode/copy/checksum/lock work has material parallel headroom or the existing-format batch control proves material syscall/coalescing - headroom. + headroom. A concurrency deficit is important diagnostic evidence, not a + mandatory stop when absolute coalescing headroom is already material. - Stop if the profile instead shows an already saturated device or no existing-format batch advantage. diff --git a/seaweed-block/internal/docs/qa-assignments/phase170-d1-walstore-headroom-qa.md b/seaweed-block/internal/docs/qa-assignments/phase170-d1-walstore-headroom-qa.md new file mode 100644 index 0000000000..5e59b3265c --- /dev/null +++ b/seaweed-block/internal/docs/qa-assignments/phase170-d1-walstore-headroom-qa.md @@ -0,0 +1,65 @@ +# Phase 170 D1 Default WALStore Headroom QA + +Validate the exact committed D1 gate in an isolated m02 source tree. Follow +`QA-AGENT-RUNBOOK.md`; do not edit or commit the shared worktree. + +```bash +cd /tmp/seaweed_block +bash scripts/run-phase170-walstore-headroom-gate.sh /tmp/seaweed_block +cat results/phase170-walstore-headroom-gate/phase170-walstore-headroom-summary.txt +``` + +## Mechanism Gate + +Require: + +- exact one-second samples and five repetitions; +- ordinary and 16-block batch controls at 1/2/4/8 writers; +- all 40 benchmark rows present; +- `explicit_sync_calls=1.000` on every row; +- every row settles all flusher debt: `dirty_entries=0`, + `checkpoint_lsn=head_lsn`, and `checkpoint_coverage=1`; +- no WAL-full, queue, panic, or benchmark failure; +- complete MB/s median/min/max, p50/p95/p99, allocation, stage, WriteAt, flush, + and checkpoint evidence; +- a readable CPU top profile; +- benchmark-only strace summary from the prebuilt test binary when the tool is + available. + +The evidence mechanism passes only when: + +```text +phase170_walstore_headroom_status=ok +``` + +## D2 Decision + +D2 is admitted only when all of these are true: + +```text +batch_throughput_headroom=true +ordinary_one_writeat_per_entry=true +batch_writeat_coalescing=true +paired_batch_gain_stable=true +writeat_shape_stable=true +ordinary_range_bounded=true +batch_range_bounded=true +existing_format_headroom=true +d2_owner_admitted=true +next_recommendation=implement_bounded_existing_format_commit_owner +``` + +The batch control is not a prediction that ordinary writes will reach the same +throughput. It proves only that the current record format and `appendBatch` +path have measurable coalescing headroom worth one bounded owner experiment. +Latency and Go allocation metrics are per API call: one 4 KiB Write for +ordinary and one 16-block WriteBatch for batch. Record-stage and +`writeat_calls/entry` metrics use the explicit denominator in their key. Do not +compare unlike denominators. Strace covers the whole prebuilt benchmark +process, including calibration/setup/cleanup, and is qualitative only. + +If D2 is not admitted, report mechanism PASS and candidate direction STOP. +Do not weaken the thresholds or disable the normal flusher. + +Write the result to +`internal/docs/qa-assignments/phase170-d1-walstore-headroom-qa-signoff.md`. diff --git a/seaweed-block/scripts/run-phase170-walstore-headroom-gate.sh b/seaweed-block/scripts/run-phase170-walstore-headroom-gate.sh new file mode 100644 index 0000000000..884ae0549c --- /dev/null +++ b/seaweed-block/scripts/run-phase170-walstore-headroom-gate.sh @@ -0,0 +1,391 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="${1:-$(pwd)}" +ARTIFACT_DIR="${SW_BLOCK_ARTIFACT_DIR:-${ROOT}/results/phase170-walstore-headroom-gate}" +SUMMARY="${ARTIFACT_DIR}/phase170-walstore-headroom-summary.txt" +BENCHTIME="${SW_BLOCK_PHASE170_BENCHTIME:-1s}" +REPETITIONS="${SW_BLOCK_PHASE170_REPETITIONS:-5}" +WRITERS=(1 2 4 8) + +mkdir -p "${ARTIFACT_DIR}" +: >"${SUMMARY}" + +write_summary() { + echo "$*" | tee -a "${SUMMARY}" >/dev/null +} + +benchmark_for_mode() { + case "$1" in + ordinary) echo "BenchmarkPhase167WALStoreContention" ;; + batch) echo "BenchmarkPhase170WALStoreBatchContention" ;; + *) return 1 ;; + esac +} + +metric_from_log() { + local file="$1" + local benchmark="$2" + local writers="$3" + local metric="$4" + awk -v prefix="${benchmark}/writers_${writers}-" -v metric="${metric}" ' + index($1, prefix) == 1 { + for (i = 2; i < NF; i++) { + if ($(i + 1) == metric) { + print $i + exit + } + } + } + ' "${file}" +} + +median_file() { + sort -n "$1" | awk 'NR == 3 { print; exit }' +} + +minimum_file() { + sort -n "$1" | awk 'NR == 1 { print; exit }' +} + +maximum_file() { + sort -n "$1" | awk 'END { print }' +} + +ratio_for_summary() { + awk -v numerator="$1" -v denominator="$2" 'BEGIN { + if (numerator <= 0 || denominator <= 0) exit 1 + printf "%.3f", numerator / denominator + }' +} + +ratio_at_least() { + awk -v numerator="$1" -v denominator="$2" -v minimum="$3" 'BEGIN { + if (numerator <= 0 || denominator <= 0) exit 1 + print (numerator / denominator >= minimum) ? "true" : "false" + }' +} + +ratio_at_most() { + awk -v numerator="$1" -v denominator="$2" -v maximum="$3" 'BEGIN { + if (numerator <= 0 || denominator <= 0) exit 1 + print (numerator / denominator <= maximum) ? "true" : "false" + }' +} + +ratio_below() { + awk -v numerator="$1" -v denominator="$2" -v maximum="$3" 'BEGIN { + if (numerator <= 0 || denominator <= 0) exit 1 + print (numerator / denominator < maximum) ? "true" : "false" + }' +} + +at_most() { + awk -v value="$1" -v maximum="$2" 'BEGIN { + print (value <= maximum) ? "true" : "false" + }' +} + +at_least_value() { + awk -v value="$1" -v minimum="$2" 'BEGIN { + print (value >= minimum) ? "true" : "false" + }' +} + +equal_values() { + awk -v left="$1" -v right="$2" 'BEGIN { + print (left + 0 == right + 0) ? "true" : "false" + }' +} + +paired_ratio_at_least_count() { + paste "$1" "$2" | awk -v minimum="$3" ' + $1 > 0 && $2 > 0 && $1 / $2 >= minimum { count++ } + END { print count + 0 } + ' +} + +paired_ratio_below_count() { + paste "$1" "$2" | awk -v maximum="$3" ' + $1 > 0 && $2 > 0 && $1 / $2 < maximum { count++ } + END { print count + 0 } + ' +} + +values_at_least_count() { + awk -v minimum="$2" '$1 >= minimum { count++ } END { print count + 0 }' "$1" +} + +values_at_most_count() { + awk -v maximum="$2" '$1 <= maximum { count++ } END { print count + 0 }' "$1" +} + +if [[ "${REPETITIONS}" != "5" ]]; then + echo "SW_BLOCK_PHASE170_REPETITIONS must be exactly 5" >&2 + exit 1 +fi +if [[ "${BENCHTIME}" != "1s" ]]; then + echo "SW_BLOCK_PHASE170_BENCHTIME must be exactly 1s" >&2 + exit 1 +fi + +write_summary "phase170_walstore_headroom_status=running" +write_summary "benchmark_time=${BENCHTIME}" +write_summary "repetitions=${REPETITIONS}" +write_summary "writers=1,2,4,8" +write_summary "ordinary_shape=one_4k_write" +write_summary "batch_control_shape=sixteen_4k_writes" +write_summary "sync_cadence=one_final_explicit_sync_per_sample" +write_summary "legacy_background_flush_enabled=true" +write_summary "timed_close_shape=sync_then_final_flusher_drain" +write_summary "latency_and_alloc_denominator=api_call" +write_summary "record_stage_denominator=record_or_named_append_stage" +write_summary "stability_requirement=paired_4_of_5_and_range_ratio_at_most_1.35" + +cd "${ROOT}" +go test ./core/storage -count=1 >"${ARTIFACT_DIR}/storage-regression.log" 2>&1 +write_summary "storage_regression=pass" + +metric_pairs=( + "MB/s:mibps" + "p50_ns:p50_ns_per_api_call" + "p95_ns:p95_ns_per_api_call" + "p99_ns:p99_ns" + "B/op:bytes_per_api_call" + "allocs/op:allocs_per_api_call" + "wal_copy_ns/record:wal_copy_ns_per_record" + "wal_encode_ns/record:wal_encode_ns_per_record" + "wal_checksum_ns/record:wal_checksum_ns_per_record" + "wal_append_ns/writeat:wal_append_ns_per_writeat" + "wal_lock_wait_ns/append_call:wal_lock_wait_ns_per_append_call" + "commit_lock_wait_ns/api_call:commit_lock_wait_ns_per_api_call" + "dirty_map_ns/record:dirty_map_ns_per_record" + "writeat_calls/entry:writeat_calls_per_entry" + "writeat_bytes/entry:writeat_bytes_per_entry" + "writeat_max_bytes:writeat_max_bytes" + "flushes:flushes" + "dirty_entries:dirty_entries" + "checkpoint_lsn:checkpoint_lsn" + "head_lsn:head_lsn" + "checkpoint_coverage:checkpoint_coverage" + "explicit_sync_calls:explicit_sync_calls" + "entries/api_call:entries_per_api_call" +) + +for mode in ordinary batch; do + for writers in "${WRITERS[@]}"; do + for pair in "${metric_pairs[@]}"; do + alias="${pair#*:}" + : >"${ARTIFACT_DIR}/${mode}-writers-${writers}-${alias}.values" + done + done +done + +for repetition in 1 2 3 4 5; do + if (( repetition % 2 == 1 )); then + order=(ordinary batch) + else + order=(batch ordinary) + fi + write_summary "repetition_${repetition}_order=${order[*]}" + for mode in "${order[@]}"; do + benchmark="$(benchmark_for_mode "${mode}")" + log="${ARTIFACT_DIR}/${repetition}-${mode}.log" + go test ./core/storage -run '^$' \ + -bench "^${benchmark}/writers_(1|2|4|8)$" \ + -benchtime="${BENCHTIME}" -count=1 >"${log}" 2>&1 + for writers in "${WRITERS[@]}"; do + for pair in "${metric_pairs[@]}"; do + metric="${pair%%:*}" + alias="${pair#*:}" + value="$(metric_from_log "${log}" "${benchmark}" "${writers}" "${metric}")" + if [[ -z "${value}" ]]; then + echo "missing ${mode} writers=${writers} metric=${metric} in ${log}" >&2 + exit 1 + fi + echo "${value}" >>"${ARTIFACT_DIR}/${mode}-writers-${writers}-${alias}.values" + done + sync_calls="$(metric_from_log "${log}" "${benchmark}" "${writers}" "explicit_sync_calls")" + if [[ "${sync_calls}" != "1.000" ]]; then + echo "invalid ${mode} writers=${writers} explicit Sync count in ${log}" >&2 + exit 1 + fi + dirty_entries="$(metric_from_log "${log}" "${benchmark}" "${writers}" "dirty_entries")" + checkpoint_lsn="$(metric_from_log "${log}" "${benchmark}" "${writers}" "checkpoint_lsn")" + head_lsn="$(metric_from_log "${log}" "${benchmark}" "${writers}" "head_lsn")" + checkpoint_coverage="$(metric_from_log "${log}" "${benchmark}" "${writers}" "checkpoint_coverage")" + if [[ "$(equal_values "${dirty_entries}" "0")" != "true" || + "$(equal_values "${checkpoint_lsn}" "${head_lsn}")" != "true" || + "$(equal_values "${checkpoint_coverage}" "1")" != "true" ]]; then + echo "unsettled flusher/checkpoint debt ${mode} writers=${writers} in ${log}" >&2 + exit 1 + fi + entries_per_call="$(metric_from_log "${log}" "${benchmark}" "${writers}" "entries/api_call")" + if [[ "${mode}" == "batch" ]]; then + batch_blocks="$(metric_from_log "${log}" "${benchmark}" "${writers}" "batch_blocks")" + if [[ "${batch_blocks}" != "16.00" || "${entries_per_call}" != "16.00" ]]; then + echo "invalid batch block count writers=${writers} in ${log}" >&2 + exit 1 + fi + elif [[ "${entries_per_call}" != "1.000" ]]; then + echo "invalid ordinary entries/API call writers=${writers} in ${log}" >&2 + exit 1 + fi + done + done +done + +write_summary "flusher_debt_settled_all_samples=true" + +for mode in ordinary batch; do + for writers in "${WRITERS[@]}"; do + mibps_file="${ARTIFACT_DIR}/${mode}-writers-${writers}-mibps.values" + write_summary "${mode}_writers_${writers}_mibps_median=$(median_file "${mibps_file}")" + write_summary "${mode}_writers_${writers}_mibps_min=$(minimum_file "${mibps_file}")" + write_summary "${mode}_writers_${writers}_mibps_max=$(maximum_file "${mibps_file}")" + write_summary "${mode}_writers_${writers}_p50_ns_per_api_call_median=$(median_file \ + "${ARTIFACT_DIR}/${mode}-writers-${writers}-p50_ns_per_api_call.values")" + write_summary "${mode}_writers_${writers}_p95_ns_per_api_call_median=$(median_file \ + "${ARTIFACT_DIR}/${mode}-writers-${writers}-p95_ns_per_api_call.values")" + write_summary "${mode}_writers_${writers}_p99_ns_per_api_call_median=$(median_file \ + "${ARTIFACT_DIR}/${mode}-writers-${writers}-p99_ns.values")" + write_summary "${mode}_writers_${writers}_bytes_per_api_call_median=$(median_file \ + "${ARTIFACT_DIR}/${mode}-writers-${writers}-bytes_per_api_call.values")" + write_summary "${mode}_writers_${writers}_allocs_per_api_call_median=$(median_file \ + "${ARTIFACT_DIR}/${mode}-writers-${writers}-allocs_per_api_call.values")" + write_summary "${mode}_writers_${writers}_writeat_calls_per_entry_median=$(median_file \ + "${ARTIFACT_DIR}/${mode}-writers-${writers}-writeat_calls_per_entry.values")" + done +done + +for writers in 1 4; do + for alias in \ + wal_copy_ns_per_record \ + wal_encode_ns_per_record \ + wal_checksum_ns_per_record \ + wal_append_ns_per_writeat \ + wal_lock_wait_ns_per_append_call \ + commit_lock_wait_ns_per_api_call \ + dirty_map_ns_per_record \ + writeat_bytes_per_entry \ + writeat_max_bytes \ + flushes \ + checkpoint_lsn; do + write_summary "ordinary_writers_${writers}_${alias}_median=$(median_file \ + "${ARTIFACT_DIR}/ordinary-writers-${writers}-${alias}.values")" + done +done + +ordinary_1="$(median_file "${ARTIFACT_DIR}/ordinary-writers-1-mibps.values")" +ordinary_4="$(median_file "${ARTIFACT_DIR}/ordinary-writers-4-mibps.values")" +batch_4="$(median_file "${ARTIFACT_DIR}/batch-writers-4-mibps.values")" +ordinary_writeat_4="$(median_file \ + "${ARTIFACT_DIR}/ordinary-writers-4-writeat_calls_per_entry.values")" +batch_writeat_4="$(median_file \ + "${ARTIFACT_DIR}/batch-writers-4-writeat_calls_per_entry.values")" +ordinary_4_min="$(minimum_file "${ARTIFACT_DIR}/ordinary-writers-4-mibps.values")" +ordinary_4_max="$(maximum_file "${ARTIFACT_DIR}/ordinary-writers-4-mibps.values")" +batch_4_min="$(minimum_file "${ARTIFACT_DIR}/batch-writers-4-mibps.values")" +batch_4_max="$(maximum_file "${ARTIFACT_DIR}/batch-writers-4-mibps.values")" + +ordinary_scaling_ratio="$(ratio_for_summary "${ordinary_4}" "${ordinary_1}")" +batch_gain_ratio="$(ratio_for_summary "${batch_4}" "${ordinary_4}")" +ordinary_4_range_ratio="$(ratio_for_summary "${ordinary_4_max}" "${ordinary_4_min}")" +batch_4_range_ratio="$(ratio_for_summary "${batch_4_max}" "${batch_4_min}")" +ordinary_concurrency_deficit="$(ratio_below "${ordinary_4}" "${ordinary_1}" "1.200")" +batch_throughput_headroom="$(ratio_at_least "${batch_4}" "${ordinary_4}" "1.250")" +ordinary_one_writeat_per_entry="$(at_least_value "${ordinary_writeat_4}" "0.900")" +batch_writeat_coalescing="$(at_most "${batch_writeat_4}" "0.250")" +ordinary_range_bounded="$(ratio_at_most "${ordinary_4_max}" "${ordinary_4_min}" "1.350")" +batch_range_bounded="$(ratio_at_most "${batch_4_max}" "${batch_4_min}" "1.350")" +paired_batch_gain_pass_count="$(paired_ratio_at_least_count \ + "${ARTIFACT_DIR}/batch-writers-4-mibps.values" \ + "${ARTIFACT_DIR}/ordinary-writers-4-mibps.values" "1.250")" +paired_ordinary_deficit_count="$(paired_ratio_below_count \ + "${ARTIFACT_DIR}/ordinary-writers-4-mibps.values" \ + "${ARTIFACT_DIR}/ordinary-writers-1-mibps.values" "1.200")" +ordinary_writeat_pass_count="$(values_at_least_count \ + "${ARTIFACT_DIR}/ordinary-writers-4-writeat_calls_per_entry.values" "0.900")" +batch_writeat_pass_count="$(values_at_most_count \ + "${ARTIFACT_DIR}/batch-writers-4-writeat_calls_per_entry.values" "0.250")" +paired_batch_gain_stable="$(at_least_value "${paired_batch_gain_pass_count}" "4")" +writeat_shape_stable=false +if [[ "${ordinary_writeat_pass_count}" == "5" && "${batch_writeat_pass_count}" == "5" ]]; then + writeat_shape_stable=true +fi + +existing_format_headroom=false +if [[ "${batch_throughput_headroom}" == "true" && + "${ordinary_one_writeat_per_entry}" == "true" && + "${batch_writeat_coalescing}" == "true" && + "${writeat_shape_stable}" == "true" ]]; then + existing_format_headroom=true +fi +d2_owner_admitted=false +if [[ "${existing_format_headroom}" == "true" && + "${paired_batch_gain_stable}" == "true" && + "${ordinary_range_bounded}" == "true" && + "${batch_range_bounded}" == "true" ]]; then + d2_owner_admitted=true +fi + +write_summary "ordinary_four_writer_scaling_ratio=${ordinary_scaling_ratio}" +write_summary "batch_four_vs_ordinary_four_ratio=${batch_gain_ratio}" +write_summary "ordinary_writers_4_range_ratio=${ordinary_4_range_ratio}" +write_summary "batch_writers_4_range_ratio=${batch_4_range_ratio}" +write_summary "ordinary_concurrency_deficit=${ordinary_concurrency_deficit}" +write_summary "paired_ordinary_deficit_count=${paired_ordinary_deficit_count}" +write_summary "batch_throughput_headroom=${batch_throughput_headroom}" +write_summary "paired_batch_gain_pass_count=${paired_batch_gain_pass_count}" +write_summary "paired_batch_gain_stable=${paired_batch_gain_stable}" +write_summary "ordinary_one_writeat_per_entry=${ordinary_one_writeat_per_entry}" +write_summary "batch_writeat_coalescing=${batch_writeat_coalescing}" +write_summary "ordinary_writeat_pass_count=${ordinary_writeat_pass_count}" +write_summary "batch_writeat_pass_count=${batch_writeat_pass_count}" +write_summary "writeat_shape_stable=${writeat_shape_stable}" +write_summary "ordinary_range_bounded=${ordinary_range_bounded}" +write_summary "batch_range_bounded=${batch_range_bounded}" +write_summary "existing_format_headroom=${existing_format_headroom}" +write_summary "d2_owner_admitted=${d2_owner_admitted}" + +profile_log="${ARTIFACT_DIR}/ordinary-writers-4-profile.log" +go test ./core/storage -run '^$' \ + -bench '^BenchmarkPhase167WALStoreContention/writers_4$' \ + -benchtime=1s -count=1 \ + -cpuprofile="${ARTIFACT_DIR}/ordinary-writers-4.cpu.pprof" \ + -memprofile="${ARTIFACT_DIR}/ordinary-writers-4.mem.pprof" \ + >"${profile_log}" 2>&1 +go tool pprof -top -nodecount=20 \ + "${ARTIFACT_DIR}/ordinary-writers-4.cpu.pprof" \ + >"${ARTIFACT_DIR}/ordinary-writers-4.cpu-top.txt" +write_summary "cpu_profile=ordinary-writers-4.cpu.pprof" +write_summary "memory_profile=ordinary-writers-4.mem.pprof" +write_summary "cpu_top=ordinary-writers-4.cpu-top.txt" + +if command -v strace >/dev/null 2>&1; then + go test -c ./core/storage -o "${ARTIFACT_DIR}/storage.test" + if strace -f -c -e trace=pwrite64,fsync,fdatasync \ + -o "${ARTIFACT_DIR}/ordinary-writers-4.strace.txt" \ + "${ARTIFACT_DIR}/storage.test" \ + -test.run '^$' \ + -test.bench '^BenchmarkPhase167WALStoreContention/writers_4$' \ + -test.benchtime=1s \ + -test.count=1 \ + >"${ARTIFACT_DIR}/ordinary-writers-4.strace-benchmark.log" 2>&1; then + write_summary "strace_available=true" + write_summary "strace_summary=ordinary-writers-4.strace.txt" + write_summary "strace_scope=qualitative_whole_benchmark_process" + else + write_summary "strace_available=false" + write_summary "strace_error=ordinary-writers-4.strace-benchmark.log" + fi +else + write_summary "strace_available=false" +fi + +if [[ "${d2_owner_admitted}" == "true" ]]; then + write_summary "next_recommendation=implement_bounded_existing_format_commit_owner" +else + write_summary "next_recommendation=stop_before_staged_owner" +fi +write_summary "phase170_walstore_headroom_status=ok"