Tips on How to Fix or Help a Very Laggy and Slow Keyboard Maestro?

It has progressively got worse over the months. Now it's to the point where often, anything I do creates a few seconds pause at best. For instance, I might click to add a macro and it will pause a few seconds before adding. I might click an input box and it will pause a few seconds before it will be ready to input anything. I might click to add a pause and it will pause a few seconds before adding the pause. I might press delete to delete something and it will pause a few seconds before deleting it. You get the picture, and that's at best; any one action may cause instead a ten second or over a minute pause. It makes everything take like five times as long or even longer.

Nothing else on my computer lags like this. I can use Chrome fine, other apps fine, but when I go to Keyboard Maestro it's sooo slow. I'm using a newish computer with a good amount of ram, 16gb, and 1tb of storage with enough space. I look at activity monitor and it seems there should be plenty of memory and speed for it at any given time. Keyboard Maestro doesn't seem to use that much memory or anything. And yet it still is sooo slow. It's still slow even after closing the app and engine down and starting them all again fresh.

I will say I've had Keyboard Maestro for years and have used it a lot. I've created a ton of macros and subsequently deleted a ton. I keep the variables clear or deleted as much as possible and generally have all macros turned off when I'm editing a macro. I do have a good amount of macro groups, maybe about 50, although at one point in the past I had many more (over 100 at once) and Keyboard Maestro was still working well. Each group contains maybe 5-30 macros, and each macro contains maybe 5-30 actions.

I feel like because I've used it so much over the years, maybe it's somehow stored a lot of the past information somewhere (old variable info and/or or old macros groups) that's now bloated to the point where it's affecting the performance of Keyboard Maestro in a major way. Or, if it's not that, then it's something.

Does anyone have any tips or suggestions to what I can do to improve the performance? Since I use it so much this is a major major frustration that really slows me down.

ETA - I should specify that when I use a macro or group, they generally work fine once started (because of the laggyness of Keyboard Maestro sometimes they give lagging problems when first started and sometimes I may need to stop and restart a few times but will generally work okay once I keep an eye on them until they're properly going). It's the editing that is always, always so very slow. And I do editing every day as I'm always creating new macros and groups or editing older ones so it's a major problem.

There’s a whole other conversation about this that you might want to check out...

1 Like

Thank you, tiffle. I read the thread and responding to the suggestions given there, see some things I can try, but it looks like for me it boils down to, 'make the macros smaller and delete as many as you can'.

I don't ever use more than one editor window so that's not a problem.

I always keep my variables cleared out so that's not a problem.

I don't ever keep macro groups or macros enabled unless they're specifically being used so that's not a problem. The only one 'always' on is the Global Macro group which honestly I wish I could delete or at least disable because it spoils the order I have for my macro groups (since it's 'G' it's in the middle and sticks out because it's always black as enabled while the rest are greyed as disabled; and it's capitalised while the others are all titled in lowercase; I even went through a phase of naming all my groups with a space in the front so the Global Macro Group would be at the very bottom).

I do use found images, a lot actually, but they are important to my macros and impossible to get around. It sounds like the more images used the higher the possibility of making the editor lag. It's odd the actual macro being used won't lag but the editor will with a found image. I will keep this in mind going forward and try to use the smallest images possible but since I basically already do that and since using these are important there's not much I can change there.

I do make larger macros and groups sometimes, and it appears that maybe they are too large from what's said in the other thread. I can work on splitting them up more.

I do have a lot of groups in the editor so I guess I'll need to go through and offload the ones I use the least and just re-onload them whenever I need to use them.

Hopefully this will work, I'll give it a try, but in the meantime if anyone has any other suggestions please let me know!

Well, why not rename it, delete it or disable it?

You can't rename, delete or disable it. Don't you see it on your own Keyboard Maestro?

1 Like

Bugger - my bad! Having done all that with numerous other macro groups I just assumed you could also do it to the global one. Not so. Apologies.

Just goes to show there's always something else to learn about KM - and this forum is a good place for that.

No problem. It sticks out like a sore thumb on my groups list because it's capitalised and always enabled/black, so I learnt quickly that you can't do any of that with it.

1 Like

in Activity Monitor, what's the CPU usage by KM?

Having now found out about the "Global Macro Group" I would tend to support removing its special status and demoting it to the same level as any other macro group.

1 Like

I had just restarted it so right now it's only 0.5%. I'll be using the editor and engine more in a little while and will keep an eye on it and let you know how it fares.

1 Like

I experienced a similar issue before. When the editor became laggy, it actually affected everything I was doing. The only way to get it back to normal is to restart the KM engine (not the editor).

Restarting the engine doesn't help it for me, though I'm glad it worked for you.

All right, I've been watching it while doing some editing and it jumps up to a high of about 68% (I think all the available) whenever I do any editing action and whenever the pauses happen so that seems high. When that's over if I don't immediately do something else in the editor then it goes back down to around 20% at most but even 10% or less (it's constantly changing).

