Repository Public
1<!--2ORIX Sonata3File: Documentation/manual/performance.md4Author: Simon-Pierre Boucher5Contact: contact@spboucher.ai6-->7# Performance89This chapter reports what was measured, how, and on what. The figures describe one machine on10one day; they are measurements, not promises. Run `sonata benchmark` to get yours.1112## Protocol1314* **Machine.** MacBook Pro, Apple M5 Max, 18 cores, 48 GB, macOS 27.0.15* **Build.** Release build of the command-line tool (`cargo build --release`), measured16 2026-11-24.17* **Method.** `sonata benchmark --seconds 4`. Each case compiles a composition, prepares it18 and drives the real-time processor on one thread in blocks of 128 or 256 frames at 48 kHz,19 for 4 seconds of audio after a warm-up. No audio device is involved: the engine is timed20 alone. The engine measures the duration of every callback itself.21* **What is reported.** The time available for a block (the *budget*: 2 667 µs for 128 frames22 at 48 kHz), the mean, median (p50), 99th percentile (p99) and maximum time actually taken,23 the p99 as a percentage of the budget, and the number of callbacks that took longer than24 their budget (*missed*). Percentiles are upper bounds of 5 µs buckets.2526The percentiles matter more than the mean: one late block is a click, however fast the27average.2829## Voices3031Each case holds N notes at once on one instrument for the whole measurement.3233| Case | Block | Budget | Mean | p50 | p99 | Max | p99 / budget | Missed |34|---|---|---|---|---|---|---|---|---|35| SynthLead × 1 | 128 | 2 667 µs | 6 µs | 10 µs | 10 µs | 28 µs | 0.4 % | 0 |36| SynthLead × 16 | 128 | 2 667 µs | 64 µs | 60 µs | 120 µs | 132 µs | 4.5 % | 0 |37| SynthLead × 64 | 128 | 2 667 µs | 209 µs | 210 µs | 240 µs | 294 µs | 9.0 % | 0 |38| SynthLead × 128 | 128 | 2 667 µs | 402 µs | 405 µs | 445 µs | 550 µs | 16.7 % | 0 |39| SynthLead × 256 | 128 | 2 667 µs | 788 µs | 790 µs | 865 µs | 1 149 µs | 32.4 % | 0 |40| SynthLead × 256 | 256 | 5 333 µs | 1 547 µs | 1 540 µs | 1 830 µs | 2 090 µs | 34.3 % | 0 |41| GrandPiano × 1 | 128 | 2 667 µs | 8 µs | 10 µs | 15 µs | 40 µs | 0.6 % | 0 |42| GrandPiano × 16 | 128 | 2 667 µs | 63 µs | 60 µs | 115 µs | 131 µs | 4.3 % | 0 |43| GrandPiano × 64 | 128 | 2 667 µs | 221 µs | 220 µs | 310 µs | 398 µs | 11.6 % | 0 |44| GrandPiano × 64 | 256 | 5 333 µs | 443 µs | 440 µs | 550 µs | 719 µs | 10.3 % | 0 |4546On this machine, 64 simultaneous piano voices use about a tenth of one core's time at 12847frames, and 256 synthesizer voices about a third, with no missed deadline in these runs.4849What these figures do **not** say: they are for one thread, without a real audio device and50without other programs competing for the processor; they cover two instruments, without51effects. Higher voice counts and other engines were not measured here, and nothing is claimed52about them.5354## A complete piece5556`sonata benchmark Examples/multitrack_band.sonata --seconds 8`: six instrument tracks, two57buses, compressors, a reverb, a delay, an equaliser and the limiter.5859| Block | Budget | Mean | p50 | p99 | Max | p99 / budget | Missed |60|---|---|---|---|---|---|---|---|61| 128 | 2 667 µs | 42 µs | 45 µs | 60 µs | 183 µs | 2.3 % | 0 |62| 256 | 5 333 µs | 83 µs | 85 µs | 130 µs | 243 µs | 2.4 % | 0 |6364## Offline rendering6566`sonata render`, release build, 24-bit WAV at 48 kHz, wall-clock time including compilation,67measurement and writing the file:6869| Example | Audio | Render time | Speed |70|---|---|---|---|71| aurora | 4.4 s | 0.05 s | 95× real time |72| string_quartet | 20.3 s | 0.19 s | 105× |73| mallet_phasing | 17.5 s | 0.14 s | 128× |74| multitrack_band | 12.8 s | 0.21 s | 62× |75| multitrack_band at 192 kHz | 12.8 s | 0.81 s | 16× |76| ambient_drift | 65.3 s | 6.1 s | 11× |7778`ambient_drift` is slow for a reason worth knowing: it uses the convolution reverb, which is79by far the most expensive effect.8081## Compilation8283Time spent in each stage, from `sonata inspect --json` (release build, one run each):8485| Example | Notes | Lexing | Parsing | Semantics |86|---|---|---|---|---|87| aurora | 8 | 57 µs | 90 µs | 156 µs |88| lofi_keys | 157 | 67 µs | 100 µs | 253 µs |89| multitrack_band | 162 | 86 µs | 115 µs | 399 µs |9091A piece of this size compiles in well under a millisecond, which is what makes compiling on92every keystroke and hot reload practical. The console of the app shows the time of each93compilation, and whether the result came from the cache.9495## In the app9697While a piece plays, the status bar shows the 99th percentile of the callback time and the98number of voices; the mixer panel adds the median, the maximum and the number of overruns99(callbacks that exceeded their budget). These are measured on the real audio device.100101## Advice102103* The safety limiter and the meters cost almost nothing; leave them on.104* A reverb on a bus, shared through sends, costs once; the same reverb on eight tracks costs105 eight times.106* Convolution is expensive; the algorithmic `reverb` is not.107* Long release times keep voices alive: 64 notes with a 5 s release can be 64 voices.108* If you hear clicks, look at the overrun counter first. Zero overruns means the cause is in109 the music (a hard cut, a clipped level), not in the engine.110