Skip to content

Performance Research A11 Attenuation Lookup Table

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

Exact finite-domain volume attenuation table

A11 — Implementation and validation notes

Field Value
Evidence state All 65,536 inputs match in standalone same-environment C checks; product patch pending
Inspected source 322986f4c5502b3fa887a9605ac8cd88e9b2c579
First experiment Table initialized with the unchanged attenuation expression
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

Direct source support. attenuate(uint16_t) masks its input to 12 bits, returns zero for 0xfff, and otherwise calls powf. Normal mixing calls it once for each of eight mixbins per processed voice. There are only 4,096 distinct inputs, so a float table requires 16,384 bytes. Function and callers.

Why this is stronger than a generic cache. The table is indexed by the complete input, has no eviction policy, and does not require observing guest memory writes. Populate it once, before workers run, using the same calculation and floating-point environment as the reference path. Do not introduce lazy initialization races or startup work into the audio deadline.

Executed check. A standalone C reduction compared the original function against the table for every one of the 65,536 uint16 inputs, including the high-bit mask and mute sentinel. There were zero bitwise mismatches at both -O0 and -O2 on the recorded host toolchain. This is a same-environment result, not a claim that different libm implementations or floating-point modes produce identical tables.

Gain model. At the maximum 256 active voices, eight mixbins, and nominal 1,500 audio frames/s, the upper activity model is 3.072 million attenuation evaluations per second. Actual activity may be far lower. The table removes those transcendental evaluations, not the rest of mixing. First compare isolated function cost and total APU CPU time; then qualify fixed-work retail output and frame/audio tails.

Caveats. Retain the exact mute sentinel, input mask, rounding behavior, and initialization environment. A generated approximate decibel curve is a different change and does not inherit this equivalence result.

First patch boundary

Retain mask, mute sentinel and exact expression. Initialize before audio workers with the reference floating-point environment; no lazy race or approximate curve.

masked 12-bit volume -> powf per use; candidate: same expression once per value -> indexed float load

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

git grep -n -E 'attenuate|voice_work_init|voice_process' -- hw/xbox/mcpx/apu/vp

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
A11.01 Exhaust all uint16 values 0..65535 using the original expression and the populated 4,096-entry table. Zero float-bit mismatches; high bits mask identically and 0xfff is zero.
A11.02 Repeat on supported production compilers/architectures and the documented worker rounding environment. Each deployment matches its own reference; cross-libm equivalence is not assumed.
A11.03 Cold initialization, worker startup, reset and prolonged active mixing with varying volumes. No initialization race or in-window allocation; PCM and underruns remain qualified.

Counters and rejection criteria

Collect: attenuate_calls, table_lookups, init_cpu_ns, lookup_cpu_ns, apu_cpu_ns, pcm_mismatches, underruns. Keep exact counts separate from sampled durations; use an uninstrumented build for performance qualification.

Reject or hold: Reject any float/PCM mismatch outside a deliberately separate behavior change. A same-environment lookup proof does not establish game FPS gain.

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