News for hackers. Stuff that matters.
Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @11:25AM (#25059663)
It seems like they say nothing whether they optimised their audio engine. There are a couple of low hanging fruits that they avoid to pick for some reason that would vastly improve the performance. For example they could enable wrapping the VST plugins in their own separate processes. That means the operating system scheduler would be able to distribute the load on available cores in a more efficient way than Ableton currently does. Another is that when you have two tracks using the same send, then all paths that lead to the send with the send included work on the same core that means you can easily run into issues if you use more demanding plugins. Here the solution would be processing the tracks in parallel up to the point where it goes to the send - this could actually be solved by running plugins in separate processes. One more feature related to performance improvements would be ability to freeze tracks just partially and freeze entire groups. I think other features added are great, but they are kind of useless if you can't play anything because the audio engine can't keep up.
Re:Ableton Live 11 by PaulDavisThe1st on Wednesday November 11, 2020 @12:00PM (#25060115)
> wrapping the VST plugins in their own separate processes.

This isn't an optimization. https://ardour.org/plugins-in-process.html

And also, the kernel cannot schedule more efficiently than Ableton does, because it doesn't know the data dependencies between plugins.

Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @12:07PM (#25060213)
That's not what my experience tells me. If you read on Ableton website:

> Live uses one thread to process a signal path. A signal path is a single chain of audio flow. In tracks where instrument or effect racks are used, with multiple chains in parallel, Live may use one thread per chain depending on how CPU-intensive each chain may be. If two tracks are "chained" by routings, for instance by a side-chain routing, a track being fed to a return track or any tracks being fed into each-other, they are considered dependent tracks and count as one signal path. Any dependant set of tracks will use one thread each.

https://help.ableton.com/hc/en-us/articles/209067649-Multi-c...

The way they allocate plugins to threads is very inefficient and wrapping each plugin in a separate process sidesteps it as the OS takes over the allocation to different cores.

Re:Ableton Live 11 by PaulDavisThe1st on Wednesday November 11, 2020 @01:59PM (#25061571)
You should read the link I posted (I wrote it).

Ableton's scheduling could be quibbled with, but it's better than the kernel can do.

Ps. I'm the original author of Ardour, a cross-platform DAW. We use a different model than Ableton for scheduling, but not that different. We run N threads (based on a user preference for how many cores to use) and they pull signal paths from a pool, process them, and go back for more. The result is "1 thread per signal path".

Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @04:12PM (#25063044)
I read the link. I think your assumptions are wrong and definitely don't match my use case. I know there is a cost of context switching, but even with adding all that I was getting much better performance. I work with 1024 buffer and use CPU heavy plugins. Let's say that my CPU (i9 9900k @5GHz) can run 8 plugins maximum on one core. Now I have 4 tracks, and each track has 4 plugins. That sounds okay, but as soon as I use a send effect on three tracks, they are being processed in one thread and that expects one core to serve 12+1 plugins. Suddenly I get overload and I can't play anything. If I use jBridge, the plugins on each track will run in parallel utilising all cores and playback is smooth. The cpu usage per plugin is higher because of the overhead of the wrapper, but I am able to much more plugins without breaking up. I think Ableton model does not take into account that you are bound by how many plugins one core can service and if you try to cram as many plugins into one thread you'll have performance issue. The strategy should be the opposite - trying to spread the load onto as many cores as possible.
Re:Ableton Live 11 by PaulDavisThe1st on Wednesday November 11, 2020 @06:23PM (#25064228)
If plugins A, B and C are present in a given signal path, and ordered [ A, B, C ], then you cannot parallelize their execution. A must run first, then its output is fed to B, which must run to completion, and its output is fed to C. Using a single thread for this is the only sane implementation.

If you have plugins A, B and C spread across 3 signal paths, then you can certainly run them on different cores, which Ableton (and Ardour and almost any other DAW at this point) will do, by virtue on running each signal path in its own thread. The signal path/thread containing plugin A will execute on a thread/core, independently of the one containing B or the one containing C.

Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @06:40PM (#25064354)
Let me try to explain again. In Ableton one signal path executes in one thread. Any track that goes to send or to a group gets added to one thread, so that if you have [A, B, C] on track one and [D, E, F] on track two - they will run in parallel - that's fine. However, if you send track one and track two to a send track with [G], they both run on a single thread, so it becomes [A, B, C, D, E, F, G], if a single core can only process four plugins, Ableton will be stalling. If you run each plugin in a separate process, then [A, B, C] and [D, E, F] will run in parallel and the results will go to [G]. As long as either [A, B, C] or [D, E, F] will not exhaust the single core, the playback will be smooth. The same happens if you group tracks or use side chain. Plugins in the chain will all run on single thread, but they could run in parallel up until the point where they "meet". Simplest way to achieve that is to do that sandboxing or more efficient way would be to improve the thread allocation to be more granular.
Re:Ableton Live 11 by PaulDavisThe1st on Wednesday November 11, 2020 @08:12PM (#25065162)
The specific example you cite seems to be:

  [ A, B, C ] --+
                |
                +--> [ G ]   
                |
  [ D, E, F ] --+

If Live really insists on running [ A, B, C, D, E, F, G ] all in a single thread, then I agree with you, Live is being sub-optimal at best, dumb at worst. Despite their description supporting this notion that their scheduling works this way, I'm skeptical, because they're just not that dumb (I hope! :)

However, sandboxing is absolutely not the simplest way to fix this. Ardour does not and will never sandbox plugins in processes. It just uses a topological sort and a dataflow algorithm to decide what can be run and when, and would execute [ A, B, C ] and [ D, E, F ] in parallel (or could, if on appropriate hardware), before finally running [ G ].

Moving plugins into a separate process has both overhead and complications, and is basically a crazy way to fix this issue, if indeed it is an issue as described.

Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @08:25PM (#25065280)
Yes this is what's happening in Ableton and by your description I'd love if Ableton did the same thing as Ardour. I understand sandbox is not the simplest, but it is exactly what jBridge does and it gives me better performance in Ableton, so by simplest I meant that Ableton wouldn't have to change how they do processing, as jBridge is just a wrapper - does not modify Ableton in any way.
Re:Ableton Live 11 by spacechild1 on Thursday November 12, 2020 @06:20AM (#25068672)
Again, sandboxing is not done for performance reasons. On the contrary, it degrades performance because of the context switch and thread synchronization overhead. I am saying this as someone who has developed a VST plugin host with sandboxing options.

Finally, please make sure you understand what Paul Davis has tried to explain you. He's a well-respected industry expert.

Re:Ableton Live 11 by spacechild1 on Thursday November 12, 2020 @07:13AM (#25068976)
To elaborate why sandboxing itself can't help performance, let's assume you have an FX chain A -> B -> C and "B" is sandboxed. After you've computed "A", you take the output and pass it to "B". You then have to wait for "B" to finish before you can go on and compute "C". So while the subprocess for "B" might run in another thread, the main audio thread has to go to sleep. See how there's actually no parallelism at play? In fact, you lose performance because context switches and thread synchronization (especially wake up from sleep) takes time.

I think jBridge might actually collect the result of the subprocess in the next DSP tick. This means that the thread can go on to compute "C" because it can take the result of "B" from the previous DSP tick. Now you indeed have things run in parallel. However, this adds additional latency of 1 audio block. If you have several of such sandboxed plugins in a row, this can easily add up.

This is technique is sometimes called the "pipelining" (see "2.3" in https://www.complang.tuwien.ac.at/Diplomarbeiten/blechmann11...). Note that you don't need sandboxing for this. You can just as well dispatch items to a thread pool, so everything stays within the same process.

So I think the speed up you observe with jBridge has nothing to do with sandboxing per-se, but is just a side effect of its implementation. I can't prove this because I can't look at the source code, but for me this is the most likely explanation.

Re:Ableton Live 11 by varispeed on Friday November 13, 2020 @06:19AM (#25081164)
Your assumptions are wrong, because when you run jBridge A B and C are sandboxed. You are essentially running all plugins in its own processes. As I stated in other comments, the performance is improved even with the losses coming from context switching. The effect is I am able to run much more plugins than without jBridge without Ableton having a breakdown and task manager shows better core saturation. I also stated I don't care about latency - I run my projects at 1024 buffer plus plugins introduce their own delays, so sometimes it takes a couple of seconds to hear something after hitting play. That's fine as long as the playback is uninterrupted. I am running very CPU heavy plugins and that bring Ableton to its knees. Other DAWs handle it miles better - especially Reaper. Unfortunately I cannot get used to the workflow in other DAWs so I have to use workarounds. I am not sure why people keep defending this flawed architecture. It's what makes the Ableton community so toxic, but still better than Bitwigs though - if you dare to comment you dislike something about Bitwig you likely get crucified.
Re:Ableton Live 11 by spacechild1 on Sunday November 15, 2020 @08:38AM (#25101072)
Who was defending Ableton's architecture? All I can see are seasoned audio developers (including my humble self) trying to tell you how sandboxing works, how it can't improve performance and how your observed performance improvement are likely caused by something else. So please stop claiming that sandboxing helps performance - it simply doesn't.

TBH, you don't seem to even try to understand our arguments. If a domain expert like Paul Davis tells you something, try to learn from him and not easily dismiss his arguments.

Re:Ableton Live 11 by spacechild1 on Sunday November 15, 2020 @11:50AM (#25102540)
> Your assumptions are wrong, because when you run jBridge A B and C are sandboxed.

Even if that is the case, it doesn't change anything about the point I was trying to make... I acknowledge that jBridge gives you a performance boost, but you're wrongly attributing it to sandboxing. That's all I'm trying to say.

Re:Ableton Live 11 by varispeed on Monday November 16, 2020 @04:04AM (#25109644)
So why do you think there is huge performance boost when plugins are sandboxed and running in their own processes?
Re:Ableton Live 11 by spacechild1 on Monday November 16, 2020 @05:37AM (#25110210)
PS: here's my own VST host with optional sandboxing and pipelining. Both features are orthogonal. https://github.com/Spacechild1/vstplugin

Supercollider (scsynth) and Pure Data - both I'm contributing to -, have single threaded DSP. Users told me that they can use many more VST plugins when they enable the pipelining option in my extension, which matches your experience.

Again, I can't look at the source code for jBridge. The only thing I know for sure is that sandboxing itself only causes performance loss.

Re:Ableton Live 11 by spacechild1 on Monday November 16, 2020 @05:22AM (#25110127)
I tried to explain this in https://news.ycombinator.com/item?id=25068976. Read the linked paper if you want to learn more about multithreaded DSP.

To put it short: I think jBridge does “pipelining“ to avoid the context switch overhead. But pipelining can also be done without sandboxing, leading to even better performance. Without pipelining, sandboxing only gives you a performance loss. Sandboxing does not imply parallelism.

Re:Ableton Live 11 by pottering on Friday November 13, 2020 @02:33PM (#25086413)
Oh please, all replies to you here had facts, or at worst fair, informed assumptions.
Re:Ableton Live 11 by pottering on Friday November 13, 2020 @02:02AM (#25079762)
"Yes this is what's happening in Ableton"

Are you sure? Because since your theory is based on grouping tracks, it is easy to test, by simply grouping all tracks in a Set with 20 or so tracks that use a decent chunk of CPU. Then all their CPU should shift from several cores into one single core/thread (according to your theory). Of course, being easy I already tested this with a Set that used Live's native devices (no CPU usage change), but I can't test with VSTs right now (none installed). Maybe VST hosting has that problem, but processing of audio summing, Live's own devices and M4L doesn't have any major problem with multi-core.

Re:Ableton Live 11 by varispeed on Friday November 13, 2020 @11:47AM (#25084125)
Yes I did such tests and then compared the same scenario with jBridge.
Re:Ableton Live 11 by pottering on Friday November 13, 2020 @02:21PM (#25086267)
I think you may be misreading that FAQ page, it mentions sidechain as the reason for using one thread for "dependant" tracks.

Sidechain is not mere grouping/routing like the chain PaulDavis described with ASCII art (different from Sends too), with sidechain the plugin needs the audio from the other track for actual DSP processing, that's why sidechained tracks become a single thread "dependant" signal flow.

That page also mentions Live can use one thread per Chain if needed (for non Live-users, Chains are internal routings inside one single track), so it clearly states Live can use more than one core for one single Track.

Also, plugins like u-HE's use multicore just fine for a single instance, if you disable their own multicore handling (which conflicts with Live's multicore handling).

For Live's own devices, I'm pretty sure multicore works just fine, just tested again with Groups and Sends.

Don't know what problem you have, but it is not simply Live's multicore handling, it is some specific scenario you hit upon.

Re:Ableton Live 11 by varispeed on Friday November 13, 2020 @07:17PM (#25089103)
It doesn't do that. Whatever seems dependant gets lumped into one thread and limited to a single core. Fortunately Ableton cannot limit what plugins do in their own runtime so as you say U-HE multicore functionality works just fine and jBridge can run plugins off of separate processes. Not sure why people are being defensive about it or attack for pointing this flaw out. It's great that you think Ableton works as intended for you, but once you go beyond Live devices and use more professional tools, you'll hit the wall. People who I know hit this as well just moved to Reaper, but I cannot get on with its workflow.
Re:Ableton Live 11 by joeevans1000 on Wednesday November 11, 2020 @09:29PM (#25065758)
As a side note... thank you for Ardour!!
Re:Ableton Live 11 by qppo on Wednesday November 11, 2020 @02:54PM (#25062227)
The problem is reducible to maximum directed cuts in arbitrary DAGs, which is hardly "low hanging fruit." The OS scheduler is a particularly poor choice of solution and introduces a ton of overhead while solving it suboptimally.

Granted you can use a lot of heuristics to figure out simpler solutions since DAW graphs aren't arbitrary DAGs and you can get clever with how you allow them to be constructed, but it's non obvious. That's why parallel performance varies a lot between daw engines.

Re:Ableton Live 11 by iainctduncan on Wednesday November 11, 2020 @05:56PM (#25064014)
ha, yeah. No real time audio person trusts the OS scheduler anymore than is totally and unavoidably necessary.
Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @06:08PM (#25064109)
But how Ableton is doing it is worse than OS scheduler, that's the point.
Re:Ableton Live 11 by qppo on Wednesday November 11, 2020 @06:18PM (#25064195)
I don't have access to Ableton's source code so I can't benchmark it to tell you if it's doing better or worse than the OS scheduler, but I would be shocked if it was worse. The penalty for even thread synchronization is quite high, let alone interprocess sync'ing. Particularly when it comes to latency.

Sand boxing isn't done for performance reasons, and it's why you can disable it in bitwig. The sole purpose of sand boxing a plugin in its own process is because it is the only way to catch a segfault and prevent a shared library from crashing a host.

Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @06:30PM (#25064279)
It's from my experience. Ableton is optimised to cram as many plugins onto a single thread as possible, which means you are quickly going to run out of processing power when using more CPU demanding plugins, because as soon as you exhaust one cpu core, the project will no longer play in real time. When plugins run from their own process, the OS take care of distributing the load across multiple cores and that lets you run more plugins before it will overload. So I agree that sandboxing is not done to gain perfomance, but better perfomance is an unintended side effect. That shows how bad Ableton scheduling is.
Re:Ableton Live 11 by qppo on Wednesday November 11, 2020 @06:49PM (#25064429)
It shows how slow your CPU's single threaded performance is and the trade off between latency and throughout in modern computing more than anything.

My experience from actually writing low latency schedulers in user space as well as the publicly available material - like in Ardour - suggests different conclusions from yours.

Keep in mind that a naive benchmark like "cpu usage" is entirely meaningless. What you look at is round trip latency required for a threshold of underruns/missed deadlines. Threading requires additional latency, and process synchronization even more. While I'm sure you report fewer underruns when splitting off into sandboxed plugins I'm suspicious if it's hitting the same performance as doubling or tripling the buffer size in terms of latency in the first place.

Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @07:55PM (#25065014)
I am using i9 9900k @5GHz so I think it is quite fast. The plugins I use are CPU heavy and you can run limited number of them on a single core. I am not interested in low latency - I am running 1024 buffer, however I would like my projects to play smoothly even if there is latency. Ableton unfortunately does not work well with such use case as it won't parallelise where it could and sandboxing does just that and I can run more plugins, even if it seems less efficient.
Re:Ableton Live 11 by spacechild1 on Thursday November 12, 2020 @07:19AM (#25069014)
For other readers: It is a misconception that sandboxing per-se enables parallelism. On the contrary, it only hurts performance. The speedup observed with jBridge might have other reasons. More here: https://news.ycombinator.com/item?id=25068976
Re:Ableton Live 11 by varispeed on Friday November 13, 2020 @06:09AM (#25081119)
I didn't observe that. I have experienced no difference apart from improved performance.
Re:Ableton Live 11 by spacechild1 on Thursday November 12, 2020 @07:23AM (#25069046)
> this could actually be solved by running plugins in separate processes.

Speaking as an audio developer, you would certainly not run things in a seperate process to achieve parallelism. Instead you would use a thread pool.

Re:Ableton Live 11 by mhh__ on Wednesday November 11, 2020 @11:27AM (#25059681)
Bitwig already does that with VSTs IIRC
Re:Ableton Live 11 by varispeed on Wednesday November 11, 2020 @11:43AM (#25059889)
Yes and that works very well. You could also achieve this in Ableton by using jBridge (it was intended as a way to run 32bit plugins in 64bit DAW or other way around or to overcome the memory limits of a 32bit process) which runs plugins in separate processes and unintended consequence is vastly improved performance. I remember having projects that wouldn't play at all and played through jBridge without breaking a sweat.
Re:Ableton Live 11 by spacechild1 on Thursday November 12, 2020 @07:18AM (#25069009)
For other readers: It is a misconception that sandboxing per-se enables parallelism. On the contrary, it only hurts performance. The speedup observed with jBridge might have other reasons. More here: https://news.ycombinator.com/item?id=25068976