SPB Git

Repository Public

performance.md 18.7 KB

# Performance

This document collects every performance figure that has actually been measured for ORIX DJ, with the machine, the build and the conditions of each measurement, and lists what has not been measured. No figure here is an estimate. The architecture behind the numbers is described in audio-engine.md, deck-engine.md, mixer.md and dsp.md.

# Sources of the numbers

Source Produced by Build
engine-benchmark.txt orix-dj-bench bench release
real-music-analysis.tsv orix-dj-bench analyze <folder> release
Test log blocks === ORIX-SYNC ===, === ORIX-AUTOMATION-TIMING ===, === ORIX-RENDER-COST (debug build) ===, === ORIX-ANALYSIS-TIMING === swift test --no-parallel in Packages/ORIXDJCore, run on 2026-11-21 debug
Two offline mixes orix-dj-bench mix release

Machine for all of them: Apple M5 Max (18 cores, 48 GB), macOS 27.0 (build 26A5425a), Swift 6.4.2. The benchmark header itself records "Apple M5 Max, macOS Version 27.0 (Build 26A5425a), 20.0 s of audio per case, single render thread, 48 kHz".

# What "offline" means here

Every figure in this document except where stated was obtained by offline rendering: DJEngine.renderOffline calls RenderCore.render in a loop from an ordinary thread of a command-line process or of the test runner. It is the same render function the Core Audio callback calls, but:

  • the thread is not a real-time thread. The operating system may preempt it at any moment, and the time it spends descheduled is included in the measured block time. The maxima in the tables below therefore include scheduler preemption and are not the worst-case cost of the code. Means and 99th percentiles are much less affected.
  • there is no audio device, no device clock and no competing audio I/O;
  • the machine was otherwise idle apart from normal background activity; no load was applied on purpose.

No live measurement with an audio interface was taken. The benchmark tool has a live command (see below), but the report contains no output from it, and no multi-channel interface was attached to the development machine. Callback jitter, overloads under real-time scheduling, behaviour at small buffers on real hardware and round-trip latency are all unmeasured.

# How the benchmark is produced

The tool is the orix-dj-bench executable target of the core package (main.swift, Benchmarks.swift, RealMusic.swift). From Packages/ORIXDJCore:

sh
swift run -c release orix-dj-bench bench            # the report; optional argument: seconds per case (default 20)
swift run -c release orix-dj-bench analyze <folder>  # the TSV table for a folder of audio files
swift run -c release orix-dj-bench mix <a> <b> <out.wav> [preset]
swift run -c release orix-dj-bench devices           # list output devices with reported latency
swift run -c release orix-dj-bench live [seconds] [buffer]

A debug build prints a warning at the top of the bench output. Its other commands, docs and check, concern ORIX Script (automation.md).

bench runs, in order:

  1. Render cost (measureRender). A 48 kHz engine is created with the requested buffer size. Each deck gets a synthetic track from SignalSynth.track at 44.1 kHz, so sample-rate conversion is part of every case. Decks are assigned through the crossfader, fader at −9 dB, low EQ at −4 dB, filter knob at 0.15; with key lock, the rate is 1.04. The "14 effects" cases add echo, flanger and compressor on each of the four channel racks and reverb and delay on the master rack. The master limiter is on in every case (it is on by default). After one second of warm-up, each block is rendered separately and its duration is taken from EngineRenderState.lastRenderNanos, which render measures itself with mach_absolute_time from entry to exit. The table reports mean, 99th percentile, maximum, the block's real-time budget (buffer / 48000), load (mean / budget) and the number of clipped blocks.
  2. Effects. Each of the 18 units is created, enabled, and fed 4000 blocks of 512 frames of white noise; the mean wall-clock time per block is reported. The table is in dsp.md.
  3. Time stretching (measureStretch). A 440 Hz sine at 48 kHz is played for 8 s with key lock at seven rates, limiter off. Pitch is measured from interpolated zero crossings after the first second; the residual is the energy that is not the fundamental at the measured frequency; playhead speed is the deck position after 8 s divided by 8.
  4. Analysis. One 5-minute 44.1 kHz stereo synthetic track is analysed once, timed with wall-clock time.
  5. Automation scheduling (measureAutomation). Two automations run for the whole duration on a 128 BPM click track with 256-frame buffers: one issues sixteen parameter writes on every beat, the other runs continuous ramps on a filter, the crossfader and a fader. The scheduler is ticked once per block by AutomationHost.renderOffline.

