HACKER Q&A
📣 dsnr

How to intentionally throttle CPU on a M1 MacBook?


Hi everyone,

I recently had no choice but to upgrade to an M1 Macbook from an Intel-based one. I did not want to upgrade, as I’m working on a software for which performance on mid-range machines is critical, but unfortunately the previous laptop gave up on me. Since M1 macbooks are so much more powerful than previous generations, is there a way to intentionally slow it down to be able to test my program on a slower machine? One way I can think of, is to run the program inside a VM, but that would slow down the development loop.

Thanks for all the suggestions. Now I have the following list of tricks to try (collected from the thread):

- taskpolicy -b -p [pid]

- macOS low power mode (which can even be enabled when plugged in)

- VM with limited CPU and RAM, and shared filesystem with host OS.

- Buy older laptop (not an option at this point, really)

- Stress the machine by compiling the Rust compiler in parallel :)


  👤 xenonite Accepted Answer ✓
The M1 chips have two types of cores: high-performance "Firestorm" cores and energy-efficient "Icestorm" cores, which are much slower.

It is indeed possible to constrain a process to the Icestorm cores using taskpolicy:

> taskpolicy -b -p 567

where 567 needs to be replaced by the process id.

Reference: https://eclecticlight.co/2022/10/20/making-the-most-of-apple...


👤 marginalia_nu
I understand it's not what you want to hear, but I think the only viable option is to test on real low powered hardware.

A throttled high-end machine will not behave like a low-end machine. Sure, they'll superficially both be slow, but not slow in the same way. There are differences in IOPS, cache sizes, and so forth you simply can't escape from.

Especially in low-end laptops, you may also have uneven performance from thermal throttling.


👤 timwis
If anyone needs to do this with an Intel-based MacBook Air 2020 model, the answer is much simpler: join a Google Meet call.

👤 booleanbetrayal
Docker Compose allows for resource limits which can be useful for testing harnesses. I know this works locally for v3.9:

  version: '3.9'
  services:
    some-container:
      deploy:
         resources:
           limits:
             cpus: '0.5'
             memory: 1.5G
           reservations:
             cpus: '0.5'
             memory: 1.5G
Reference: https://docs.docker.com/compose/compose-file/deploy/#resourc...

👤 bombcar
Honestly just buy an older laptop on eBay. Depending on how slow you want, they’re very cheap.

👤 saagarjha
There are many ways to stress the machine or deprioritize your program so that it behaves worse. That said, actually getting performance that is in-line with what your users on old machines would see is generally not easy to achieve. What are you working on? Perhaps there might be something that can be done specifically for your workload.

👤 jurmous
M1 has a low power mode in the battery section which limits CPU performance.

Geekbench scores with normal and low power mode

- Single core Normal/low power - 1749/1053

- Multi core - 7739/4491

https://www.reddit.com/r/MacOS/comments/qj13bv/m1_macbook_ai...


👤 dtorres

👤 gok
`sudo /usr/bin/cpuctl` can turn off cores, so for example you can turn off the performance cores.

👤 londons_explore
Depending on what your program is, you might be able to just do some testing on a users machine.

I sometimes use a remote desktop tool (eg. teamviewer) to troubleshoot my software running on a users machine (with the user on the phone normally).

It's usually the quickest way to understand what issue a user is having, and the user walks away thinking they're getting great customer service.

It could be a good way to get a rough feeling for which areas of your software perform well/badly on a low end machine. One benefit is you get to experience it the way a user does - so the interactions with a 7 year old copy of norton antivirus, one of 13 programs running at once with 1GB of RAM, the fact the user has an always-on-top program that is blocking some of the UI but they don't know how to move it, etc.


👤 jaimehrubiks
Why a VM would slow down the loop? You can have shared directories and you can communicate between the two

👤 enoch2090
VM is still an option, many VMs today allow easy file exchange between the host and the VM, with proper configuration you can still code and compile in your original workflow, and test in the VM.

👤 TheRealPomax
Was just buying an old mac from ebay not an option? Tons available still, I've bought several for that purpose over the years.

👤 terhechte
If you run something very performance hungry at the same time, the M1 will slow down considerably. Two things that constantly maxes out my M1 is either compiling the whole Rust compiler / toolchain (which is like 30min of heavy load) or rendering something complex in blender (with the Cycles renderer) which easily taxes the M1 for hours.

👤 Tagbert
I know that you don’t want to spend money on a test machine but you might want to check on used laptops through eBay or Craigslist or Offerup. Or someone here might have an older laptop sitting around.

👤 zffr
Does your program require macOS? If not, maybe you could run the program on a low-end machine from AWS/GCP. With terraform its pretty easy to create/destroy a VM on demand for testing.

👤 jspash
something something Electron.

👤 mrlonglong
That's easy, just use your bare hands to throttle that thing. Whether you succeed or not, depends on your strength.

👤 unsupp0rted
What about running a Virtual Machine and not giving it much ram and CPU to work with?

👤 bluedino
Do any of the Mac Mini hosting providers offer hourly/daily rental?

👤 locutous
You can force processes to the e-cores. That should be plenty slow :P

👤 usefulcat
Use a profiler?

👤 factorialboy
I use Zoom. CPU and battery drain.

👤 mzs
SIGSTOP/SIGCONT in a loop?

👤 nominusllc
There is a low power mode you can turn on in battery settings.

👤 0xCAP
Ever heard of Docker?

👤 timeimp
Put it in an oven and wait a bit.