Skip to content

Fourth performance pass, review fixes, Stop releases notes - #2

Merged
Devko merged 3 commits into
mainfrom
perf-pass-4
Oct 26, 2026
Merged

Devko merged 3 commits into
mainfrom
perf-pass-4

Conversation

@Devko

@Devko Devko commented Oct 26, 2026

Copy link
Copy Markdown
Owner

A full review of the engine and plugin layer, a fourth performance pass on the engine's hot paths, and transport Stop no longer cutting ringing notes.

Performance

These are ARM instructions per 128-frame block for the profile-guided build that ships, counted under qemu-arm. The patch is both oscillators, F1 LP24 with drive into F2 LP12, notes held.

Scene Before After
1 voice 42.6 k 35.7 k (−16%)
8 voices 148.9 k 131.4 k (−12%)
8 voices, positions moving 178.0 k 158.0 k (−11%)
8 × 4 unison, Dirty 246.2 k 199.1 k (−19%)
8 × 8 unison 330.3 k 250.1 k (−24%)
8 × 8 unison, positions moving 471.1 k 384.5 k (−18%)
8 × 8 unison, busy matrix 429.1 k 346.2 k (−19%)
  • SVF step rearranged. The filter is the same, with fewer operations. GCC had turned 2 v1 - ic1 into a multiply-add on -ic1, a negation and a register move per state per sample. LP24's loop went from 30 to about 19 instructions.
  • Bus transpose. Sources render into per-lane buses, which are transposed into the filters' layout four lanes by four samples at a time. A serial patch with nothing else routed to F2 filters F1's bus in place.
  • Unison stacks. The wavetable reader now takes a whole unison stack in one call.
    • It is compiled per level length, so its shifts are immediates.
    • It gets the interpolation fraction with a fixed-point convert.
    • It loads float pairs straight into q-register halves through a five-instruction asm block, which saves the five register moves GCC made per four samples.
    • It handles two voices per pass on the frame cache's float frames.
  • Drive is computed as dry · x + sat · softclip(x · pre) with a once-refined reciprocal. The Dirty engine's in-loop saturator keeps the full reciprocal.

Output matches the previous engine within 7.8e-6 relative RMS over 139 scenes rendered on ARM. The scenes cover every filter type, the engines, unison 1–8, routings, steals, glides, odd block sizes and busy matrices. Details are in docs/PERFORMANCE.md.

Not yet benched on the Force. qemu counts instructions, not cycles. Before merging, run make bench-device.

Review fixes

  • Replaying a note retriggered its old voice even above a lowered polyphony limit, and the next parameter change released it under the held key. The search for that voice now stays within the limit.
  • All Sound Off (CC 120) cleared the engine's sustain pedal while the note generator kept it down. The engine now keeps the pedal state through CC 120.
  • Loader::publish could free the playing table if push_back threw out of memory. It reserves the slot first.
  • A block that threw kept its MIDI events for the next block. They are cleared now.

Stop and suspend

MPC suspends and resumes the plugin within ~100 ms on every Stop. Each time, the engine was hard-reset: ringing voices stopped dead, which clicked and cut every tail. Now Stop releases them, as CC 123 does. CC 120 still silences at once.

Testing

  • make test (x86, ASan/UBSan) and make test-arm (qemu): 4125 checks pass, including three new regression checks. Each new check fails on the old code.
  • make test-arm-pgo passes against the shipped profile-guided objects.
  • Each commit builds and passes make test on its own.

🤖 Generated with Claude Code

Devko and others added 3 commits October 26, 2026 08:58
…20, loader OOM, stale MIDI)

From a full review of the engine and the plugin layer:
- The same note again searched every voice, also those above a lowered
  polyphony that ring out: one was revived there, and the next setPatch()
  released it under the held key. The search stays within the limit.
- All Sound Off (CC 120) cleared the engine's sustain pedal while NoteGen
  kept it down: key-offs then released until the next CC 64. reset() keeps it.
- Loader::publish moved the old table into the graveyard's push_back: out of
  memory there freed the table the audio thread was playing. It reserves the
  slot first.
- A block that threw kept its MIDI events for the next block to replay.

Regression checks for the first two in test/review_test.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n stacks)

Profiled by function and source line under qemu-arm (a TCG plugin counting
each translated block's executions):
- The SVF step rearranged, the same filter: the new ic1 is b1 ic1 + b2 v3,
  the new ic2 v2 + t; the band output only for the types that use it. GCC
  had made `2 v1 - ic1` a multiply-add on -ic1 (a negation and a move per
  state per sample). LP24's loop: 30 -> ~19 instructions.
- Sources render into per-lane buses, transposed into the filters' layout
  four lanes by four samples (gatherBuses): no scalar store per sample, no
  clearing. Serial with nothing else into F2: F2 filters F1's bus in place.
- The wavetable reader takes a whole unison stack per call, compiled per
  level length (immediate shifts), the fraction by a fixed-point convert,
  its float pairs loaded straight into q-register halves (asm: GCC moved
  registers five times per four samples), two voices per pass on float
  frames (one output load and store per pair).
- Drive: dry * x + sat * softclip(x * pre) with a once-refined reciprocal.

ARM instructions per block, profile-guided: 8 voices -12%, 8 x 8 unison
-24% (positions still) / -18% (moving) / -19% (busy matrix). The output is
within 7.8e-6 relative RMS of the previous engine over 139 scenes on ARM.
Not yet benched on the Force. Numbers in docs/PERFORMANCE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them

MPC suspends and resumes the plugin within ~100 ms on every transport Stop
(effStopProcess, effMainsChanged 0). The next block hard-reset the engine:
every ringing voice stopped dead, a click and every tail cut. It now
releases them as All Notes Off (CC 123) does; All Sound Off (CC 120) still
silences at once. A check in test/review_test.cpp, a line in the user guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Devko
Devko merged commit 52dc546 into main Oct 26, 2026
4 checks passed
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