# Render cost (release, offline)

From engine-benchmark.txt. Times are per render call.

Case Buffer (frames) Mean (µs) p99 (µs) Max (µs) Budget (µs) Load Clipped
2 decks, EQ + filter 64 2.8 10.8 179.0 1333 0.21 % 0
2 decks, EQ + filter 128 5.6 17.6 89.7 2667 0.21 % 0
2 decks, EQ + filter 256 10.8 25.7 109.2 5333 0.20 % 0
2 decks, EQ + filter 512 22.0 49.4 132.0 10667 0.21 % 0
2 decks, key lock 256 12.7 41.5 106.0 5333 0.24 % 0
4 decks, EQ + filter 256 18.6 39.8 178.9 5333 0.35 % 0
4 decks, key lock, 14 effects, limiter 256 61.2 124.7 396.8 5333 1.15 % 0
4 decks, key lock, 14 effects, limiter 64 15.3 48.8 173.7 1333 1.14 % 0

Reading the table:

  • The mean scales with the buffer size, so the load is roughly constant per configuration. The heaviest case measured uses 1.15 % of one core on this machine.
  • The maxima do not scale with the buffer (179.0 µs at 64 frames against 132.0 µs at 512), which is consistent with them being dominated by preemption rather than by the work in the block, as explained above. In the heaviest case at 64 frames the maximum, 173.7 µs, is 13 % of the 1333 µs budget.
  • With key lock the cost is uneven by construction: the stretcher synthesises a 1024-frame hop at a time, so a block that triggers a hop costs more than one that only reads the FIFO. This shows in the p99 of the key-lock case (41.5 µs against 25.7 µs without).
  • These are results for one machine. No measurement exists on older or slower Macs.

For reference, the test suite prints the same kind of figure from an unoptimised debug build running under the test runner (renderCostFullLoad: four decks with key lock, twelve channel effects, three master effects, limiter, 256-frame buffers): mean 3098 µs, maximum 69 046 µs, 58 % of the 5333 µs budget over 1875 blocks. This is not a performance result. It is quoted to show how much the optimiser matters and why the release benchmark, not the test log, is the reference; the test only asserts that more than 1000 blocks were rendered.

# Time stretching (release, offline)

From engine-benchmark.txt: 440 Hz sine, 48 kHz, key lock on.

Rate Measured pitch Error Residual below the tone Playhead speed
0.84 440.002 Hz +0.01 cents 40.5 dB 0.8396
0.92 440.014 Hz +0.06 cents 29.0 dB 0.9213
0.96 440.015 Hz +0.06 cents 46.5 dB 0.9612
1.00 440.000 Hz +0.00 cents 99.5 dB 1.0000
1.04 439.985 Hz −0.06 cents 160.2 dB 1.0388
1.08 439.989 Hz −0.04 cents 25.6 dB 1.0804
1.16 440.000 Hz +0.00 cents 37.9 dB 1.1584

The pitch is held within 0.06 cents. The residual, which is everything in the output that is not the fundamental (amplitude modulation and splice artefacts of the overlap-add), varies strongly with the rate, from 25.6 dB to 160.2 dB below the tone, because it depends on how the splice period relates to the period of the test tone. A steady sine is a favourable and narrow test: it says nothing about transients, polyphonic material or stereo content, and nobody has listened to the stretcher's output. The method and its limits are described in deck-engine.md.

The header of this section in the report also mentions "120 BPM clicks"; the click measurement is done in the test suite (keyLockPreservesBeatTiming, tolerance 12 ms), not in the benchmark tool.

# Timing accuracy (debug, offline)

From the test log of 2026-11-21.

Sync. syncMatchesTempoAndPhase plays a 120 BPM click track on deck A and syncs a 126 BPM click track whose first beat is 80 ms into the file on deck B, then compares click onsets on the two output channels:

text
=== ORIX-SYNC === mean 0.006628787878787879 ms, worst 0.020833333333333332 ms over 22 beats === END ===

The worst offset, 0.0208 ms, is one sample at 48 kHz. The test's tolerance is 3 ms. The tracks are synthetic clicks with exact beat grids, so this measures the sync mechanism, not the accuracy of beat detection on music (for that see analysis.md).

Automation. scriptActionsLandOnExactSamples schedules deck starts and a pause on bar and beat boundaries from an ORIX Script and compares the started deck's clicks with the master deck's clicks:

text
=== ORIX-AUTOMATION-TIMING === tracked 3 late 0 maxLate 0 samples; worst click offset 0 samples === END ===

Three timed commands, none late, zero samples of offset. The test allows 2 samples and requires lateEvents == 0. It sets the scheduler look-ahead to 20 ms.

Automation under load (release, from engine-benchmark.txt, 256-frame buffers):

Quantity Value
Scheduler ticks 3750
Tick duration, mean 2.5 µs
Tick duration, max 343.9 µs
Timed commands 687
Late commands 0
Worst lateness 0 samples
Dropped control events 0
Runtime errors 0

Two caveats. First, offline the scheduler is ticked exactly once before each block, so "0 late" shows that the scheduling arithmetic and the sub-block event splitting are exact; it does not show how the scheduler thread behaves when it competes for CPU in the running application, where it wakes every 4 ms under the Mach time-constraint policy. Second, the report's section title says "15 ms look-ahead", but measureAutomation does not set the look-ahead and the default of AutomationHost.lookaheadSeconds in the source is 0.03; the title is a fixed string and may not reflect the value in effect.

# Analysis speed

Synthetic track. One 5-minute 44.1 kHz stereo track:

Build Time Source
release 0.294 s engine-benchmark.txt
debug, single thread, best of 3 0.747 s test log, === ORIX-ANALYSIS-TIMING ===

Both runs returned 126 BPM (truth 126), a first beat at 0.081 s (truth 0.080) and G minor (truth G minor).

Real music. orix-dj-bench analyze was run on 60 commercial tracks from the owner's library. The footer of real-music-analysis.tsv reads:

text
# 60 files, 0 failed, 12449 s of audio analysed in 32.0 s (389× real time)

The 32.0 s is the sum of the analysis times only. Decoding is timed separately per file (decode_s): the column sums to 29.2 s, with a range of 0.10 s to 2.48 s per file; analysis ranges from 0.05 s to 1.98 s per file. Files are processed one after the other on one thread. Decode time depends on the codec and on the file cache and was measured once. The accuracy of the results on these tracks is discussed in analysis.md; the table has no ground truth for them.

In the application, analysis runs on a background queue one track at a time (DJSession.analyzePending), and a track that has no stored analysis is analysed during its first load onto a deck.

# Latency

# Output latency shown by the application

The latency the application reports is

text
output latency = device-reported latency + one buffer

where the device-reported part is AudioDeviceInfo.latencyFrames, computed in AudioOutput.swift as kAudioDevicePropertyLatency + kAudioDevicePropertySafetyOffset + the latency of the first output stream. It is displayed in two places:

  • the status bar, as "… ms out", from AppModel.outputLatencyMillis ((latencyFrames + bufferFrames) / sampleRate), in AppModel.swift and RootView.swift;
  • Settings → Audio, as three read-outs: "Buffer latency", "Device latency (reported)" and "Total output latency", in AudioSettingsTab.swift, with the note that Bluetooth devices add latency the system does not report.

The buffer part is arithmetic: at 48 kHz, 64 frames are 1.33 ms, 128 are 2.67 ms, 256 (the default) are 5.33 ms, 512 are 10.67 ms.

This figure is a computed value from what the device declares. It has not been compared with a physical measurement (loopback or microphone), and it leaves out the following, which follow from the code:

  • the master limiter's 5 ms look-ahead when the limiter is on (it is on by default);
  • any additional buffering inside the HAL or the device beyond what it reports, including Bluetooth codecs;
  • the time between a user action and the next render call: an untimed control event takes effect at the start of the next buffer, so up to one more buffer;
  • the interface itself, which refreshes at 30 Hz, and MIDI input delivery.

orix-dj-bench devices prints the reported latency of each output device, and orix-dj-bench live would open the default device with the master at −60 dB and report callback times measured on the real-time thread, scheduler tick gaps and automation lateness. No output of either command is part of the reports.

