Closed Bug 2089739 Opened 11 days ago Closed 17 hours ago

Compute WebAudioUtils::ConvertDecibelsToLinear(dB) using fdlibm_expf(dB * ln(10)/20) instead of fdlibm_powf(10.0f, 0.05f * dB) to improve performance

Categories

(Core :: Web Audio, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: perf-ai-bot, Assigned: kats)

References

(Blocks 1 open bug)

Details

(Whiteboard: [foofrix:f416b52f-8233-4c37-9304-e3af391c7074][fxpe])

Attachments

(1 external file)

Compute WebAudioUtils::ConvertDecibelsToLinear(dB) using fdlibm_expf(dB * ln(10)/20) instead of fdlibm_powf(10.0f, 0.05f * dB). This avoids general-purpose power computation in DynamicsCompressorKernel's per-frame detector release-rate calculation and above-knee saturation, and also affects its curve setup, gain, and envelope calculations. The implementation retains fdlibm for cross-platform consistency, but floating-point rounding changes: differences depend on the input and are not uniformly bounded by a few ulps. The submitted OfflineAudioContext highpass->compressor->gain measurement reports output differences up to approximately 2e-6 absolute and 7e-6 relative, and reduction differences around 2e-5 dB; these are measurements for that graph, not universal bounds. Outside DynamicsCompressorKernel, AudibilityMonitor uses the helper for its constant -72 dB threshold. This optimization composes with separately skipping unused detector release-rate computation during attack.

Problem

Media-Conferencing's VoiceChat step renders 30 s of stereo audio through an OfflineAudioContext graph with a DynamicsCompressorNode (Source -> Biquad -> Compressor -> Gain -> StereoPanner) and the step time is bound by the MediaTrackGraph thread. In the baseline profile, fdlibm_powf alone was ~28% of the MediaTrackGraph thread's samples during VoiceChat (via WebAudioUtils::ConvertDecibelsToLinear called per sample from DynamicsCompressorKernel::process), the largest single hotspot. With the change, VoiceChat-sync went from 450.0 ms to 366.6 ms median (min 449.1 -> 366.2) in profiled media-tag runs; media-tag score 1.565 -> 1.623 (+3.7%, 4/4 interleaved rounds positive); full SP4-experimental interleaved A/B 4.330 -> 4.365 (+0.82% paired over 6 rounds, 5/6 positive).

Performance

  • Benchmark: speedometer4
  • Test: sp4-full
  • Component: Media
  • Local Improvement: 0.85%

Validation

Blocks: speedometer3

Please move this bug to the correct component.

Once the Phabricator patch is ready for review, please commandeer it.

Compute WebAudioUtils::ConvertDecibelsToLinear(dB) using fdlibm_expf(dB * ln(10)/20) instead of fdlibm_powf(10.0f, 0.05f * dB). This avoids general-purpose power computation in DynamicsCompressorKernel's per-frame detector release-rate calculation and abo

Assignee: nobody → kats
Summary: Compute WebAudioUtils::ConvertDecibelsToLinear(dB) using fdlibm_expf(dB * ln(10)/20) instead of fdlibm_powf(10.0f, 0.05f * dB). This avoids general-purpose power computation in DynamicsCompressorKernel's per-frame detector release-rate calculation and abo → Compute WebAudioUtils::ConvertDecibelsToLinear(dB) using fdlibm_expf(dB * ln(10)/20) instead of fdlibm_powf(10.0f, 0.05f * dB) to improve performance

I had claude cook up a microbenchmark to verify these results:

iterations/rep=20000000 reps=7 (best-of)

input range                kind         old ns/call  new ns/call   speedup
typical  [-60, 12] dB      throughput         17.71         2.03     8.71x
                           latency            30.17        14.37     2.10x
wide     [-150, 100] dB    throughput         16.49         2.18     7.57x
                           latency            29.64        15.18     1.95x

The benchmark also computed the max ULP diff in the output between the two versions:

Grid sweep, -200..+100 dB, step 0.001 dB
  inputs tested        : 300000 (300000 finite results)
  bit-different outputs: 246165 (82.06%)
  max absolute diff    : 0.109375 at 99.4199982 dB
  max relative diff    : 2.33248625e-06 at -177.505005 dB
  max ULP diff         : 38 at -186.722 dB (mean 3.8072)

Practical range, -100..+24 dB, step 0.0001 dB
  inputs tested        : 1240000 (1240000 finite results)
  bit-different outputs: 863109 (69.61%)
  max absolute diff    : 4.76837158e-06 at 23.0547009 dB
  max relative diff    : 1.22834831e-06 at -82.9649963 dB
  max ULP diff         : 19 at -96.6132965 dB (mean 1.9535)

I'm assuming the difference in output is minor enough that it's worth taking for the performance benefit here. I'll clean up the patch and put up for review.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Type: defect → enhancement
Component: Performance: Automated Findings → Web Audio
Attachment #9675164 - Attachment description: WIP: Bug 2089739 - Compute WebAudioUtils::ConvertDecibelsToLinear(dB) using fdlibm_expf(dB * ln(10)/20) instead of fdlibm_powf(10.0f, 0.05f * dB). This avoids general-purpose power computation in DynamicsCompressorKernel's per-frame detector release-rate → Bug 2089739 - Use faster exponentiation function. r?padenot
See Also: → 2093385
Whiteboard: [foofrix:f416b52f-8233-4c37-9304-e3af391c7074] → [foofrix:f416b52f-8233-4c37-9304-e3af391c7074][fxpe]
Status: NEW → RESOLVED
Closed: 17 hours ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: