-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experiment with thread local pool of audio render quanta #511
base: main
Are you sure you want to change the base?
Conversation
/bench |
|
a1f0270
to
d915944
Compare
/bench |
|
Interesting regression on the delay nodes between version one and two.. 🤔 |
I can't reproduce the regression locally (not with cargo bench, and also the example/benchmarks.rs shows improvement for the delay test..) Let's try again /bench |
|
/bench |
|
Hey @b-ma , the idea for this change was growing for a long time on me. Happy to see some benchmark improvements again. Could you have a look? I'm certainly interested what |
Hey, I'm a bit out of networks this week-end, I'll have a look on Monday |
Hey, so on my side:
do we agree that I have run |
src/render/quantum.rs
Outdated
} | ||
thread_local! { | ||
/// Thread local pool of pre-allocated sample slice that can be reused after being dropped | ||
static POOL: RefCell<Vec<Rc<[f32; RENDER_QUANTUM_SIZE]>>> = RefCell::new(Vec::with_capacity(32)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we shouldn't have a larger initial pool? As a stereo delay of 1 second (default max_delay_time
) uses 375 * 2 AudioRenderQuantumChannel
, having something like 1024 preallocated buffers would guarantees we don't allocate at least when creating one delay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. We could definitely do it but we should realize this could happen on any thread and the memory is never reclaimed, so to be a bit conservative would not be bad.
I'm having a bit more thoughts about this setup though, when using async rendering the OfflineAudioContext can move to any thread of the executor and we may end up leaking a lot of memory.
I could specialize it to be of different size for offline and online rendering. Starting with a small pool for offline rendering is not bad because we can safely allocate more during rendering.
Yup that's how it works. Weird that your sines seem to be affected because none of this PR should matter there.. |
Yup I agree... this is quite weird |
It is still a bit magical to me and I want to see when a new pool is initialized.
/bench |
|
With the new design of 'silent quantum' we can also instantiate silent buffers on the control thread.
/bench |
|
No description provided.