# Other fixed delays

Element Delay Source
Parameter changes ramped over at least 4 ms RenderCore.rampSamples
Transport de-click 4 ms decaying offset, audio not delayed DeckVoice
Effect enable, disable, mix 12 ms cross-fade EffectUnit
Limiter (master or rack) 5 ms look-ahead LimiterEffect
Recording writer drains every 40 ms (does not affect audio) Recorder

# Memory

# Decoded tracks

A loaded track is held entirely in memory as planar 32-bit float stereo at the file's sample rate (TrackBuffer.swift): byteSize = frameCount * 2 * 4, that is 8 bytes per frame, whatever the source format or channel count.

File sample rate Per minute 5-minute track At the 150-minute cap
44.1 kHz 21 168 000 bytes (21.2 MB) 105.8 MB 3.18 GB
48 kHz 23 040 000 bytes (23.0 MB) 115.2 MB 3.46 GB
96 kHz 46 080 000 bytes (46.1 MB) 230.4 MB 6.91 GB

(MB and GB are decimal: 10^6 and 10^9 bytes.) These values are computed from the format, not measured from the process. Consequences:

  • four loaded 5-minute tracks at 44.1 kHz hold about 423 MB of sample data;
  • TrackBuffer.maxSeconds is 150 minutes; a longer file is refused with a message. A file at the cap is accepted, and the table shows what that costs. There is no check against available memory;
  • a compressed file expands by the ratio between its bit rate and 2822 kbit/s (44.1 kHz) or 3072 kbit/s (48 kHz);
  • background analysis decodes one more track at a time into its own buffer, released when that track is done.

# Fixed allocations of the engine

Computed from the constants in the code, for a 48 kHz engine:

Allocation Size
Recording ring (AudioRing, 524 288 frames × 2 channels × 4 bytes) 4.2 MB, allocated whether or not a recording is running
Delay or echo unit (2 lines of 262 144 samples) 2.1 MB per unit
Beat repeat unit (ring of 262 144 frames plus a 4 s loop buffer, stereo) about 3.6 MB per unit
Mix buffers (6 × 4096 floats) 98 kB
Event queue (8192 slots) and pending list (512 slots) well under 1 MB

The resident memory of the running application has not been profiled, and no measurement of waveform, library or interface memory exists.

# Real automated mixes

Two complete transitions between commercial tracks were rendered offline with orix-dj-bench mix, which decodes two files, analyses them, applies the suggested gain and key lock, starts the first deck, runs a preset script from the library (the preset turns sync on for the incoming deck), and writes the master output of the 48 kHz engine to a 16-bit WAV file.

Preset Tracks Result printed by the tool Analysis of the rendered file
Bass Swap a 124 BPM track into a 122 BPM track deck B played at 124.00 BPM; 10 timed commands, 0 late; 0 clipped blocks; peak −6.99 dBFS 124.00 BPM, tempo stability 0.98
Eight Bar Transition two 119 BPM tracks 9 timed commands, 0 late; peak −3.71 dBFS 119.00 BPM, tempo stability 0.98

These runs show that the whole chain (decode, analysis, sync with key lock, script execution, mixing) completes on real material with exact command timing and without clipping, and that the tempo of the result is steady through the transition. Nobody has listened to these two files yet. Whether the transitions sound right, whether the beats of the two tracks are audibly aligned and whether key lock is acceptable on this material is not established by these numbers.

# Not measured

  • Anything on the real-time thread with a real device: callback duration distribution, overloads, the smallest usable buffer, behaviour under system load.
  • Physical output latency and input-to-sound latency (interface or MIDI controller to speaker).
  • Any machine other than the M5 Max; Intel is not a target (arm64 only).
  • CPU cost of parameter sweeps, of the first block after an effect bypass, and of 88.2 or 96 kHz operation.
  • Aliasing of the cubic resampler and listening quality of key lock and of the effects.
  • Memory footprint of the running application, energy use, and the cost of the Metal waveform renderer (waveform.md).
  • Long sessions: the longest continuous offline renders are the benchmark cases (20 s each) and the test and mix runs of a few minutes.

See testing.md for the test suites that produce the test-log figures and for how to rerun them, and setup.md for building the package.

Files main
Menu

Theme