feat: add replay/parser performance guardrails - #259
Conversation
Snazzie
left a comment
There was a problem hiding this comment.
Request changes: This benchmark should not include SQLite or raw file I/O in its measured path; those make results non-reproducible. Please move the parser and semantic replay work into the existing Mitata harness using preloaded deterministic inputs:
- raw lap-frame parsing
- semantic resolver/canonical envelope transformation
Keep frame-count assertions, but replace custom report/comparison logic with Mitata JSON output and the existing benchmark comparator. Also fix or remove custom RSS measurements: current macOS output reports hundreds of GiB because maxRSS is multiplied by 1024 despite already being bytes.
|
Additional issue: the custom worker performs one timed run per scenario with no warmup or repeated samples. Mitata should own warmup/sampling so comparison uses stable statistics (median/p99 and variance/tolerance), rather than a single cold-process measurement. |
|
@Snazzie Addressed both benchmark review points in
Local verification passed: CPU benchmark, replay I/O benchmark, comparator tests, 11 parser/replay contract tests, typecheck, lint, and changelog contract. |
Informational microbenchmarksRuntime: Report-only. Small timings can vary between runs.
Replay CPU guardrailsRuntime:
Baseline pending. Regression assessment starts after matching results exist on the base branch. |
Summary
replay/*benchmarksBenchmark boundaries
CPU guardrails
bun run benchruns existing parser/pipeline suite plus:replay/parse 20,000 raw lap framesreplay/resolve 20,000 canonical envelopesCapture file reading and gzip decompression finish before Mitata starts. Both cases use preloaded deterministic inputs, retain 20,000-frame/output assertions, and use Mitata warmup and repeated sampling.
Legacy nanosecond/microsecond parser and pipeline rows remain report-only because shared-runner jitter produces large percentage swings from tiny absolute changes. CI enforcement filters to
replay/*, gates median/allocation at 10% and p99 at 25%, and treats missing base replay rows as initial-landing bootstrap. Guardrails begin enforcing after this benchmark exists on base.Replay I/O
bun run bench:replay-ioruns in temporary isolated SQLite state and measures:I/O results remain report-only with 25% tolerance because filesystem and cache behavior varies more than CPU-only work. Workflow uploads both base/current reports and starts comparison after benchmark lands on base.
Review changes
maxRSSconversionVerification
bun test test/tooling/bench-compare.test.ts test/tooling/changelog.test.ts --timeout 60000— passedbun test test/games/shared/semantic-replay-native.test.ts test/games/ac-evo/ac-evo-mid-session.test.ts test/session-capture/parse-bin-vs-gz.test.ts --timeout 120000— 11 passed, 141 assertionsbun run benchbun run bench:replay-io--include=replay/ --threshold=10 --p99-threshold=25 --fail-on-regression— passed bootstrapbun run typecheck— passedbun run lint— 0 warnings, 0 errors