ETA - I'm speaking of the editor, named 'Keyboard Maestro' in the activity monitor. The engine, named 'Keyboard Maestro Engine' in the activity monitor, also jumps around even though I'm not using any macros but only editing, up to a high of around 20% sometimes usually in conjunction with the editor usage going up.

Peter has mentioned elsewhere that hiding the condition and found image actions will help:

Note that the Keyboard Maestro editor will implicitly be running macros if you are displaying a macro with conditions in the editor, so quitting the editor when not in use is a good idea - but just hiding it will be sufficient, since it only updates the action condition results if they are visible on the screen.

I also want to put out there that I was using the engine to run some macros just now and was watching the cpu for 'Keyboard Maestro Engine'. It went up to almost 750%, hovering around there or 680% or sometimes down to around 350%, although the macro seemed to be running fine. When I stopped the macro, the usage went down to around 150% for awhile on the engine until finally it went down into the teens a minute or two later. Is it normal for the engine to go that high in cpu when running? It's odd that the macro would even work with such high usage.

When you say hide, do you mean minimise/collapse? I do that with every action right away, including the found image actions.

Thant’s right, collapse.
Otherwise, these actions will constantly check if conditions meet.

2 Likes

Cool, thanks for that. I do already do that. I thought maybe you'd meant there was some other way to hide actions even more that I didn't know about.

It depends on the macro and what it is executing.

If it is executing an action that is looking for an image on the screen, then yes, it will use essentially all the CPU (100% is 100% of one core. If you have 8 cores, then the max would be 800%).

When you stop the macro, Keyboard Maestro Engine will return to using a fraction of a percent. It may take a short while for the various processes to complete (a second or less generally). The system may lag behind in showing the usage since it is presumably averaging usage. So after Keyboard Maestro Engine has stopped using any CPU, it might decide that 750% previously and 1% now mean 300% displayed.

Most actions take significantly less CPU - generally with a macro running the CPU usage might be around 20% for example. But image searching and OCR will take a lot more, and inter-process communication and scripting can be relatively high too (though typically they would still be < 100%).

Keyboard Maestro Engine is designed to be highly efficient in CPU while it is not doing anything (since it is running all the time, it would be bad if it impacted performance generally).

But when it is running, it is designed to do its job, and in many cases, it is designed to do its job as fas as possible, and at that point CPU usage is a significantly lesser priority.

1 Like

Thanks for that explanation, Peter!

(ETA again - I have a quad core so I find that hyper-threading can allow up to 800% so that makes sense.)

The macro did have a few different find an image actions, so that makes sense.

I don't want to get too off track of the original intent of the thread, but this does make me wonder something about a macro I was just working on. Suppose I have ten macros in a group, and each needs to find a specific image on the screen, and only one of the images would ever be on the screen at any time. Otherwise they are all identical macros. Is it better for speed and lag to:

  1. Create one separate eleventh macro with a find an image action that can be expanded to include all ten images in one action using the 'any of the following are true' parameter, and then include an 'execute a macro' action in each of the other ten macros all pointing to that eleventh macro, so that there's only one find an image action altogether even though it's loaded with ten images

  2. create a separate find an image action for each of the ten macros, so that spread over the ten macros there would be ten find an image actions (one per macro) each with one distinct image

  3. it doesn't matter

?