Understanding Cantabile's Multi-processor Support
Cantabile supports multi-core/processor machines in the following ways:
- The audio engine runs on a separate thread to the user-interface.
- Many tasks performed by the audio engine are delegated to a pool of worker threads to help spread the load.
- Many background tasks are performed on background threads (audio decoding, writing audio recordings, audio buffer management etc...)
What's a Thread?
On this page, and in any discussion of multiple-process support, the term "thread" is often used. A thread like a sub-program within a program that performs some task.
The key thing about threads is that the operating system can schedule threads to run on different CPU cores and is the underlying principle for leveraging multi-core machines - by running two computationally intensive tasks at the same time, rather than one after the other, the total time taken should be less.
The main thing to understand here is that multiple core's don't help when process a task whose input depends on the output of a previous task.
For example, say you have two plugins - an instrument, followed by an effect. There's no point processing the effect on a separate core because it can't start it's work until the instrument has been processed. In fact, in this case the additional cost of switching between threads would make the process slower.
On the other hand, if you have two instruments they can be processed on separate threads since neither needs the output of the other for its input. If they're processed on separate threads, the operating system can schedule these to different CPU cores and they can both be processed at the same time.
Why Doesn't Cantabile use 100% of all cores
If you run Cantabile under heavy load with many plugins you'll notice that rarely will it bring CPU load to 100% on all cores. Why is this?
If you think about the above example of two instruments being processed in parallel, it's extremely unlike that both instruments will take exactly the same amount of time to process their audio - different plugins have different processing load.
In other words, Cantabile needs to pause at certain points while it waits for slower plugins to finish before it can continue - and it's these pauses that cause CPU load to never reach 100%.
Of course the other reason for never hitting 100% is unrelated to multi-processor support and is due to the fact that everything is being processed faster than the duration of the audio cycle - so everything pauses until the next cycle. In fact this is the ideal - and typical - situation.
Understaning Cantabile's Multi-Processor Option
During early development of Cantabile's multi-processor support we noticed that some plugins don't work correctly if two instances of the same plugin are processed at the same time. (eg: two instances of the same instrument plugin)
For this reason Cantabile has a couple of options (Options → Audio Engine) that controls multi-processor support. The available options are:
Number of Audio Threads
Controls the number of threads Cantabile will use to perform audio processing. Normally this should be set to the number of physical processors your machine has. For processors that support hyper-threading it should be the number of actual physically processor cores - not the number of virtual hyper cores.
By setting the number of audio threads to 1 you can effectively disable Cantabile's multi-core support. This might be useful if a plugin proves to be completely incompatible with the multiprocessor support. Generally this mode shouldn't be needed but may be useful for diagnostics reasons (particularly for plugin developers) or for some unique scenarios this might actually provide better performance (eg: when only using a single plugin).
By setting this to a number lower than the number of physical processors available you can leave processing power available to other programs, or for plugins that support their own built-in multi-core processing.
Compatibility Mode provides significant performance increases when running most multi-rack songs and is the recommended mode for most situations. In this mode racks are processed in parallel but processing will stall if two or more plugins of the same type need to be processed at the same time – in which case they will be processed one after the other.
Aggressive Mode is suitable when running many racks with the same plugins on each rack. In this mode the plugins being used must be compatible. Many plugins are compatible with this mode, but those that aren't can cause undesirable effects ranging from noise to crashing the entire application.
When a song contains no duplicate plugins Compatibility Mode and Aggressive Mode are effectively equivalent.
Thread Affinity Mode
This option can be used to force Cantabile's audio threads to run on the same core. This can provide some performance advantages but should be tested on a system-by-system basis. (most systems will show negligble difference).