Repository navigation
perf(metrics): count pool stats only while metrics are enabled [W1-07] - #939
ajitpratap0 wants to merge 6 commits into
Conversation
Pool statistics are gated on a shared internal/metricsgate flag inside poolstats.Counter.Get/Put (still inlined at all call sites). GetPoolStats returns zeros for the three standard pools while disabled. Breaking: callers must metrics.Enable() before measuring. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Claude finished @ajitpratap0's task in 25s —— View job Review of PR #939: gate pool stats on
|
Perf gate: PASS (shadow mode: report only, this check never fails)Base Runner CPU:
Rules: each arm runs 20 randomized code layouts ( Gated suite (GOGC=off, GOMAXPROCS=1)
A/A' control (base revision, disjoint layout seeds): 2 of 52 benchmarks moved more than 3%; 0 would have been flagged by the time rule; suite geomean -0.79%, p 0.529. Low power46 benchmark(s) have under 80% estimated power to be flagged on their own for a +5% slowdown (their spread across layouts is too wide for 20 layouts at the Benjamini-Hochberg level alpha/m = 0.000192). A slowdown below the last column usually goes unflagged there; instructions/op, allocs/op and the suite geomean still guard them.
Power is estimated with the normal approximation for the U test (Noether): power = Phi(ln(1+shift)/s * sqrt(K/2) * sqrt(3/pi) - z(1 - alpha/(2m))), with s the spread and K the layouts per arm. Instructions per operation (cmd/perfdriver)
Secondary metric: default GC, GOMAXPROCS=1 (informational)
Environmentbenchstat (primary metric, samples pooled across layouts: informational, the verdict uses the per-layout test) |
Fill gate numbers in CHANGELOG, store startTime before opening the gate, note gosqlx stats behaviour, tidy test imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 35s —— View job Review of PR #939: gate pool stats on
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
… both runners [W1-07] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 33s —— View job Review of PR #939: gate pool stats on
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2
|
Claude finished @ajitpratap0's task in 16s —— View job Review of PR #939: gate pool stats on
|
Summary
metrics.Enable()is in effect. A newinternal/metricsgateholds the single enabled flag (own cache line);metrics.Enable/Disable/IsEnabledand every check inmetrics.goread it.poolstats.Counter.Get/Put, which still inline at all 6 call sites, so no tokenizer/parser/ast pool file is touched.RecordNamedPool*return 0 while disabled and create no custom entries. While disabled,GetPoolStatsreturns exactly the three standard pools with zero values; counts made while enabled are kept and reappear afterEnable.TestPoolStats_*and pool hygiene tests enable metrics (restoring the prior state); new tests for the gate, disabled behaviour, toggling and an end-to-end Parse/Release count pin. Mutations M1-M8 each fail a test. The transpiler hygiene test also needed the helper (test-only edit in a wave-1b-owned dir, Q1 default).PoolGetPut/serial(56.89 -> 54.03 ns/op, EPYC 9V74, -cpu 1); the larger win is under contention (parallel Get/Put), which the gate does not measure. instructions/op may rise slightly (locked add becomes a gate load plus branch).Test Plan
task test:cbinding,go test -count=1 ./pkg/compatibility/..., staticcheck on changed packages: pass.task check: lint and vet pass; under machine load (~85) several race packages hit the default 2m timeout or timing-ratio tests. Re-ran individually: formatter, gosqlx, transpiler, mcp, parser, security, tokenizer allokwith -race. The pre-commitinternal/scaletesttiming test flaked once and passed on re-run.can inline (*Counter).Get/Put, Enabled, IsEnabled, RecordPoolGet/Put, and all 6 call sites inline.scripts/perf/ab.sh -r 8 -k 8,./pkg/gosqlx=PoolGetPut|ParseParallel|E2EMetrics, merged tree vs origin/main): allocs/op identical on all rows; B/op +0.00%; geomean -1.42% (p=0.065);PoolGetPut/serial+3.34% (p=0.44) andparallel+2.03% (p=0.65), both within noise, no-cpu 4isolation in this run; ParseParallel and the metrics-ON rows (ParseE2EMetrics,ParseParallelMetrics) show no significant regression (spread 2-7%). Separate reviewer run (n=6, load 8-11):PoolGetPut/parallel-491.7 -> 8.2 ns (-91%, p=0.002),serial-4-3.1% (p=0.009).PoolGetPut/serial, runner-dependent: Zen4 EPYC 9V74 -5.41% (p<0.001, earlier head); Zen3 EPYC 7763 +3.99% and +3.93% (p<0.001, REGRESSION, head 3843b87, two attempts); Intel Xeon 6973P-C -37.06% (p<0.001, A/A' +0.43%, 0/52 moved, final head 4046552, PASS, target listed low-power so allocs/op, B/op unchanged are the backstop). Planned threshold <= -20%: met only on the Xeon run. Hypothesis of data-placement effect probed locally (per-counter flag copy, padding): no clear improvement, no production change. Maintainer decision needed on D1(b) given CPU-dependent result.PoolGetPut/serialvs -5.4% measured (projected -30% to -45%);ParseE2E/simple_select<= -1% vs -0.32% (p=0.543, not significant). The gain materializes in contended use, which the gate does not measure.Breaking Changes
Pool Get/Put counts and
metrics.GetPoolStatsare zero unless metrics are enabled. Migration: callmetrics.Enable()before the workload to measure; counts are not retroactive. See CHANGELOG.🤖 Generated with Claude Code
https://claude.ai/code/session_01DnbRnTFErhoMJdAjVEeCg2