Skip to content
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

Buffered slave threads #355

Open
olofson opened this issue Oct 12, 2022 · 0 comments
Open

Buffered slave threads #355

olofson opened this issue Oct 12, 2022 · 0 comments
Labels
enhancement Minor features, and improvements on existing functionality feature Entirely new features multitdreading Issues related to distributing work across CPU threads optimization Code optimizations, and performance oriented refactoring

Comments

@olofson
Copy link
Owner

olofson commented Oct 12, 2022

In these days of ludicrous CPU core counts (gaming PCs, consoles) and even multiprocessor systems returning to the desktop (in DAWs, VEP slaves etc), it's rather restrictive to run audio in a single thread only. However, low latency realtime processing is inherently problematic as it is, and much more so when multithreading is involved, especially on general purpose operating systems!

While one could take one's chances with lock-free synchronization across "realtime" threads, maintaining full low latency operation across multiple threads is very difficult on anything but a proper RTOS, and should not be relied upon. At best, we might do something on the "main" thread (the one on the audio interface) to reduce the impact of slave threads missing their deadlines, or at least, skip any late parts, to avoid the entire audio mix glitching.

To make it more reliable, we can allow for more latency in specific parts of the processing graph, so that these parts can run on slave threads with additional buffering. That way, we can run multiple threads with the same "glitch tolerance" as a single thread, much as if some audio was rendered in deeply buffered background worker threads (see #345), but still have a defined "lowish" event latency for all parts of the graph.

It might be helpful to allow A2S to specify desired latency for programs, so that the engine can automate the distribution of the graph across threads. That way, you can for example demand that weapon attack sounds run on the main thread, whereas music and ambience sounds are allowed to run on buffered threads whenever multithreading is enabled.

@olofson olofson added enhancement Minor features, and improvements on existing functionality feature Entirely new features optimization Code optimizations, and performance oriented refactoring multitdreading Issues related to distributing work across CPU threads labels Oct 12, 2022
@olofson olofson changed the title Multithreading: Buffered slave threads Buffered slave threads Oct 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Minor features, and improvements on existing functionality feature Entirely new features multitdreading Issues related to distributing work across CPU threads optimization Code optimizations, and performance oriented refactoring
Projects
None yet
Development

No branches or pull requests

1 participant