Moving the mouse cursor can cause CPU spikes on macOS
mmazzarolo.com
mmazzarolo.com
I suspect this is at least part of the reason why some people have mysterious performance problems with VirtualBox on macOS[0]—at least, it’s how I first noticed the problem. (I’m sure VirtualBox has some other issue going on too, since its event queue gets backed up so badly that even keyboard events become delayed. Life gets interesting when the delays are so long that the guest OS key repeat is triggered!)
Does anyone know of some small utility that adjusts mouse polling rates to at least mitigate the issue? The official Logitech software to do this is 476MB, 5 kernel extensions, and a launch daemon, which is a bit much just to send a USB command.
I've tried bringing peoples' attention to this issue for years now and they either don't notice it or care if they manage to.
It's just another manifestation of mobile is important and desktop can go hang.
You need to spin up when a human puts their finger on the touchscreen so you can have all the nifty animations and indications.
When the "cursor" isn't moving, you want to go to sleep to save battery.
Nobody cares that this isn't relevant when you have a mouse and monitor on a plugged in desktop.
Sometimes it would be stuck at 100% for ages, as usually you're not interacting with the machine during an install, and then somebody would wiggle the mouse and suddenly 'Installation complete'
You'd think an end user computer HW+OS by now would decouple the UI at a hardware level and figure out how to minimize the performance losses from at least a two-tier design. But, this would require new ground up everything, including new end-user software dev paradigms, and by-design potentially second-tier performance in order to maximize security. This seems insurmountable, of course, but I bet such innovations will emerge this decade.
My money is on whoever can offer fundamental, fully integrated fixes to the whole stack from cloud to edge. Jumpy cursor CPU's, and monolithic internet/endpoints will be an anachronism.
Kudos to Apple for being performance leaders, though. I just find the current assortment of consumer hardware offers weak assurances by default (not everyone has a megacorp or resources to harden and protect their infra). This small mouse cursor bug reminds me of the rabbit hole that needs fixing, imo.
I just decided to test it on my MBP, continuously moving the cursor on trackpad, WindowsServer was hovering at ~20+%, and 2-5% when it is not moving. It is not as high as an USB mouse but it is definitely problematic.
And I have noticed this for quite some time, I just never thought it was the mouse / cursor.
Up until some version I could kill the acceleration curve with SteerMouse (but not the scroll acceleration), but there was still the 2 frame lag. It's also extremely distracting how you can see the UI further lagging behind the cursor when you drag windows or click buttons. Another frame or two of delay, bringing it to a total of 64ms.
I have a 1000km RTT ping that takes less than it takes MacOS to react to mouse movement. It feels like using a remote desktop.
After Big Sur, the issue got even worse, especially on external displays. CPU usage also spiked through the roof.
After developing for a while on a Windows machine with a 144hz display and a 500+hz mouse I can't go back to using MacOS. It feels like trying to use a car infotainment system by comparison.
I also couldn't get a 2019 15" MBP to work on the external display at over 100hz using DP Alt Mode over a HDMI2.0 cable. The same one works fine on my desktop or on a ThinkPad.
I’ll have to look at the polling rate thing, too - thanks for the tip.
As far as I heard, it's related to CPU C-states.
while (stillRunning) {
event = getEventOrWait();
// handle event
}
(In macOS this is done inside [NSApp run], but Windows and Linux make the loop explicit.)I think the 1000 Hz you are thinking of is the accuracy of the UI timers. Since you're just calling this in a loop, not waiting for a timer to fire, you can burn through a lot of events in one timeslice. And since most systems have multiple processors, it is reasonable for your game to be running continually, especially since modern OSes frequently prioritize certain kinds of programs (and a game might request prioritization if at all possible).