bench: measure what the insert-FX chain costs, and drop the block-rate idea
`make -C ios bench` renders four channels of synth with 0/1/2/4 effects each, times every effect on its own, and compares a ten-biquad cascade three ways. It asserts nothing, so it stays out of core-test; no shipped code changes (the file is under core/tests, which neither app compiles). What it says, on an M4 at -O2. Per-sample virtual dispatch — listed in the handover as a thing to fix — costs 0.11 ns of 9.13 ns per sample, about 1%: the indirect branch is predicted and amortises over the effect's own work. The obvious block restructuring is a 162% regression, because running band-at-a-time over a block sends the running value through memory ten times per sample instead of keeping it in a register across the cascade. So that idea is recorded as measured and closed, rather than left as an invitation. Where the cost actually is: Ambience, 52% of all eight effects together (65.9 ns/sample, 3.5x Tape Delay). A full chain is ~77% of render time, and three-quarters of that is Ambience. Not urgent — four channels of four effects still render at 42x real time. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
dd04a61e22
commit
c1758637df
@@ -38,6 +38,7 @@ in exactly what it needs and nothing else:
|
||||
| `make help` | lists every target and prints the current version |
|
||||
| `make deps` | fails loudly if the JDK or the Android SDK is missing |
|
||||
| `make check` | unit tests + lint — the gate before a commit |
|
||||
| `make -C ios bench` | prints what the FX chain and each effect cost; asserts nothing |
|
||||
| `make staging` | non-debuggable build, release-like performance, debug key |
|
||||
| `make install` | `adb install -r` of the staging APK (keeps projects/presets) |
|
||||
| `make release` | **unsigned** release APK, named for F-Droid |
|
||||
@@ -974,11 +975,32 @@ polish and interchange niceties, not functional gaps.
|
||||
with the CLI project layout is the remaining interchange nicety.
|
||||
- **Route the Oboe backend through the chosen output device** (Oboe
|
||||
`setDeviceId`), matching the AudioTrack path's device selection.
|
||||
- **Block-rate FX processing.** Insert effects are `process(float)` per sample, so
|
||||
a four-effect chain on four channels is 16 virtual calls per frame. Giving
|
||||
`Effect` a block entry point (defaulting to a loop over `process`) would let the
|
||||
heavier ports vectorise. Sample-for-sample identical if done carefully, but it
|
||||
touches every effect and the golden comparison, so it is its own change.
|
||||
- **Block-rate FX processing — measured, and not worth doing.** Insert effects are
|
||||
`process(float)` per sample, so a four-effect chain on four channels is 16
|
||||
virtual calls per frame. That looks like something to fix; `make -C ios bench`
|
||||
says it is not (M4, `-O2`, part C): on a ten-biquad cascade with EQ10's shape,
|
||||
dispatch costs **0.11 ns of 9.13 ns per sample, about 1 %** — the indirect
|
||||
branch is perfectly predicted and amortises over everything the effect does.
|
||||
The obvious block restructuring is a *large regression*: running band-at-a-time
|
||||
over a block, so each band's coefficients stay in registers, measured **+162 %**,
|
||||
because the running value then makes ten round trips through memory per sample
|
||||
instead of staying in one register across the cascade. Nor is there a SIMD win
|
||||
to chase — serial IIR filters are recurrences, so they do not vectorise across
|
||||
samples, and the chains differ per channel. Don't reopen this on intuition;
|
||||
re-run the bench first.
|
||||
|
||||
Where the cost actually is, if FX headroom is ever needed (part B): **Ambience
|
||||
is 52 % of all eight effects put together** (65.9 ns/sample, 3.5× the next, Tape
|
||||
Delay at 19.1) — an 8-line FDN with four diffusers, early reflections, a
|
||||
Walsh-Hadamard feedback mix and a modulated fractional-delay read per line,
|
||||
every sample. A full chain is about 77 % of render time (part A), and
|
||||
three-quarters of that is Ambience. Nothing is urgent: four channels with four
|
||||
effects each still render at **42× real time**.
|
||||
|
||||
One trap for whoever does touch `src/fx/`: only `AmbienceReverb.cpp` carries
|
||||
`#pragma clang fp contract(off)`. Make that explicit across the directory
|
||||
*first*, as its own commit, or a change in multiply-add contraction is
|
||||
indistinguishable from a real bug in the golden comparison.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user