View previous topic :: View next topic |
Author |
Message |
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9846 Location: almost Mile High in the USA
|
Posted: Mon Oct 09, 2023 3:25 pm Post subject: a use model for ccache...to solve llvm-16 running out of RAM |
|
|
Argh.
It appears that llvm-16 is no longer fitting in 2GB RAM probably because I wanted to use distcc, once again llvm-tblgen is consuming all RAM and causing the computer to thrash.
Well what I was wondering... perhaps I should start using ccache - basically do this:
<enable ccache>
FEATURES=distcc MAKEOPTS="-j 32" emerge -1 llvm
<wait until it starts thrashing in llvm-tblgen>
^C <abort>
MAKEOPTS="-j1" emerge -1 llvm
Then it should pick up the pieces with ccache and hope it can actually finish.
It's unfortunate that this has to be done in two steps, I really wish that some of these RAM intensive or undistributable steps can automatically take a smaller -j option and let the distributable segments get a large -j option.
The same problem for dev-lang/rust where a larger -j is good for the compile of llvm at the beginning as it's distributable, but a lower -j option for the rustc portion during the latter part as rustc is not distributable. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
sam_ Developer
Joined: 14 Aug 2020 Posts: 2037
|
Posted: Tue Oct 10, 2023 4:38 pm Post subject: |
|
|
I really doubt this is worth the time saving from the manual babysitting you have to do. Just use an appropriate MAKEOPTS for the package and set it in /etc/portage/package.env for larger software. Then go spend your time on something else. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9846 Location: almost Mile High in the USA
|
Posted: Tue Oct 10, 2023 4:50 pm Post subject: |
|
|
Yeah it is a pain, wish that the build scripts would take into account expected workload - specifically for processes that generate a load average over 1 for each invocation, and feed that back to make/ninja/...
Just want to optimize completion time/decrease latency sometimes - like if the thing you're emerging is necessary for something else -- and it may not even be in portage. Say a private project needs a new version of llvm ... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3477
|
Posted: Tue Oct 10, 2023 7:11 pm Post subject: |
|
|
You could try limiting parallelism with load. I think it's -l in MAKEOPTS.
Hitting SWAP should make your load skyrocket due to processes waiting for disk IO.
Another thing, emerge has a bunch of hooks. Perhaps there is one that could be used to restart a failed build with some options changed? |
|
Back to top |
|
|
pingtoo Veteran
Joined: 10 Sep 2021 Posts: 1339 Location: Richmond Hill, Canada
|
Posted: Tue Oct 10, 2023 7:36 pm Post subject: |
|
|
eccerr0r wrote: | wish that the build scripts would take into account expected workload - specifically for processes that generate a load average over 1 for each invocation, and feed that back to make/ninja/...
Just want to optimize completion time/decrease latency sometimes - like if the thing you're emerging is necessary for something else -- and it may not even be in portage. Say a private project needs a new version of llvm ... |
Just few ideas - What if modify portage such that job scheduling as a plugin, so that is possible to develop different optimisation strategy?
- Having a score program that can generate a "Gentoo score" based on hardware capability and submit to online database. Also upload genlop output, so it give a historical log than emerge can fetch this information to predict each job load requirement?
Just quick thoughts may not be logically sound but just threw it out for thoughts |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9846 Location: almost Mile High in the USA
|
Posted: Tue Oct 10, 2023 7:44 pm Post subject: |
|
|
szatox wrote: | You could try limiting parallelism with load. I think it's -l in MAKEOPTS. |
That's what I've been doing, alas make and the crappy programs that fool make/ninja think it uses just one slot but in reality takes more than one slot. Like if I say -l2 and it comes time to schedule when the load average drops to 0, it decides to run two jobs...and each job spawns its own 4 threads, suddenly your load average is 8 and it won't come down until both jobs finish...
Quote: | Another thing, emerge has a bunch of hooks. Perhaps there is one that could be used to restart a failed build with some options changed? |
Now there's an idea... HMM... then again it can take a long time before it figures out it's out of RAM. Just hoping that the build *smartly* uses swap - thrash swapping (i.e. needing to page in/out on every context swap) is to be avoided.
pingtoo wrote: | Just few ideas 8O [list][*]What if modify portage such that job scheduling as a plugin, so that is possible to develop different optimisation strategy? |
The thing is that the best strategy can change during the merge, so portage has no chance of optimizing it. It's totally within the package itself that needs to be optimized... _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Zucca Moderator
Joined: 14 Jun 2007 Posts: 3776 Location: Rasi, Finland
|
Posted: Tue Oct 10, 2023 7:59 pm Post subject: |
|
|
eccerr0r wrote: | szatox wrote: | You could try limiting parallelism with load. I think it's -l in MAKEOPTS. |
That's what I've been doing, alas make and the crappy programs that fool make/ninja think it uses just one slot but in reality takes more than one slot. Like if I say -l2 and it comes time to schedule when the load average drops to 0, it decides to run two jobs...and each job takes 4 threads, suddenly your load average is 8 and it won't come down until both jobs finish... | I've witnessed problems with this too.
I'm certain it worked better before with same packages... I've tested with firefox and gentoo-kernel.
Both builds had --jobs=8 --load-average=7.80 in MAKEOPTS. Now the loads creep close to 16.
So I've settled to Code: | MAKEOPTS="--jobs=4 --load-average=7.20" | I essentially lose hyperthreading (the AMD version) when running a single build process. _________________ ..: Zucca :..
My gentoo installs: | init=/sbin/openrc-init
-systemd -logind -elogind seatd |
Quote: | I am NaN! I am a man! |
|
|
Back to top |
|
|
sam_ Developer
Joined: 14 Aug 2020 Posts: 2037
|
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9846 Location: almost Mile High in the USA
|
Posted: Tue Oct 10, 2023 11:38 pm Post subject: |
|
|
Currently I think the two classes of evil are (for distcc/portage)...
- all sorts of LTO. For some reason LTO thinks it's ok to spawn a whole bunch of jobs. Really need to stop it from doing it if make is submitting these jobs, at least using -l with make will limit -- but not of one job spawns 16 sub-jobs. At least IIRC all the times I've seen LTO builds it spawns a whole bunch of jobs, and load average ends up way higher than -l specification.
- anything that has mixed builds of (some non distcc'able language like rust) + C/C++ -- things like librsvg and cbindgen are fine since they're pretty much all rust so we can make a package.env for them, but rust itself (C++ for LLVM, and rust for the rest of rust) and things like firefox (mixture of C++ and rust).
I don't know if portage integration really is the problem. Using emerge --jobs is one thing, mainly I run it because of the faster merge/ebuilds that have a lot of single threaded portions compared to the compile portion so some parallelism can be gotten there, but usually that is not CPU intensive and more disk i/o than CPU. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
Hu Administrator
Joined: 06 Mar 2007 Posts: 22865
|
Posted: Wed Oct 11, 2023 12:05 am Post subject: |
|
|
Exactly what command line options are you using to enable LTO? Depending on how you invoke it, it can interface with the GNU make jobserver to manage the maximum number of job tokens the LTO processing consumes. |
|
Back to top |
|
|
eccerr0r Watchman
Joined: 01 Jul 2004 Posts: 9846 Location: almost Mile High in the USA
|
Posted: Wed Oct 11, 2023 1:01 am Post subject: |
|
|
Not sure, thought the default should deal with it?
I'm not even sure what llvm-tblgen is doing, it's part of the llvm build that seems to be disobeying load average for some reason. _________________ Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching? |
|
Back to top |
|
|
|