Repository navigation
feat(autoresearch): add perfProbe sanity probes (refs #3113 Task 2) - #3118
Conversation
Three RPC handlers in AutoResearchRemote.cpp that calibrate the autoresearch timing infrastructure BEFORE wave2dPerf (#3116, Task 1) data is trusted for cross-platform comparison: perfProbeMemcpy { bytes, iterations } - Measures SRAM throughput via repeated memcpy. - Returns mb_per_s. - Host compares vs per-platform vendor floor (e.g. ESP32-S3 ~175 MB/s); below floor → timer instrumentation broken. perfProbeNop { iterations } - Volatile-fenced nop loop calibration. - Returns total_us + us_per_iter. - Host computes (total_us * cpu_mhz / iterations) and checks [1.0, 2.5] cycles-per-nop. Out-of-band → timer broken or IRQ jitter / branch-predictor stall confounding measurement. perfProbeRepeat { W, H, iterations, repeats, stencil } - Runs wave2dPerf's measurement N times back-to-back, reports mean + std_dev_pct of us_per_update. - Host checks std_dev_pct < 5%; higher → IRQ noise or RPC framing jitter is contaminating wave2dPerf, mark UNTRUSTED. All three follow the fail-loud contract: probe failures must stamp result UNTRUSTED at the host reporter. Silent corruption of perf data is worse than no data. Probe details: - Newton-Raphson sqrt in perfProbeRepeat (6 iterations, ~14 significant digits) avoids pulling in <cmath> on platforms where it's costly. - All probes guard their inputs (bytes/iterations/W/H bounded) — a bad RPC payload returns success=false + error=out_of_range rather than crashing the device. - nop probe uses __GNUC__/__clang__ asm nop with a volatile counter fallback for non-GCC compilers. Verified by bash compile wasm --examples AutoResearch (build clean). Refs #3113 Task 2.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughReplaces the ChangesPerformance Sanity Probe RPC Endpoints
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ch becomes external binder (#3120) Per user direction: wave-PDE benchmarking belongs to the wave simulator, not to the AutoResearch RPC layer. AutoResearchRemote.cpp was embedding the wave PDE setup (checkerboard seed, halfDuplex off, stencil selection, warm-up, timing, statistics) inline in two RPC lambdas (wave2dPerf, perfProbeRepeat). The simulator side did not own its own bench API; the RPC layer had to know wave-PDE-specific details that don't belong in transport plumbing. This PR cleanly separates concerns: src/fl/math/wave/wave_perf_bench.h (new): namespace fl::wave_perf: struct WavePerfResult, WavePerfRepeatResult runWavePerf(W, H, iterations, stencil) -> WavePerfResult runWavePerfLoadsOnly(W, H, iterations, stencil) -> WavePerfResult runWavePerfRepeat(W, H, iterations, repeats, stencil) -> WavePerfRepeatResult examples/AutoResearch/AutoResearchRemote.cpp: wave2dPerf and perfProbeRepeat RPC handlers become thin JSON-RPC binders: parse args, dispatch to fl::wave_perf::*, format response. No wave PDE knowledge in the RPC layer. The header-only design keeps the bench helpers compile-time-cheap and co-located with the simulator they measure. They can be reused by any future RPC layer (BLE, HTTP, etc.) or driven directly from a unit test without standing up the AutoResearch sketch. Things deliberately unchanged: - perfProbeMemcpy and perfProbeNop stay in AutoResearchRemote.cpp. They're not wave-PDE-specific; they're general SRAM/cycle-counter calibration helpers. If the codebase ever grows a generic src/fl/perf/sanity_probes.h they can move there. - All JSON wire formats are byte-identical to #3116 (wave2dPerf) and #3118 (perfProbeRepeat). Existing host-side callers don't notice. Validation: - bash test fl_math_wave_wave_simulation_real --cpp — 8/8 pass. - bash lint --cpp — clean. - bash compile wasm --examples AutoResearch — build clean. Refs #3113 Task 1 + Task 2.
…1 / #3113 Task 1) (#3134) A1 of meta #3122. Wires the device-side wave2dPerf (#3116) + perfProbe* (#3118) RPCs (refactored behind fl::wave_perf::* in #3120) into a single host-driven measurement pass. bash autoresearch esp32s3 --wave2d-perf 64x64 Sequence per platform run: 1. perfProbeMemcpy — SRAM throughput, MB/s. 2. perfProbeNop — cycle calibration, us/iter. 3. perfProbeRepeat — wave2dPerf reproducibility, std_dev_pct. >= 5% stamps results UNTRUSTED. 4. wave2dPerf x 4 — { FivePoint, NinePointIsotropic } x { compute, loads_only }. The loads_only/compute gap isolates memory cost from compute cost (critical for ESP32-S3 per #3114 / #3117 PSRAM analysis). Output: per-RPC live progress + final JSON dump with structured results { grid, probes, bench, untrusted, untrusted_reasons }. Naming note: per #3124, future perf-related flags use the --perf-XX prefix convention. This flag uses the original --wave2d-perf name per explicit user direction in this session ("don't fix this now, just file an issue") — #3124 tracks the prefix-rename pass for a future PR. Args dataclass + RunContext extended with the new field; existing test fixture updated to construct both with the new defaults. All 48 ci/tests/test_autoresearch_phases.py tests pass. Refs #3122 A1, #3113 Task 1.
Task 2 of meta #3113. Three RPC handlers that calibrate the autoresearch timing infrastructure before
wave2dPerf(#3116, Task 1) data is trusted for cross-platform comparison.RPCs added
perfProbeMemcpy{ bytes, iterations }mb_per_sperfProbeNop{ iterations }us_per_iterperfProbeRepeat{ W, H, iterations, repeats, stencil }mean_us_per_update,std_dev_us_per_update,std_dev_pctstd_dev_pct > 5→ IRQ noise or RPC framing jitter contaminating wave2dPerfFail-loud contract
All three follow the meta's fail-loud contract: probe failures must cause the host-side reporter to stamp the
wave2dPerfresult UNTRUSTED and refuse to feed it into cross-platform comparison tables. Silent corruption of perf data is worse than no data.Implementation notes
perfProbeRepeat(6 iterations, ~14 significant digits) avoids pulling in<cmath>on platforms where it's costly.bytes/iterations/W/Hbounded) — bad RPC payload returnssuccess=false+error="out_of_range"rather than crashing.__GNUC__/__clang__asmnopwith a volatile counter fallback for non-GCC compilers.Validation
bash lint --cpp— clean.bash compile wasm --examples AutoResearch— build clean.What's NOT in this PR
wave2dPerfand gates the UNTRUSTED stamp — separate slice.bash autoresearch <board> --wave2d-perf <W>x<H>flag — separate slice.Refs #3113 Task 2.
Summary by CodeRabbit
perfProbeMemcpy,perfProbeNop,perfProbeRepeat) to verify timing stability and provide diagnostic statistics before conducting performance measurements.