Skip to content

feat: add replay/parser performance guardrails - #259

Open
Korupt-virus wants to merge 2 commits into
mainfrom
throughput-benchmarks
Open

feat: add replay/parser performance guardrails#259
Korupt-virus wants to merge 2 commits into
mainfrom
throughput-benchmarks

Conversation

@Korupt-virus

@Korupt-virus Korupt-virus commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What changed

  • add isolated 20,000-frame benchmarks for raw telemetry parsing and semantic replay
  • compare pull-request results with base revision on same machine
  • enforce parser and replay hard memory ceilings, plus relative throughput and peak-memory limits
  • validate benchmark reports before comparison so malformed data, changed workloads, different machines, or relaxed budgets cannot produce false greens
  • add bootstrap behavior for initial landing, local comparison tooling, focused CLI contract tests, CI summaries/comments, and seven-day report artifacts
  • treat telemetry-benchmark-results.json as generated output instead of committed machine-specific data

Why this helps

Single benchmark run gives capacity snapshot. Current parser processes 20,000 frames in roughly 0.4 seconds while exposing baseline, peak, and incremental memory use. Value compounds after this lands on main: relevant PRs compare base and current revisions under same Bun version and machine.

Guardrails catch:

  • parser or semantic replay throughput losses above 10%
  • peak RSS or heap growth above 15%
  • absolute memory overruns even when no comparable base report exists
  • extra retained packet arrays, decompressed recordings, envelopes, or resolver state
  • dishonest comparisons caused by different fixtures, frame counts, semantic counts, runtimes, machines, or relaxed hard budgets

RSS and heap are not added together. RSS measures resident process memory; heap measures Bun/JSC-managed memory. Incremental metrics subtract worker startup baseline to better isolate workload growth. This remains targeted parser/replay guardrail, not proof of UI latency, long-running leak behavior, every recording shape, or low-memory hardware behavior.

Budget policy

  • parser: 768 MiB peak RSS; 512 MiB incremental RSS; 512 MiB incremental heap
  • replay: 1,536 MiB peak RSS; 1,024 MiB incremental RSS; 1,024 MiB incremental heap
  • relative limits: 10% throughput loss; 15% peak RSS/heap growth
  • initial landing: explicit hard-budget-only bootstrap because base has no replay/parser report

Verification

  • bun install --frozen-lockfile
  • bun test test/tooling/replay-parser-bench-compare.test.ts — 5 passed, 20 assertions
  • bun run typecheck
  • bun run lint
  • bun run bench:telemetry:current --no-enforce --output=telemetry-benchmark-results.json
    • parser: 20,001 output packets from 20,000 input frames
    • replay: 20,001 envelopes for eight semantic IDs
    • both stayed within hard memory limits
  • bun run bench:telemetry --base=main
    • reported bootstrap mode
    • enforced current hard budgets
    • removed temporary worktree and data

@Korupt-virus
Korupt-virus requested a review from a team August 13, 2026 18:20
@github-actions

Copy link
Copy Markdown
Contributor

Bench comparison

Runtime: bun on AMD EPYC
Threshold: ±5%

Bench Baseline Current Δ time Δ alloc
ac-evo/parse 3.99 µs / 437 b 4.28 µs / 0 b 🔴 +7.4% 🟢 -100.0%
ac-evo/pipeline 23.85 µs / 437 b 22.69 µs / 874 b 🟢 -4.9% 🔴 +100.0%
acc/parse 5.49 µs / 1.83 kb 4.71 µs / 874 b 🟢 -14.2% 🟢 -53.3%
acc/pipeline 35.47 µs / 29.44 kb 35.86 µs / 29.44 kb 🔴 +1.1% ≈ -0.0%
f1/parse 503 ns / 0 b 427 ns / 0 b 🟢 -15.1% ≈ 0.0%
f1/pipeline 110.49 µs / 55.47 kb 135.26 µs / 64.00 kb 🔴 +22.4% 🔴 +15.4%
fm/parse 1.45 µs / 0 b 1.90 µs / 437 b 🔴 +31.7% ≈ 0.0%
fm/pipeline 60.86 µs / 8.53 kb 72.17 µs / 17.07 kb 🔴 +18.6% 🔴 +100.0%

Regressions (>5%)

  • ac-evo/parse: time +7.4% (3.99 µs → 4.28 µs)
  • ac-evo/pipeline: alloc +100.0% (437 b → 874 b)
  • f1/pipeline: time +22.4% (110.49 µs → 135.26 µs)
  • f1/pipeline: alloc +15.4% (55.47 kb → 64.00 kb)
  • fm/parse: time +31.7% (1.45 µs → 1.90 µs)
  • fm/pipeline: time +18.6% (60.86 µs → 72.17 µs)
  • fm/pipeline: alloc +100.0% (8.53 kb → 17.07 kb)

Replay/parser benchmark budgets

Base commit has no replay/parser benchmark. Current hard memory budgets passed; same-machine throughput comparison starts after this benchmark lands on the base branch.

@Snazzie Snazzie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Snazzie

Snazzie commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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.

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.

2 participants