Repository navigation
refactor(wave): perf-bench owned by wave simulator; AutoResearch is external binder (refs #3113) - #3120
Conversation
…ch becomes external binder
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.
|
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 (2)
📝 WalkthroughWalkthroughA new header ChangesWave benchmark extraction and RPC delegation
Sequence Diagram(s)sequenceDiagram
participant Client
participant AutoResearchRemote
participant wave_perf
rect rgba(100, 149, 237, 0.5)
Note over Client,wave_perf: perfProbeRepeat RPC
Client->>AutoResearchRemote: perfProbeRepeat(stencil_name, W, H, iterations, repeats)
AutoResearchRemote->>wave_perf: runWavePerfRepeat(W, H, iterations, repeats, stencil)
wave_perf-->>AutoResearchRemote: WavePerfRepeatResult{success, mean_us, std_dev, std_dev_pct}
AutoResearchRemote-->>Client: JSON response
end
rect rgba(144, 238, 144, 0.5)
Note over Client,wave_perf: wave2dPerf RPC
Client->>AutoResearchRemote: wave2dPerf(stencil_name, W, H, iterations, loads_only)
alt loads_only
AutoResearchRemote->>wave_perf: runWavePerfLoadsOnly(W, H, iterations, stencil)
else
AutoResearchRemote->>wave_perf: runWavePerf(W, H, iterations, stencil)
end
wave_perf-->>AutoResearchRemote: WavePerfResult{success, total_us, us_per_update, fps}
AutoResearchRemote-->>Client: JSON response
end
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 |
…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.
Per user feedback on PRs #3116 + #3118: wave-PDE benchmarking belongs to the wave simulator side, not to the AutoResearch RPC layer.
AutoResearchRemote.cppwas embedding wave PDE setup (checkerboard seed, halfDuplex off, stencil selection, warm-up, timing, statistics) inline in two RPC lambdas — the RPC layer should not know wave-PDE-specific details that don't belong in transport plumbing.Separation of concerns
New, simulator-side:
src/fl/math/wave/wave_perf_bench.hExisting, binder-side:
examples/AutoResearch/AutoResearchRemote.cpp—wave2dPerfandperfProbeRepeatRPC handlers become thin JSON-RPC translators: parse args, dispatch tofl::wave_perf::*, format response.Why header-only
Bench helpers are co-located with the simulator they measure, compile-time-cheap, and reusable by any future RPC layer (BLE, HTTP, etc.) or driven directly from a unit test without standing up the AutoResearch sketch.
What's deliberately unchanged
perfProbeMemcpyandperfProbeNopstay inAutoResearchRemote.cpp— they're not wave-PDE-specific; they're general SRAM/cycle-counter calibration helpers. If the codebase ever grows a genericsrc/fl/perf/sanity_probes.hthey can move there.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.
Summary by CodeRabbit