Skip to content

Conversation

@roderickvd
Copy link
Member

@roderickvd roderickvd commented Jan 3, 2026

This PR speeds up cargo bench by approximately 7.5% on my MacBook Air M3.

I had expected that --features crossbeam-channel would have been even faster because its operations are lock-free, where std::sync::mpsc are not. However, the speedup is reduced slightly to 7.4%, probably because there isn't any contention to speak of.

Improvements:

  • Replace Vec with VecDeque for queue and output buffering and avoid O(n) remove(0) operations
  • Replace Mutex + Atomic pending list with a channel and consume via try_recv
  • retain_mut sources in-place to reduce allocations and copies

* Use VecDeque for output buffering and avoid O(n) remove(0) operations.
* Replace Mutex+Atomic pending list with a channel and consume via try_recv.
* Drain/retain_mut sources in-place to reduce allocations and copies.
@roderickvd roderickvd requested a review from yara-blue January 3, 2026 22:23
Replace the Vec used for next_sounds with VecDeque to avoid O(n)
shifts when removing from the front.
@roderickvd
Copy link
Member Author

1.7% faster on my Raspberry Pi 4 where other math operations dominate.

Copy link
Member

@yara-blue yara-blue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍

LGTM

@yara-blue yara-blue merged commit ca2ca66 into master Jan 4, 2026
9 checks 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.

3 participants