Skip to content

test(bench): add six performance benchmarks for core hot paths#215

Open
HanSur94 wants to merge 1 commit into
mainfrom
claude/serene-davinci-1c2536
Open

test(bench): add six performance benchmarks for core hot paths#215
HanSur94 wants to merge 1 commit into
mainfrom
claude/serene-davinci-1c2536

Conversation

@HanSur94

Copy link
Copy Markdown
Owner

Summary

Grows benchmark coverage across the FastSense performance surface, added incrementally via /bench-evolve (one focused benchmark per iteration). Additive only — new benchmark scripts under benchmarks/, no library or production code changed. Each benchmark is deterministic, labels the active MEX-vs-fallback path, and was verified in MATLAB R2025b (and Octave where the feature supports it).

Kernel microbenchmarks — every MEX kernel wired into production

  • bench_downsample_kernels.m — LTTB + MinMax downsampling throughput (the core resolve→downsample→render kernels; previously LTTB was never timed). MEX: ~344 Mpts/s LTTB, ~1100 Mpts/s MinMax at 20M; O(N) confirmed.
  • bench_violation_cull.m — fused threshold detect + pixel cull, exercising both the constant and time-varying (ZOH) threshold branches.
  • bench_binary_search.m — per-call latency of the O(log N) viewport-clip / bucket-boundary search (the most ubiquitous hot-path call); ~1 µs/call, log-like scaling.

Composite-path benchmarks

  • bench_fastsense_multiline.m — live-update refresh rate vs line count on one axes (564→39 Hz over 1→64 lines; sublinear per-line cost).
  • bench_detached_mirror_refresh.m — refresh overhead of detached live mirrors, i.e. the project's headline constraint ("detached live-mirrored widgets must not degrade refresh rate"). Finds mirrors add real, increasing overhead (+35%→~+200% over 1→4 mirrors). MATLAB-only (Octave-skipped — see findings).
  • bench_derived_resolve_chain.m — DerivedTag full-chain recompute cost vs dependency depth (cold ~linear in depth; warm cache flat ~0.02 ms, proving the lazy-memo).

Coverage note

benchmarks/.reports/coverage.md tracks what's covered, what remains, and the methodology lessons baked into the noisier composite benches (warmup, amortized vs per-tick median for bimodal drawnow('limitrate') timing, min-over-reps for GC-bursty recompute).

Findings surfaced (reported, not fixed here — additive-only remit)

  1. Three MEX kernels are test-onlycompute_violations_mex, to_step_function_mex, resolve_disk_mex ship with parity tests but have no production .m call site. Either dead code or missing wiring.
  2. Octave-incompatible deserializationDashboardWidgetRegistry.fromStruct (libs/Dashboard/DashboardWidgetRegistry.m:92) uses feval([className '.fromStruct'], s), which Octave can't resolve. This breaks serialized dashboard load and widget detach under Octave (a "fully supported" runtime). One-line str2func fix candidate noted in the coverage file.

Test plan

  • All six run cleanly in MATLAB R2025b on Apple Silicon (real MEX kernels).
  • Portability verified: bench_downsample_kernels, bench_violation_cull, bench_binary_search, bench_fastsense_multiline, bench_derived_resolve_chain run under Octave 11; bench_detached_mirror_refresh cleanly skips on Octave (guarded — the detach feature is currently MATLAB-only per finding Add datetime X-axis support #2).
  • These are baseline-able by /bench-guard and /perf-watch; no production code touched, so no regression risk to the library.

🤖 Generated with Claude Code

Grows benchmark coverage over the FastSense performance surface (via
/bench-evolve). All additive — new benchmark scripts only, no library or
production code changed. Each is deterministic and labels the active
MEX-vs-fallback path; verified in MATLAB R2025b (and Octave where the
feature supports it).

Kernel microbenchmarks (every MEX kernel wired into production):
- bench_downsample_kernels.m  — LTTB + MinMax downsampling throughput
- bench_violation_cull.m      — fused threshold detect + pixel cull (const & step)
- bench_binary_search.m       — O(log N) viewport-clip / bucket-boundary latency

Composite-path benchmarks:
- bench_fastsense_multiline.m       — live-update refresh vs line count (one axes)
- bench_detached_mirror_refresh.m   — refresh overhead of detached live mirrors
                                      (the project's headline constraint)
- bench_derived_resolve_chain.m     — DerivedTag full-chain recompute vs depth

benchmarks/.reports/coverage.md tracks what is covered, what remains, and two
findings surfaced while writing these (both reported, not fixed here, per the
additive-only remit): three MEX kernels (compute_violations_mex,
to_step_function_mex, resolve_disk_mex) ship + parity-tested but have no
production call site; and DashboardWidgetRegistry.fromStruct uses an
Octave-incompatible dotted feval that breaks serialized-dashboard load and
widget detach under Octave.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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