You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
test: add benchmarks, runnable examples, and bench-regression infrastructure
Summary
Add syncmap_bench_test.go (benchmarks for every public method plus concurrent patterns and an overhead comparison against raw sync.Map), example_test.go (runnable godoc Example functions for every public symbol), and the bench.txt baseline + scripts/check-bench-regression.sh wiring that re-enables mask's benchstat-regression-guard CI job.
One Benchmark* per public symbol: BenchmarkLoad, BenchmarkStore, BenchmarkLoadOrStore, BenchmarkLoadAndDelete, BenchmarkDelete, BenchmarkRange, BenchmarkLen, BenchmarkMap, BenchmarkKeys, BenchmarkValues (or Items if rename #(rename-issue) hasn't landed), BenchmarkSwap, BenchmarkClear, BenchmarkCompareAndSwap, BenchmarkCompareAndDelete.
Every benchmark calls b.ReportAllocs().
Concurrent patterns: BenchmarkConcurrentReadWrite with b.RunParallel and a realistic read/write ratio.
Overhead comparison: BenchmarkOverhead_LoadSyncMap vs BenchmarkOverhead_LoadRawSyncMap (and the same pair for Store, Delete, LoadOrStore, LoadAndDelete) to quantify the generic-wrapper cost.
One Example* per public symbol — ExampleSyncMap, ExampleSyncMap_Load, ExampleSyncMap_Store, etc. — each ending with // Output: so they run under go test.
bench.txt — committed baseline, produced by go test -bench=. -benchmem -run=^$ -count=5 ./... > bench.txt on an ubuntu-latest-equivalent host.
scripts/check-bench-regression.sh — mirror mask's script verbatim (adjust repo-specific paths if any). Exits non-zero when benchstat reports a regression beyond the tolerated threshold.
ci.yml — re-enable the benchstat-regression-guard job from mask (currently commented out / deferred).
Apache headers on all new .go files. No AI-attribution tokens. No timing-based synchronisation in Examples (use WaitGroup if any goroutine is spawned; ideally Examples are single-threaded).
Benchmarks must have zero additional allocations beyond what sync.Map itself allocates for Load, Store, Delete, LoadOrStore, LoadAndDelete — confirmed by b.ReportAllocs() output and compared to the raw-sync.Map baseline.
Acceptance Criteria
syncmap_bench_test.go exists with ≥14 Benchmark* functions (one per public symbol plus concurrent + overhead sets).
example_test.go exists with ≥10 Example* functions, one per public symbol.
go test -run 'Example' ./... passes — all Examples have matching // Output: blocks.
go test -bench=. -benchmem -run=^$ -count=1 ./... produces output for every benchmark; allocs/op for BenchmarkLoad, BenchmarkStore, BenchmarkDelete, BenchmarkLoadOrStore, BenchmarkLoadAndDelete matches (or is within one alloc of) the corresponding BenchmarkOverhead_…RawSyncMap baseline.
bench.txt exists at repo root and contains count=5 sample runs for every Benchmark*.
scripts/check-bench-regression.sh exists, is executable, and mirrors mask's script.
make bench-regression runs benchstat against bench.txt vs a fresh current.txt and exits 0 on an unchanged tree.
makefile-targets-guard passes with bench-regression added to its expected list.
benchstat-regression-guard job in ci.yml is enabled and passes on this PR.
make check and CI green.
Testing Requirements
go test -run 'Example' ./... — green.
make bench-regression — green locally on an unchanged tree.
CI benchstat-regression-guard — green on this PR.
Coverage not regressed (Examples may add to coverage; benchmarks don't affect -cover).
Documentation Requirements
Each Example's comment above the function briefly describes the scenario (matching godoc example conventions).
test: add benchmarks, runnable examples, and bench-regression infrastructure
Summary
Add
syncmap_bench_test.go(benchmarks for every public method plus concurrent patterns and an overhead comparison against rawsync.Map),example_test.go(runnable godocExamplefunctions for every public symbol), and thebench.txtbaseline +scripts/check-bench-regression.shwiring that re-enables mask'sbenchstat-regression-guardCI job.Requirements
syncmap_bench_test.go(package syncmap_test, Apache 2.0 header):Benchmark*per public symbol:BenchmarkLoad,BenchmarkStore,BenchmarkLoadOrStore,BenchmarkLoadAndDelete,BenchmarkDelete,BenchmarkRange,BenchmarkLen,BenchmarkMap,BenchmarkKeys,BenchmarkValues(orItemsif rename #(rename-issue) hasn't landed),BenchmarkSwap,BenchmarkClear,BenchmarkCompareAndSwap,BenchmarkCompareAndDelete.b.ReportAllocs().BenchmarkConcurrentReadWritewithb.RunParalleland a realistic read/write ratio.BenchmarkOverhead_LoadSyncMapvsBenchmarkOverhead_LoadRawSyncMap(and the same pair for Store, Delete, LoadOrStore, LoadAndDelete) to quantify the generic-wrapper cost.example_test.go(package syncmap_test, Apache 2.0 header):Example*per public symbol —ExampleSyncMap,ExampleSyncMap_Load,ExampleSyncMap_Store, etc. — each ending with// Output:so they run undergo test.bench.txt— committed baseline, produced bygo test -bench=. -benchmem -run=^$ -count=5 ./... > bench.txton an ubuntu-latest-equivalent host.scripts/check-bench-regression.sh— mirror mask's script verbatim (adjust repo-specific paths if any). Exits non-zero when benchstat reports a regression beyond the tolerated threshold.bench-regressiontarget (removed in chore: align CI, release, and tooling to axonops/mask pattern #8 for lack of script).makefile-targets-guardinci.ymlupdates its expected list to include it.ci.yml— re-enable thebenchstat-regression-guardjob from mask (currently commented out / deferred)..gofiles. No AI-attribution tokens. No timing-based synchronisation in Examples (useWaitGroupif any goroutine is spawned; ideally Examples are single-threaded).sync.Mapitself allocates forLoad,Store,Delete,LoadOrStore,LoadAndDelete— confirmed byb.ReportAllocs()output and compared to the raw-sync.Mapbaseline.Acceptance Criteria
syncmap_bench_test.goexists with ≥14Benchmark*functions (one per public symbol plus concurrent + overhead sets).example_test.goexists with ≥10Example*functions, one per public symbol.go test -run 'Example' ./...passes — all Examples have matching// Output:blocks.go test -bench=. -benchmem -run=^$ -count=1 ./...produces output for every benchmark;allocs/opforBenchmarkLoad,BenchmarkStore,BenchmarkDelete,BenchmarkLoadOrStore,BenchmarkLoadAndDeletematches (or is within one alloc of) the correspondingBenchmarkOverhead_…RawSyncMapbaseline.bench.txtexists at repo root and containscount=5sample runs for everyBenchmark*.scripts/check-bench-regression.shexists, is executable, and mirrors mask's script.make bench-regressionruns benchstat againstbench.txtvs a freshcurrent.txtand exits 0 on an unchanged tree.makefile-targets-guardpasses withbench-regressionadded to its expected list.benchstat-regression-guardjob inci.ymlis enabled and passes on this PR.make checkand CI green.Testing Requirements
go test -run 'Example' ./...— green.make bench-regression— green locally on an unchanged tree.benchstat-regression-guard— green on this PR.-cover).Documentation Requirements
Dependencies
Labels
testingperformanceP1