Skip to content

perf: optimize audio processing hot paths (mixer, transformers, buffer pool, worker IPC)#210

Open
quiverdev wants to merge 2 commits into
PerformanC:v3from
quiverdev:v3
Open

perf: optimize audio processing hot paths (mixer, transformers, buffer pool, worker IPC)#210
quiverdev wants to merge 2 commits into
PerformanC:v3from
quiverdev:v3

Conversation

@quiverdev

@quiverdev quiverdev commented Jun 15, 2026

Copy link
Copy Markdown

Changes

This PR implements a series of high-impact performance optimizations targeting the hot paths of NodeLink's audio processing engine:

  1. Audio Mixing – Refactored the inner loop of AudioMixer.mixBuffers to pre-filter active layers and use local array references, significantly reducing CPU cycles spent on property lookups and conditional logic.
  2. Transformers – Added specialized logic to VolumeTransformer and FadeTransformer to skip expensive calculations when gain remains constant between frames.
  3. Math Optimizations – Replaced division operations with multiplications by pre-calculated inverses in LoudnessNormalizer and implemented a Taylor series approximation for the soft-knee limiter in VolumeTransformer.
  4. Memory Management – Increased default BufferPool capacity to reduce allocation frequency under load. Added RingBuffer.readTo to allow direct copying into existing buffers, avoiding unnecessary Buffer object allocations.
  5. Worker IPC – Rounded floating-point numbers in the worker statistics payload to decrease the size of serialized data transmitted between processes.

Why

These optimisations collectively improve both CPU throughput and RAM stability by reducing garbage collection pressure and instruction counts in real-time audio streams. The changes make NodeLink more efficient under high concurrency and heavy audio load, which is critical for production deployments.

Checkmarks

  • The modified endpoints have been tested.
  • Used the same indentation as the rest of the project.
  • Still compatible with LavaLink clients.

Additional information

No additional information at this time.

quiverdev and others added 2 commits June 15, 2026 04:20
- Optimized the core mixing loop in `AudioMixer` to reduce property lookup overhead and avoid per-layer object allocations.
- Enhanced `VolumeTransformer` and `FadeTransformer` with specialized paths for constant gain and fast math approximations for the limiter.
- Improved `LoudnessNormalizer` efficiency by using pre-calculated reciprocals and optimizing local variable access.
- Tuned `BufferPool` constants for better allocation reuse and added a `readTo` method to `RingBuffer` for zero-allocation reads.
- Optimized Worker IPC by rounding telemetry statistics to reduce serialization overhead.
- Implemented these changes without breaking existing functionality or removing features.
…468960965277556

Performance Optimizations for RAM and CPU Efficiency
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

All Contributors have signed the CLA. The PR is now allowed to be merged.
Posted by the CLA Assistant Lite bot.

@quiverdev

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

performanc-bot added a commit to PerformanC/CLA-Signatures that referenced this pull request Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant