Number of devices and CPU utilization ---I'm totally confused.
Hi,
I'm having trouble with multiple instances of my devices and high CPU utilization when hooked up to an LFO. In the process of debugging my devices, I ran a simple test which yielded shocking (for me) results. I'm hoping someone can help me undertand what's going on here.
In my test, I ran a simple 8 encoder device (called CC8) to transmit 8 different midi cc # values to the track. Every encoder is hooked up to an LFO running at 40hz going from 0 to 127.
Running alone on the track, the CC8 causes Ableton to display 5% cpu utilization. No problem. Adding 13 instances of the default Ableton max MIDI effect, which just has a [midiin]-->[midiout] in it, causes Ableton displays CPU utilization as 20%-25%.
A 400% increase in displayed CPU utilization with 13 instances of a patch that just passes through MIDI?
Why this is happening? Like a river flowing through a dam, should not a simple midi passthrough extract nothing from the track and thereby use no processing power?
I'm hoping that understanding this test scenario will help me better understand what's going on with my devices.
Devices used in this test scenario are attached in case anyone wants to recreate my test on their machine.
Your “simple midi passthrough” is being executed ~1000 times per second per knob If you’re controlling all 8 knobs with an LFO. (Your update rate limit on the knobs is the default 1ms, otherwise it would be much higher).
At minimum I would put a “change” object after each knob because midi resolution is integers and floating point value changes from the lfo will send the same interger value out a bunch of times before the value changes. Though I guess at 40hz the change object likely won’t help much because you’ll likely have different integer values every ms anyway.
You could also replace the prepend->send->receive->midiformat with just a [ctlout] per knob instead.
8000 midi messages/second maybe shouldn't be that much to pass through devices, but it also isn't trivial. There may be other things going on...
IIRC you were running on an intel MacBook Pro? You might take a look in Activity Monitor for a process called "kernel_task" and see if it's spiking in CPU usage. That process is used to balance CPU core usage to reduce thermal load somehow. When I was on an intel MBP I found it really problematic and it correlated highly with getting CPU spikes.
Also, I've not seen anything documented on this, but I think there is a layer of midi processing that happens going into and out of Max devices that may add some computational overhead that becomes more noticeable with lots of devices and lots of MIDI. I only observed something like this when working with MPE though.
Many thanks Tyler. Very interesting. Though I imagined MIDI CC was interleaved when sending MIDI from different encoders at a high rate of speed, I didn't think any of those values would be repeated (thereby rending the change object unnecessary). I'll take a look at the kernal_task in the activity monitor as well. My production DAW is windows so hopefully this is an OSX specific issue.
Since I'm not able to reduce the number of devices on the track (given my use case) I think the best approach here is to bypass the 13 devices altogether. I could do that by placing a device at the end of the device chain that would receive MIID CC from send-->receive objects rather than from [midiin].
Consider device 1 ,2,3,4,5,6,7,8,9,10, 11, 12, 13 and 14 on track A.
Device 14 contains object [receive midiout]. Device 1-13 sends it's midi cc values to the [send midiout] object rather than [midiout]. In that way device 2-13 would not see the midi from track at all.
I'm hoping this whole issue could then be avoided.
Bypassing the [midiin]-->[midiout] of the 13 devices by routing it to the last device in the chain using [send]-->[receive] reduced displayed CPU utilization in Ableton by more than 50%: down to 7-10% utilization from 20%-25%.
Got to say I'm shocked that simply passing through midi in and out of a device—even 8,000 times per second—is so CPU intensive. That seems a basic use case for all MIDI devices that should be highly optimized. Having multiple midi devices on a track is not uncommon especially in larger, complex sets that utilize encoders to control external synths.
Thanks for your help Tyler! Very much appreciated.