Troubleshooting "More than 50 simultaneous macros - aborting everything" error

See my response to Kevinb above.

There is inherently a ceiling to how many macros will need to run at once. And the macros I'm using are designed to trigger, run, and finish up very quickly, so they get out of the way. I also have a ton of trigger filters set up to prevent things from triggering in the first place, that don't absolutely have to trigger, rather than having to filter trigger events after the fact. It's all designed to be as efficient and quick as possible. That said, the macros are running in parallel, as opposed to serially, so that they all process more or less at the same time, instead of waiting in line for one to finish, so another can begin. This is where the total number of active macros starts to stack up.

It's not a runaway macro situation. It's just that it needs to be more than 50. And, for how I'm using it, adjusting the threshold to 200 (or whatever) has worked just fine for my needs. It was just the artificial limit of 50 that has caused me problems in the past. That's why I came back looking for your post. This solution worked before, and I knew it would again. There are 8 buttons on my SD that I desire to update, each time that I change tracks. There are probably 15-ish macros (or sub macros) per button, plus some other extraneous stuff all going on at the same time, so that's roughly 150 macros (and/or sub macros) at once, but that's kind of the upper limit. Hence, why bumping it up to 200 fixes the problem.

Earlier in this thread, you said 200 wouldn't be a problem, so I wasn't sure why you were expressing trepidation about this now?

1 Like

I'm not sure if I follow that last bit about the setting not existing. Are you saying that I need to actively configure this somewhere, in addition to running that command in Terminal?

No. He is saying that some settings have a default value, and he's telling you that the default value for "MaximumSimultaneousMacros" is "50". His words were:

Without wishing to put put words into Peter's mouth:

Emphasis mine.

If your macros are similarly "low impact" then you also probably won't have a problem, but so much depends on the macros, your hardware, other processes that are running, etc, etc that you'll have to suck it and see. It's worked fine for you before, so it'll probably be OK this time too.

But increasing the maximum concurrent macros limit is generally not the correct thing to do, if only because your Mac is "event driven" and event queues have limits -- it's not that difficult to have KM send enough events fast enough that the queue fills and events are dropped, and the more macros executing the more chance of that happening. Triggers are events too, so that can also happen on the "input" side.

Nitpick:

Not exactly, which is another reason for looking for other solutions before bumping the limit. We say "parallel" because they are executing at the same time -- but they are actually executing concurrently. The Engine only executes one action at a time, rapidly switching between the different macros, and while the order of action execution within an instance is guaranteed the order across instances isn't. Generally that's not a problem -- but the more simultaneous macros running the more chance that there might be.

And, of course, more macros means more Engine memory required, more switching overhead, etc. And macro actions(*) are all executed on the same single CPU core and you eventually get to the point where adding another executing instance slows down all the executing instances -- for me that's around 25 simultaneous executions, IIRC.

Long story short -- bumping the max macros number can be the answer, it shouldn't be the first answer, and in this particular case is probably the right answer :wink:

* There's a difference between the action and what the action does. Image detection actions, for example, will be executed within the Engine but the actual processing is "external" and will run on another core. You can see this in Activity Monitor -- run three simultaneous "Pause Until Image..." macros and the Engine may top out at 20% CPU usage while total CPU usage jumps 300%

2 Likes

I hear you, and I appreciate some of that inside info. I can tell you that I use the Pause Until action, extensively, don't reuse variable names to avoid cross contamination from other similar macros running in parallel, have a Cancel This Macro action at the top of each of these macros that cancels the previously executing instance (if it was still running), and other such things. A lot of work went into taking all of this stuff into account, to make it as efficient and reliable as possible.

At the end of the day, I just needed to be able run more than 50 simultaneous macros. And changing it to 200 solved the issue. I hope this feature is never removed from KM.

2 Likes