Skip to content

Performance Research A01 Bulk VP to DSP Transfer

github-actions[bot] edited this page Sep 15, 2026 · 1 revision

Bulk VP-to-DSP transfer

A01 — Implementation and validation notes

Field Value
Evidence state Source-confirmed opportunity; bulk API not implemented by this review
Inspected source 322986f4c5502b3fa887a9605ac8cd88e9b2c579
First experiment One backend-owned 1,024-word mixbuffer write
Scope Addendum dated September 15, 2026; not a current-main benchmark or implementation status

Unproven performance research · Performance research — common test protocol · Performance research — reproducible checks

Evidence and implementation reasoning

Verified route. mcpx_apu_dsp_frame() converts every mixbin sample with float_to_24b() and calls dsp_write_memory() individually. That wrapper dispatches through DSPOps; the JIT wrapper then enters dsp56300_write_memory(). The dimensions are 32 mixbins by 32 samples. At nominal 48 kHz this is 1,024 writes per frame and 1,536,000 scalar writes per second. The word payload is only 6,144,000 bytes/s, so the motivation is repeated dispatch/mapping overhead, not a large memory-bandwidth requirement. Source: DSP frame, dispatch, constants.

Proposed implementation. Add a backend-owned bounded word-span operation. First support only the known X-space mixbuffer range. Convert samples using the unchanged conversion routine, then perform one bulk dispatch per frame. A generic DSP-memory bulk API can follow later, after DMA and program-memory invalidation are covered.

Important implementation trap. Do not write DSPState.core.xram directly. The JIT maintains separately owned X/Y/P buffers; the shared core is synchronized for save/load and engine switching. Its mixbuffer is an alias into JIT XRAM. A shortcut into the wrong array could appear to work in the interpreter while doing nothing useful—or restoring stale data—in the JIT. Resolve the span inside each backend. JIT memory ownership.

Gain model. One bulk call per frame replaces 1,024 dispatches with one, but does not remove conversion or stores. Assuming—not measuring—50 ns of removable overhead per scalar dispatch, the difference is 76.725 ms of one core per second. That is not a 7.67% FPS prediction: audio may already finish before its deadline.

Proof and acceptance. Compare all 1,024 destination words and both alias views; cover both engines, reset, save/load, engine switch, clipping, ties, and round mode. Preserve lrint, asymmetric signed-24-bit saturation, and the 24-bit mask. Benchmark packing, dispatch, conversion, total APU work, CPU blocking, and underruns separately. Conversion source.

First patch boundary

Support only the existing X-space mixbuffer first. Do not combine generic DMA spans, a new conversion algorithm, or DSP execution changes.

32 x 32 conversion + 1,024 backend calls -> unchanged conversion + one backend-owned span

Locate the inspected seam before editing; names or ownership may have changed since the pinned review:

git grep -n -E 'mcpx_apu_dsp_frame|dsp_write_memory|float_to_24b' -- hw/xbox/mcpx/apu

Proposed focused tests

These are implementation gates to add or exercise, not claims that production tests already exist or passed. Retained standalone checks are on the checks page.

Test ID Setup / deliberate control Required oracle
A01.01 Replay a deterministic 1,024-sample block through scalar and bulk paths on both engines. Include zero, signed extrema, clipping, and nearest-even ties. Every destination word matches; conversion and 24-bit masking are unchanged.
A01.02 Read the mixbuffer through its dedicated view and XRAM alias; repeat after reset, save/load, and engine switch. Both views identify the active backend memory and contain the same words.
A01.03 Request a span extending one word outside the admitted mixbuffer. The eligibility check rejects it or falls back; no unrelated memory is written.

Counters and rejection criteria

Collect: scalar_write_calls, bulk_write_calls, words_written, conversion_cpu_ns, transfer_cpu_ns, apu_frame_cpu_ns, underruns. Keep exact counts separate from sampled durations; use an uninstrumented build for performance qualification.

Reject or hold: Stop on any word/alias mismatch, lifecycle discrepancy, or new underrun. Lower dispatch count without lower total APU cost is not a performance win.

Follow the common protocol for source identities, previous-main/fixed-baseline controls, raw results, confidence and retail/XISO qualification. No gain becomes proven from a model, cache hit, local operation count, or shifted wait label alone.

Clone this wiki locally