general tips for reducing CPU load

oshii's icon

Hi guys,
I've been searching for hours and couldn't find good general advice on how to reduce CPU load.
I know that GUI objects are huge consumers, but apart from that should I look for something else?
Also is there a way to measure this by myself? I found a time benchmark time patch (not sure about its creator, but I think it could be Chris Muir), which measures some time, however I'm not sure about some reference ranges, and is it actually the best one?

Max Patch
Copy patch and select New From Clipboard in Max.

Roman Thilenius's icon

i am not an expert for this low level stuff, but i think that for scheduler rate data, measuring how long they take to be processed by the objects above the target point is perfectly describing the "CPU requirement" of the algorithms.

and it is that what you usually want to know: if something still runs fine within its thread.

Roman Thilenius's icon

patch: thats milliseconds of system time

oshii's icon

1) I was basically asking for some general advice on how to reduce CPU load, not something too low level. I've got couple of patches which quite easily hit the 100% load every now and then, and would like to fix that.
2) As a result the benchmark showed 5.5ms for a meter~ vs 3.3ms for a simple message object, and 2.1 for a number~, which I thought was supposed to be heavier than [message].
I am confused.

Rodrigo's icon

There's tons of other stuff you can be looking at before you start looking at the scheduler and UI objects. It's good practice to limit those, but where you will be spending big % will be on audio processes.

In the "View" menu there is a "Show CPU Usage" option. Turn that on and take a look at your patch. Also, when you turn it off, it prints off what % of your total CPU is being used by each individual object, and lets you double-click to go to that object.

That will help you identify your problem areas.

From there, it varies by what you're are doing (seeing a patch helps), but you normally want to disable parts of your patch that aren't presently in use. This normally happens by wrapping it inside a [poly~] object, and turning it on/off that way. But again, this varies a ton by what you're doing.

oshii's icon

Thanks Rodrigo, pretty good advice to use the CPU Usage. I was using the DSP CPU Monitor found in Extras, but it didn't show me such information. You said that once I turn CPU Usage off I should be able to see exactly what % is used by each individual object, but I can't see that. Can you please share a screenshot?

Rodrigo's icon

It will be in the Max window, which may be hidden or closed.

Here is a screenshot of a relatively simple patch:

It's worth noting that the percentage that it lists for each object is of the total listed at the top.

So in this case my average audio usage is 0.79%, of which the object [karma~] is 72% of.

oshii's icon

Hi Raja, again plenty of interesting information to consider from your side. I realise that I find the work with poly~ cumbersome and usually that's my last resort (i know.. i have to start loving it for its benefits, and yet..).
However I'm not sure if this would help in my case - it's about a synth I'm building, consisting of 3 oscillators, each having a choice of waveforms - sine, triangle, square etc + custom wave, for which i was using multislider with 512 sliders, peek~ and a buffer~. Unfortunately I see that the combination of these 3 objects results in pretty huge CPU load (as per the benchmark) - 5000msec! So I had to remove that option from the first two OSCs and leave it only for the third one.

oshii's icon

Rodrigo, that's pretty cool. Thanks!!

Rodrigo's icon

Yeah it's not very clear, but I've deduced it after seeing many patches like this one (there's no way that karma~ is using 72% of the total CPU!).

Rodrigo's icon

It's particularly nice as it jumps you to the object (like a normal error report), so when it says "poly~", you know which one.

Brent 's icon

The CPU usage percentage list (broken down by object) mentioned and screenshotted by {the amazing} Rodrigo, appears for me *after* I close my M4L patch.

George Collins's icon

Hi everyone - I can't seem to access this CPU usage list... I have selected it on the patch I want to show, and have the max console up, but nothing coming up. Any ideas? Thanks in advance.
On Max 8.1.3...

analogue01's icon

Wow. Had no idea the show cpu setting printed a list to the console - awesome! Is there any way to get a more granular breakdown of stuff going on inside a poly~? Setting show cpu on the window I get when I double click a poly~ does nothing

Rahm's icon

Is the CPU usage feature only visible when using standalone Max, or is it visible in Max for Live as well? I ask because I can only get it to work when I open a .maxpat and not a .amx.

ghostique's icon

whats the recommended CPU for Max 8? I have a Ryzen 9 5900x, but if I require a 5950x I can buy it asap. Just tell me.