# Concurrency Experiment Loop — Go

Extends `../shared/experiment-loop-base.md` with Go concurrency-specific steps.

## Domain-Specific Additions

**Step 1 — Baseline profiling**: Run block profile (`-blockprofile`), mutex profile (`-mutexprofile`), and standard benchmarks (`-benchmem -count=5`). Save benchmark output.

**Step 3 — Reasoning checklist**: Use the 8-question checklist from `codeflash-async.md`.

**Step 9 — Benchmark**: Run benchmarks with `benchstat` comparison. Also re-run block and mutex profiles.

**Step 10 — Guard**: `go test -race -short ./...` is MANDATORY for concurrency domain. Race failures = automatic DISCARD.

**Step 12 — Re-profile**: Re-run block and mutex profiles to check if contention shifted.

## Keep Thresholds

- **Latency (ns/op)**: ≥5% improvement with p < 0.05
- **Throughput**: ≥5% more ops/sec
- **Goroutine leak fix**: KEEP regardless of perf delta (correctness fix)
- **Contention reduction**: KEEP if block profile shows measurable reduction

## Plateau

- Block profile shows no project-code hotspots
- Mutex profile shows no significant contention
- All remaining waits are in runtime or stdlib
- 3+ consecutive discards
