Skip to content

⚡ Bolt: optimize hot loop and eliminate redundant audio buffering#3

Merged
kassoulet merged 1 commit into
mainfrom
bolt-optimize-hot-loop-5961411998986729976
May 4, 2026
Merged

⚡ Bolt: optimize hot loop and eliminate redundant audio buffering#3
kassoulet merged 1 commit into
mainfrom
bolt-optimize-hot-loop-5961411998986729976

Conversation

@kassoulet

Copy link
Copy Markdown
Owner

💡 What: Optimized the core audio processing loop by eliminating per-block heap allocations and reducing redundant audio data copying.

🎯 Why: The original implementation was allocating several `Vec`s on every processing block and performing an extra copy of the audio data before passing it to the plugins. This overhead added up, particularly when using many plugins or small block sizes.

📊 Impact: Reduces overall rendering time by approximately 5% (measured on a single-plugin chain with block size 128). More importantly, the hot loop now achieves zero heap allocations, making it much more efficient and predictable.

🔬 Measurement:
Performance was verified using `time` on a standard rendering task:

  • Before: ~0.57s average for block-size 128.
  • After: ~0.54s average for block-size 128.
    Correctness was verified with the existing test suite (`cargo test`).

PR created automatically by Jules for task 5961411998986729976 started by @kassoulet

- Refactored `process_audio` to remove redundant intermediate `decode_buffer`.
- Added `copy_to_planar_f32` for direct copying from Symphonia buffers to planar plugin buffers.
- Implemented `run_instance` helper using iterators to eliminate per-block `Vec` allocations for plugin port connections.
- Fixed a potential panic in channel copying by adding bounds checks.
- Maintained backward compatibility by keeping the original `pub copy_to_f32_buffer` API.
- Measurably improved performance, especially for smaller block sizes.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@kassoulet
kassoulet merged commit f3b2495 into main May 4, 2026
1 check passed
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