test: isolate phase173 control samples

This commit is contained in:
pingqiu committed 2026-08-01 01:08:54 -07:00
1 parent c5356bf85a
commit 6165755950
3 files changed
+53 -31

No files matched your search

@@ -8,6 +8,7 @@ import (
"path/filepath"
"runtime"
"sort"
"strconv"
"sync"
"testing"
"time"
@@ -15,6 +16,8 @@ import (
const (
phase173ControlStoreEnv = "SW_BLOCK_PHASE173_ARCH_CONTROL_STORE_DIR"
phase173ControlNameEnv = "SW_BLOCK_PHASE173_ARCH_CONTROL"
phase173ControlRunEnv = "SW_BLOCK_PHASE173_ARCH_CONTROL_RUN"
phase173ControlRuns = 5
phase173ControlAPIOps = 2320
phase173ControlWarmup = 80
@@ -81,29 +84,36 @@ func TestPhase173ArchitectureControls(t *testing.T) {
if dir == "" {
t.Skip("formal architecture controls require " + phase173ControlStoreEnv)
}
control := os.Getenv(phase173ControlNameEnv)
run, err := strconv.Atoi(os.Getenv(phase173ControlRunEnv))
if err != nil || run < 1 || run > phase173ControlRuns {
t.Fatalf("%s must be in [1,%d]", phase173ControlRunEnv, phase173ControlRuns)
}
if err := os.MkdirAll(dir, 0o755); err != nil {
t.Fatal(err)
}
for _, tc := range []struct {
name string
control string
writers int
live bool
}{
{control: "shipped_concurrent", writers: 4, live: true},
{control: "deferred_foreground", writers: 1, live: false},
{control: "deferred_foreground", writers: 4, live: false},
{name: "shipped_concurrent_writers_4", control: "shipped_concurrent", writers: 4, live: true},
{name: "deferred_foreground_writers_1", control: "deferred_foreground", writers: 1, live: false},
{name: "deferred_foreground_writers_4", control: "deferred_foreground", writers: 4, live: false},
} {
path := filepath.Join(dir, fmt.Sprintf("phase173-control-%s-writers%d.store", tc.control, tc.writers))
if control != tc.name {
continue
}
path := filepath.Join(dir, fmt.Sprintf("phase173-control-%s-run%d.store", tc.name, run))
s := preparePhase173ControlStore(t, path, tc.writers)
for run := 1; run <= phase173ControlRuns; run++ {
runtime.GC()
time.Sleep(100 * time.Millisecond)
foreground, flusher := runPhase173WALStoreControl(t, s, tc.control, tc.writers, tc.live, run)
emitPhase173ArchitectureControl(t, foreground)
if tc.control == "deferred_foreground" && tc.writers == 4 {
emitPhase173ArchitectureControl(t, flusher)
}
runtime.GC()
time.Sleep(100 * time.Millisecond)
foreground, flusher := runPhase173WALStoreControl(t, s, tc.control, tc.writers, tc.live, run)
emitPhase173ArchitectureControl(t, foreground)
if tc.writers == 4 && !tc.live {
emitPhase173ArchitectureControl(t, flusher)
}
if err := s.Close(); err != nil {
t.Fatal(err)
@@ -111,21 +121,18 @@ func TestPhase173ArchitectureControls(t *testing.T) {
if err := os.Remove(path); err != nil {
t.Fatal(err)
}
return
}
scratch := preparePhase173FileLayoutScratch(t, dir)
defer scratch.close(t)
for run := 1; run <= phase173ControlRuns; run++ {
order := []bool{false, true}
if run%2 == 0 {
order = []bool{true, false}
}
for _, split := range order {
runtime.GC()
time.Sleep(100 * time.Millisecond)
emitPhase173ArchitectureControl(t, scratch.run(t, split, run))
}
if control == "shared_file_scratch" || control == "split_file_scratch" {
scratch := preparePhase173FileLayoutScratch(t, dir)
defer scratch.close(t)
runtime.GC()
time.Sleep(100 * time.Millisecond)
emitPhase173ArchitectureControl(t, scratch.run(t, control == "split_file_scratch", run))
return
}
t.Fatalf("unsupported %s=%q", phase173ControlNameEnv, control)
}
func phase173ControlConfig(writers int) phase173FixedWorkConfig {
@@ -31,6 +31,8 @@ run the formal gate on a network share, tmpfs, overlay, or OS-root filesystem.
The CPU set must contain at least four comparable physical cores. Do not mix
performance and efficiency cores or sibling SMT threads; the gate records the
set and constrains both process affinity and `GOMAXPROCS`.
Each sample runs in a fresh process after `sync` and a 250 ms settle interval,
matching the Phase 173 D1 baseline's sample-isolation policy.
## Fixed Controls
@@ -12,7 +12,7 @@ MATERIAL_RATIO="1.30"
RUNS=5
CONTROL_CPUSET="${SW_BLOCK_PHASE173_CONTROL_CPUSET:-}"
mkdir -p "${ARTIFACT_DIR}" "${STORE_DIR}" "${ARTIFACT_DIR}/environment"
mkdir -p "${ARTIFACT_DIR}" "${STORE_DIR}" "${ARTIFACT_DIR}/environment" "${ARTIFACT_DIR}/logs"
: >"${SUMMARY}"
: >"${RESULTS}"
@@ -90,12 +90,25 @@ go test ./core/storage -run '^TestPhase173ArchitectureControlContract$' -count=1
>"${ARTIFACT_DIR}/control-contract-test.log" 2>&1
go test -c -o "${TEST_BINARY}" ./core/storage
control_log="${ARTIFACT_DIR}/architecture-controls.log"
SW_BLOCK_PHASE173_ARCH_CONTROL_STORE_DIR="${STORE_DIR}" \
GOMAXPROCS="${CONTROL_GOMAXPROCS}" taskset -c "${CONTROL_CPUSET}" \
"${TEST_BINARY}" -test.run '^TestPhase173ArchitectureControls$' -test.v -test.count=1 \
>"${control_log}" 2>&1
sed -n 's/^phase173_architecture_control_result=//p' "${control_log}" >"${RESULTS}"
for control in \
shipped_concurrent_writers_4 \
deferred_foreground_writers_1 \
deferred_foreground_writers_4 \
shared_file_scratch \
split_file_scratch; do
for run in $(seq 1 "${RUNS}"); do
sync
sleep 0.25
control_log="${ARTIFACT_DIR}/logs/${control}-run${run}.log"
SW_BLOCK_PHASE173_ARCH_CONTROL_STORE_DIR="${STORE_DIR}" \
SW_BLOCK_PHASE173_ARCH_CONTROL="${control}" \
SW_BLOCK_PHASE173_ARCH_CONTROL_RUN="${run}" \
GOMAXPROCS="${CONTROL_GOMAXPROCS}" taskset -c "${CONTROL_CPUSET}" \
"${TEST_BINARY}" -test.run '^TestPhase173ArchitectureControls$' -test.v -test.count=1 \
>"${control_log}" 2>&1
sed -n 's/^phase173_architecture_control_result=//p' "${control_log}" >>"${RESULTS}"
done
done
mkdir -p "${STORE_DIR}/tmp"
TMPDIR="${STORE_DIR}/tmp" GOMAXPROCS="${CONTROL_GOMAXPROCS}" taskset -c "${CONTROL_CPUSET}" go test ./core/frontend/durable \