Skip to content

feat(autoresearch): Animartrix-representative Perlin noise bench (float vs s16x16) - #2847

Merged
zackees merged 1 commit into
masterfrom
feat/animartrix-perlin-bench
Jun 6, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/animartrix-perlin-bench

Conversation

@zackees

@zackees zackees commented Jun 6, 2026 •

Copy link
Copy Markdown
Member

Adds animartrixPerlinBench RPC that drives the same Perlin noise workload Animartrix runs every frame, in two implementations:

  • fl::pnoise(x, y, 0.0f) — the scalar float reference at src/fl/fx/2d/animartrix_detail/perlin_float.h
  • fl::perlin_i16_optimized::pnoise2d_raw(...) — the s16x16 Q16.16 fixed-point variant at src/fl/fx/2d/animartrix_detail/perlin_i16_optimized.cpp.hpp

Both versions are exercised on the same 16×16 coordinate grid per iteration (256 pnoise calls/iter), with a slow per-iter drift in the noise space the way Animartrix's time_speed does. Result includes per-implementation total wall time, total call count, and a server-computed speedup ratio (encoded as basis-points to avoid float on the JSON wire format).

Motivation

The existing testSimdBenchmark measures microbenchmarks of single ops (add, mul, div) on synthetic data. Per-element packed-SIMD wins there look dramatic (22× for s16x16 add on Cortex-M7 ARM-DSP per #2808) but don't generalize to real Animartrix frame times because most Animartrix work is not packed SIMD — it's scalar float pnoise. This bench measures the actual Animartrix hot path, so the speedup it reports is the realistic upper bound for any Animartrix-on-fixed-point port.

Invocation

Via RPC client (ci/rpc_client.py):

RpcClient.send("animartrixPerlinBench", {"iterations": 200})

Returns:

{
  "success": true,
  "iterations": 200,
  "pnoise_calls_per_iter": 256,
  "pnoise_float_us": <int>,
  "pnoise_i16_us": <int>,
  "speedup_x1000": <int>
}

Status

Code is complete and pushed. Hardware verification on Teensy 4.0 attempted in the originating session but the AutoResearch sketch's USB Serial setup on Teensy never emits its [SETUP] banner — appears to be a separate AutoResearch-on-Teensy infra issue (no CI workflow exercises AutoResearch on Teensy today). Bench is correct against the host build and the ESP32-S3 path; Teensy validation is a follow-up.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Summary by CodeRabbit

  • New Features
    • Added a Perlin noise performance benchmark that compares floating-point and fixed-point implementations, returning execution timing and speedup metrics.

Adds `animartrixPerlinBench` RPC that drives the same Perlin noise
workload Animartrix runs every frame, in two implementations:

- `fl::pnoise(x, y, 0.0f)` — the scalar float reference at
  `src/fl/fx/2d/animartrix_detail/perlin_float.h`
- `fl::perlin_i16_optimized::pnoise2d_raw(...)` — the s16x16 Q16.16
  fixed-point variant at `src/fl/fx/2d/animartrix_detail/perlin_i16_optimized.cpp.hpp`

Both versions are exercised on the same 16x16 coordinate grid per
iteration (256 pnoise calls/iter), with a slow per-iter drift in the
noise space the way Animartrix's `time_speed` does. Result includes
per-implementation total wall time, total call count, and a server-
computed speedup ratio (encoded as basis-points to avoid float on the
JSON wire format).

Why this benchmark exists: the existing `testSimdBenchmark` measures
microbenchmarks of single ops (add, mul, div) on synthetic data. Per-
element packed-SIMD wins there look dramatic (22x for s16x16 add on
Cortex-M7 ARM-DSP per #2808) but don't generalize to real Animartrix
frame times because most Animartrix work is not packed SIMD — it's
scalar float pnoise. This bench measures the actual Animartrix hot
path, so the speedup it reports is the realistic upper bound for any
Animartrix-on-fixed-point port.

Invocation:

  bash autoresearch teensy40 (or esp32s3) --simd  # not yet wired
  # or directly via RPC client:
  RpcClient.send("animartrixPerlinBench", {"iterations": 200})

Returns JSON:
  { "success": true,
    "iterations": 200,
    "pnoise_calls_per_iter": 256,
    "pnoise_float_us": <int>,
    "pnoise_i16_us": <int>,
    "speedup_x1000": <int>  // multiply by 0.001 for the x-factor
  }

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown

Lost in the diff? Review this PR in Change Stack to follow the change map from intent to exact ranges.

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0e427ae6-851a-42a7-ba53-1927767f2a4f

📥 Commits

Reviewing files that changed from the base of the PR and between 73ac19d and d5a9946.

📒 Files selected for processing (2)
  • examples/AutoResearch/AutoResearchAnimartrixBench.h
  • examples/AutoResearch/AutoResearchRemote.cpp

📝 Walkthrough

Walkthrough

This PR adds a micro-benchmark comparing Animartrix Perlin noise implementations (float versus Q16.16 fixed-point) and exposes it via remote API. The benchmark sweeps a 16×16 grid with drifting coordinates to measure wall-clock latency, and returns iteration count, timing for both paths, and computed speedup.

Changes

Perlin Benchmark and RPC

Layer / File(s) Summary
Perlin noise benchmark implementation
examples/AutoResearch/AutoResearchAnimartrixBench.h
Defines PerlinBenchResult struct, volatile global sink, and runPerlinBenchmark() function that measures wall-clock time for fl::pnoise (float) and fl::perlin_i16_optimized::pnoise2d (fixed-point) over a drifting 16×16 grid sweep, storing results in timing fields.
RPC registration and remote API exposure
examples/AutoResearch/AutoResearchRemote.cpp
Includes benchmark header, registers animatrixPerlinBench RPC handler that parses and clamps iterations, invokes runPerlinBenchmark(), and returns JSON response with timings, call count per iteration (256), and computed speedup factor; updates help/schema documentation.

Sequence Diagram

sequenceDiagram
  participant Client as Remote Client
  participant RPC as animatrixPerlinBench Handler
  participant Bench as runPerlinBenchmark
  participant FloatImpl as fl::pnoise
  participant FixedImpl as fl::perlin_i16_optimized
  Client->>RPC: request with iterations count
  RPC->>RPC: parse and clamp iterations (1–10000)
  RPC->>Bench: invoke with iteration count
  Bench->>FloatImpl: sweep 16×16 grid, measure time
  FloatImpl-->>Bench: timing_float_us
  Bench->>FixedImpl: sweep 16×16 grid, measure time
  FixedImpl-->>Bench: timing_i16_us
  Bench-->>RPC: return PerlinBenchResult
  RPC->>RPC: compute speedup_x1000 from timings
  RPC-->>Client: JSON response with timings and speedup
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

A rabbit hops through Perlin's fold,
Float meets fixed-point, stories told,
Sixteen grids in measured time,
Speedup factors, dance sublime—
Benchmark bliss in every line! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding an Animartrix Perlin noise benchmark that compares float versus Q16.16 fixed-point implementations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/animartrix-perlin-bench

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
examples/AutoResearch/AutoResearchRemote.cpp

In file included from examples/AutoResearch/AutoResearchRemote.cpp:14:
examples/AutoResearch/AutoResearchRemote.h:14:10: fatal error: 'fl/stl/stdint.h' file not found
14 | #include "fl/stl/stdint.h" // for uint32_t, uint8_t
| ^~~~~~~~~~~~~~~~~
1 error generated.
examples/AutoResearch/AutoResearchRemote.cpp:3232:5-12: ERROR translating statement 'ReturnStmt'
Aborting translation of method 'AutoResearchRemoteControl::startBleRemote' in file 'examples/AutoResearch/AutoResearchRemote.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", li

... [truncated 2200 characters] ...

in file "src/istd/IExn.ml" (inlined), line 13, characters 2-50
Called from ClangFrontend__CTrans.CTrans_funct.instruction_log.(fun) in file "src/clang/cTrans.ml", line 4784, characters 10-1023
Called from ClangFrontend__CTrans.CTrans_funct.instruction in file "src/clang/cTrans.ml" (inlined), line 4765, characters 38-71
Called from ClangFrontend__CTrans.CTrans_funct.exec_with_node_creation in file "src/clang/cTrans.ml" (inlined), line 104, characters 20-38
Called from ClangFrontend__CTrans.CTrans_funct.get_clang_stmt_trans in file "src/clang/cTrans.ml" (inlined), line 5395, characters 4-69
Called from ClangFrontend__CTrans.CTrans_funct.get_custom_stmt_trans in file "src/clang/cTrans.ml", line 5401, characters 8-55
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs.exec_trans_


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees
zackees merged commit a28dac3 into master Jun 6, 2026
6 checks passed
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jun 6, 2026
@zackees
zackees deleted the feat/animartrix-perlin-bench branch August 21, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant