Skip to content

ci: extend benchmark gate to G7 — allocation contracts and stdlib-parity ratios - #28

Merged
tr1v3r merged 1 commit into
masterfrom
ci/benchmark-gate-extend
Sep 14, 2026
Merged

tr1v3r merged 1 commit into
masterfrom
ci/benchmark-gate-extend

Conversation

@tr1v3r

@tr1v3r tr1v3r commented Sep 14, 2026

Copy link
Copy Markdown
Owner

Summary

Extends the benchmark gate from 3 to 7 checks — the library's other performance contracts were unprotected (a Sort/DistinctBy/Take/laziness regression would pass CI silently).

New gates

gate type threshold measured (M3 Pro) catches
G4 Sort vs direct slices.SortFunc same-process ratio ≤ 2.5× 1.17–1.22× adapter re-introduction, O(n²) path
G5 DistinctBy vs Distinct ratio ×2 ≤ 0.6× time, ≤ 5% allocs 0.24–0.27×, 0.3% fmt.Sprint boxing regression
G6 Take on 100k deterministic allocs ≤ 50 exactly 6 materialize-all regression (would be ~thousands)
G7 Limit(2).ToSlice() on 100k deterministic allocs ≤ 200 exactly 12 eager traversal regression

Allocation gates (testing.AllocsPerRun) are hardware-free and zero-flake by construction — the strongest gate kind available.

Documented exclusion

Proposal A6 (multi-section 16+2 speedup) is deliberately NOT a time gate: its speedup is core-count dependent (16 workers need 16 cores to beat 4) and thus cannot be machine-independent. Multi-section correctness stays pinned by TestParallelV2_MidChainParallelReopens.

Verification

  • 3 local calibration runs: all gates pass with wide margins (table in file header)
  • gofmt/vet/lint 0 issues; full -race suite green; gate runs in ~1.8s

…ity ratios

Beyond parallel ratios, the gate now locks the library's other performance contracts: G4 Sort pipeline <=2.5x direct slices.SortFunc (kills adapter/O(n^2) regressions; measured 1.17-1.22x), G5 DistinctBy <=0.6x Distinct time and <=5% of its allocations (measured 0.24-0.27x and 0.3%), and two deterministic allocation gates via testing.AllocsPerRun — G6 Take on 100k <=50 allocs (reservoir O(1); measured exactly 6, materialize-all regression would be orders more) and G7 Limit(2).ToSlice() on 100k <=200 allocs (lazy short-circuit; measured exactly 12). Proposal A6 (multi-section speedup) is documented as deliberately excluded from time gates: its speedup is core-count dependent (16 workers need 16 cores to beat 4), so it cannot be machine-independent; correctness stays pinned by TestParallelV2_MidChainParallelReopens. AGENTS.md gate table updated.
@tr1v3r
tr1v3r merged commit 1d05225 into master Sep 14, 2026
2 checks passed
@tr1v3r
tr1v3r deleted the ci/benchmark-gate-extend branch September 14, 2026 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant