Need fix for browser throttling

I’m using a fairly new iMac running High Sierra(starring Leif Ericson and Cameron Mitchell). The issue I’m having is that a javascript site I use on chrome (it’s an idle game) slows down by about 90% when the display sleeps. End result is after running in the background all day it’s done less than an hour’s progress. I’ve gone into Chromes flags and turned off “Throttle expensive background timers” and I also have caffeinate running from a terminal window. Is anything I can do to keep it going unattended at full speed?

Can you try Safari or FireFox just as a test to see if the behavior is the same? The display sleeping is a hardware item (I think), I don’t understand why it would affect an app. It is possible more than the display is sleeping and the system is somehow entering an energy saving state, despite the caffeinate utility. As a test turn off all power saving features. You want to verify it’s a client-side issue, not the server or network slowing down. If the javascript code is somehow single-threaded on disk or network I/O or some server-side ack, the entire web app might slow down if any of those slow down – even if all client-side power saving features are disabled. Testing that is one way to find out.

I get the same behavior in Safari and FireFox. Turning off power saving features is no longer an option. The computer sleep slider was removed from the OS a few years ago. Caffeinate is now the only way to tell the computer not to sleep when the display is off unless the app lodges a power assertion. They seem to be operating on the assumption that everyone is running on batteries now, and have gotten overly aggressive with power saving features.

I just ran a python benchmark while the javascript site was running. The site slowed way down while the screen was off, going from ~5 seconds per cycle to ~45 seconds per cycle. The benchmark kept running at the same speed, doing one cycle every ~4 seconds. So it seems to be the browser that is slowing down, except that all three browsers do it.

What about the Power Saving option “Prevent computer from sleeping automatically when the display is off”? Does that do anything in this case? If that is checked I don’t understand why the display would affect app behavior. That implies it’s not just shutting off the display backlight but maybe the graphics system or putting it into a low-power mode which causes certain APIs to be delayed.

What if you turn off the display timeout in system prefs > energy saver and just manually turn down the screen brightness to zero using the keyboard? If only as a test that would be interesting.

There are other “stay awake” apps besides caffeinate, but I haven’t used them: https://itunes.apple.com/us/app/amphetamine/id937984704?mt=12

Is that new in High Sierra? I’m running Sierra and I still have a “Never” put the display to sleep option and checkboxes to disable power saving features.

It was changed in 2015. There used to be a slider for when the computer could sleep right under the slider for when to put the display to sleep. That slider has been gone for some time. The checkboxes don’t really prevent it from sleeping. Here’s an article about the change from 2015.

But in this case it appears caffeinate does prevent the computer from sleeping, it just greatly slows down the javascript running in browsers, to roughly 10% of normal speed. I don’t know whether the browsers do that, or the system, but turning that flag off is supposed to prevent that.

You could try pmset.

pmset -a sleep 0

That should prevent sleeping.

Ignorance fought. Thanks.

pmset -g reports that sleep is prevented by caffeine. Anyway, it continues to run while the screen is off. Just that all browsers running javascript go verrrrrrrryyyyyyy slllllloooooowwwlllyyyy.

I can’t find it now, but awhile back I recall reading a discussion where somebody said he had some important system monitoring equipment that used an embedded javascript web app, and that with this throttling it was causing important events to not be logged if they happened in between cycles.

I’d love to be able to watch Activity Monitor when this is happening, but obviously I can’t see it when the screen is asleep, and it doesn’t slow down when the screen’s awake.

Can you just turn off screen sleep?

Leaving the screen on 24/7 is not a good idea. Also, I’ve tried using a blank screensaver, but the problem occurs when the screensaver is on as well. I suspect that even if I had a separate monitor instead of a built in one that the OS would detect if I shut it off.

It used to be possible to turn the brightness all the way down, but they’ve taken that feature away as well. I don’t know whether that’s a software or hardware thing.

Unlike Windows Performance Monitor, the macOS Activity Monitor won’t monitor a remote machine. However –

You can run the terminal “top” command (which gathers process stats) to a file and later examine this. E.g. top -s 10 > topout.txt

This runs the command line statistics app “top” every 10 sec to the output file topout.txt. After the display goes to sleep this should keep running. You could later cancel the command via CTRL+C, then examine the file with TextEdit.

If 10 sec is too quick and makes the file too large, try 15, 30 or 60 sec.

Another approach is remotely connecting from another Mac via SSH and running top remotely. Procedure:

(1) Enable remote login on the target machine via System Preferences>Sharing.
(2) From your client machine run terminal
(3) Use the terminal menu Shell>New Remote Connection
(4) Provide the login to the target machine in that dialog
(5) On the client machine in terminal type the admin password of the target machine

You will then be running SSH terminal connected to the remote machine. You can run top or most other commands which will execute on the remote machine via the network.

For details on top, see the man page, e.g, “man top” from terminal. There are other more advanced command line monitoring tools such as htop which can run remotely via SSH but they require installation via a package manager: https://www.ionos.com/digitalguide/server/tools/htop-the-task-manager-for-linux-mac-os-x-and-bsd/

All modern screens are LED-illuminated, so leaving them on 24/7 is OK.

Note that your eyes are logarithmically sensitive to light. This means when your iMac display is turned to the dimmest setting, the actual illumination level (hence LED backlight power consumption) is much less than it visually appears.

I just measured my 2017 iMac 27 with a lux meter, and at the brightest setting it produces 330 lux, and the dimmest setting only 2 lux, a difference of 165x. Yet the dimmest setting doesn’t look that dim – you can clearly see it. This is an artifact of how the human eye works. In fact the monitor is 1/165th as bright.

Although LED flux is not always linear with power consumption, for rough purposes we can consider it so. In general that means the monitor’s LED power consumption at the dimmest level is less than 1/100th the brightest level.

This implies just turning it to the dimmest setting has almost the same results (from a power and durability standpoint) as being totally off.

On my older one (which I still have) if I turn the brightness all the way down the screen goes completely black and the backlight turns off. On my newer one if I turn it down as far as it will go the screen is still visible in daylight. In the dark it’s still bright enough for the glow to be visible from the next room, which happens to be our bedroom.

What happens if you put up a completely black image as your screensaver?

My point is despite the apparent brightness, it is consuming less than 1/100th the energy of max brightness. This can be very misleading because visually it only looks about 1/5th or 1/10th as bright. In actuality the display is consuming virtually no energy.

If the concern is the dim light bothers you at night (understandable due to night vision adaptation), maybe you could just put up a black screen, e.g, open terminal and maximize it.

The human eye operates over a very wide dynamic range and is incredibly sensitive at night. A young person can see dimly under starlight at 0.0001 lux. Yet their eyes also work at 110,000 lux on a bright sunny day, a difference of one billion times.

The tradeoff is we can’t accurately perceive two roughly similar (but different) brightness levels. This is why you visually perceive the dimmest iMac monitor as “still pretty bright” when in fact it is putting out less than 1/100th the energy of full brightness.

LCD screens don’t get phosphor burn, but they do get backlight failures. I wouldn’t leave a LED backlight on continuously if I wasn’t using it.

Here’s what Samsung says about burn in:

But that’s become semi-moot, because I’ve since discovered that even if I let the screen stay on and turn off the screensaver the javascript process still gets throttled at some point. I don’t know how long it sits before slowing down because it only displays the last 10 cycles, but at some point the speed slowed down from ~6.6 seconds per cycle to ~54 seconds per cycle - dropping from 47million points per minute to 5 million points per minute. It immediately sped back up after I moved the mouse pointer.

Like I said before a bash script still continues to chug along at the same speed, so it’s not the whole system that’s slowing, apparently just javascript processes, which leads me to believe it’s browser behavior, not system behavior.

I’ve been reading with interest, hoping somebody would come up with an explanation.

Does anyone know how the javascript event loop works? Does your application have an asynchronous provess that is triggered by events?