You are not logged in.

#1 2020-12-24 20:12:37

mynis01
Member
Registered: 2011-04-29
Posts: 71

How to make my CPU less utilized while compiling with yay? [SOLVED!]

I'm brainstorming and trying to think of a way to make my CPU heat up less when I'm compiling. I have a Ryzen 3700x with a mid-range air cooler, and it's in "game mode" which sets it to a static clock of 4.2 GHz. This works great when I'm gaming in Windows and the temps stay manageable there. But when I'm compiling stuff in arch that takes more than 30 minutes, like chromium-dev for example, my temps will get into the low-to-high 90s. The same thing happens if I'm using something like handbrake or prime95 in Windows that maxes out all of the cores. What sucks about this too, is that the way I have everything configured in the BIOS, it basically makes it so "cpupower" stops working in Linux. I'm not really interested in changing the BIOS config if I can find a suitable workaround, because I was having an issue in Windows before where the CPU was sometimes downclocking to ridiculously low speeds while gaming, and setting it to "game mode" seems to have fixed that problem.

What I'd like to do, is figure out some way to make it so when yay invokes a compiler, the CPU doesn't get as heavily utilized. I'd like to do this without having to modify a pkgbuild or do some other manual change every time a program needs to be recompiled. I'm okay with the system taking a performance hit for other non-compilation related tasks too if needed - the system is way overkill for what I use it for in Linux anyways.

It would be cool if there's some way I could set nice levels for all the child processes that yay opens, but I haven't been able to figure out a way to do this.

Another thing that occurred to me is I could maybe just disable hyperthreading in Linux. I've heard there's some way to do this in GRUB but I haven't been able to figure it out yet.

If anyone has any other ideas or suggestions that would be awesome!

Last edited by mynis01 (2020-12-24 22:33:11)

Offline

#2 2020-12-24 20:16:40

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,787
Website

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

man makepkg.conf | less -p MAKEFLAGS

Mod note: Moving to AUR issues.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2020-12-24 21:03:52

loqs
Member
Registered: 2014-03-06
Posts: 17,194

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

mynis01 do the PKGBUILDs that use all cores use ninja?

Offline

#4 2020-12-24 21:12:39

mynis01
Member
Registered: 2011-04-29
Posts: 71

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

loqs wrote:

mynis01 do the PKGBUILDs that use all cores use ninja?

Funny you ask. I was reading the man page WorMzy said to check out. I had thought about setting makeflags before but figured I'd end up having mixed results depending on how the package is built. I set "-j8" (which should result in only 8/16 threads being used) in /etc/makepkg.conf, and then made sure that  ~/.makepkg.conf didn't exist in my home dir, and $XDG_CONFIG_HOME is not set. I then tried to compile chromium-vaapi, which is definitely using ninja, and yes it's maxing out all 16 threads.

I might try and compile linux-mainline or something in a sec here to see if setting the makeflags works there.

Last edited by mynis01 (2020-12-24 21:13:31)

Offline

#5 2020-12-24 21:18:27

loqs
Member
Registered: 2014-03-06
Posts: 17,194

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

ninja does not use makeflags thats why I asked about it.  If you set makeflags then linux-mainline as it is make based will use it.  Without makeflags being set make will use only one thread.
ninja you have to pass the option -j# to avoid it using starting number of cores + 2 jobs.

Offline

#6 2020-12-24 21:26:29

mynis01
Member
Registered: 2011-04-29
Posts: 71

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

loqs wrote:

ninja does not use makeflags thats why I asked about it.  If you set makeflags then linux-mainline as it is make based will use it.  Without makeflags being set make will use only one thread.
ninja you have to pass the option -j# to avoid it using starting number of cores + 2 jobs.

Awesome, that's definitely some good info there, so thanks. Do you by chance know off the top of your head if there's a config file where I can set that option once globally and not have to edit individual PKGBUILDS? If not I'll google some stuff and RTFM a little and see if I can figure this out.

Offline

#7 2020-12-24 21:40:32

loqs
Member
Registered: 2014-03-06
Posts: 17,194

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

Not tried this but in previous discussions which I can not currently find it came down to:
Define an alias before executing makepkg

alias ninja=ninja -j8

or use numactl to limit the available cores makepkg can use

numactl --physcpubind=0,2,4,6 makepkg

Last edited by loqs (2020-12-24 21:40:49)

Offline

#8 2020-12-24 22:32:11

mynis01
Member
Registered: 2011-04-29
Posts: 71

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

Setting the alias for ninja in ~/.bashrc didn't work for some reason. But I did this and it worked:

numactl --physcpubind=0,2,4,6 yay -S chromium-vaapi

It looks like the numactl command is pretty predictable as far as how it propagates down to the child processes for yay. That's a super useful command for my use case so thanks for sharing! Marking this thread as solved. I'll work on setting up an alias later so yay just always runs with numactl and I imagine that should work just fine.

Last edited by mynis01 (2020-12-24 22:32:39)

Offline

#9 2020-12-24 22:35:01

kermit63
Member
Registered: 2018-07-04
Posts: 171

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

An alternative is to use something like Cpulimit. I used it before when I was doing folding@home which raised by temps to unsafe levels. It's available from the arch repos.

edit: oops, didn't see your last post.

Last edited by kermit63 (2020-12-24 22:39:00)

Offline

#10 2020-12-27 06:53:35

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: How to make my CPU less utilized while compiling with yay? [SOLVED!]

https://archlinux.org/packages/communit … 4/samurai/ is a c99 reimplementation of ninja that supports SAMUFLAGS=-j8 (note you will need to export it since makepkg.conf does not directly support it).

loqs, aliases only work in interactive shells and they don't work in scripts (like makepkg). Not even if you add them to bashrc, since that's still not sourced by scripts...


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB