Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit cpu usage for a terminal command that works on m1 mac and macOS Monterey?

I have a m1 macbook pro and I regularly need to do some heave processing with ffmpeg. When I do it, all my 8 cores go at it 100% and my cpu temperature goes to 92°C, which I don't feel comfortable about.

I don't really need 100% speed, I'd much rather see 80°C and wait 5x longer for it to finish.

I use Macs Fan Control which sets my fan at 100% at 75°C, so this helps definitely, but is not enough.

I tried ffmpeg -threads 1 parameter but it doesn't make a difference in compressing speed nor temperature, so I assume it just doesn't work.

I tried cpulimit -l 60 -i ffmpeg ... and it doesn't change a thing, so I assume it also doesn't work. cpulimit -l value gives 100% for every core, so cpulimit -l 800 should be 100%, -l 400 should be 50% and -l 60 should be 7.5%.

I tried nice and it is not for my use case. Even with the lowest priority the task uses all available cpu, resulting in 92°C.

Did anybody figure it out for m1 macs already?

like image 228
mcaay Avatar asked Oct 27 '25 08:10

mcaay


1 Answers

One way to reduce the CPU usage is to use taskpolicy, as in

taskpolicy -b program

This will run the program and the -b flag sets its priority to that of a background process (PRIO_DARWIN_BG), which is a reduced one.

It can also be used when the program is already running by using the -p pid option.

like image 187
ttq Avatar answered Oct 29 '25 02:10

ttq