Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
a use model for ccache...to solve llvm-16 running out of RAM
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo Chat
View previous topic :: View next topic  
Author Message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9846
Location: almost Mile High in the USA

PostPosted: Mon Oct 09, 2023 3:25 pm    Post subject: a use model for ccache...to solve llvm-16 running out of RAM Reply with quote

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
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2037

PostPosted: Tue Oct 10, 2023 4:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9846
Location: almost Mile High in the USA

PostPosted: Tue Oct 10, 2023 4:50 pm    Post subject: Reply with quote

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
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3477

PostPosted: Tue Oct 10, 2023 7:11 pm    Post subject: Reply with quote

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
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1339
Location: Richmond Hill, Canada

PostPosted: Tue Oct 10, 2023 7:36 pm    Post subject: Reply with quote

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 8O
  • 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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9846
Location: almost Mile High in the USA

PostPosted: Tue Oct 10, 2023 7:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3776
Location: Rasi, Finland

PostPosted: Tue Oct 10, 2023 7:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2037

PostPosted: Tue Oct 10, 2023 9:01 pm    Post subject: Reply with quote

See also bug 692576 and https://github.com/gentoo/portage/pull/913.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9846
Location: almost Mile High in the USA

PostPosted: Tue Oct 10, 2023 11:38 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 22866

PostPosted: Wed Oct 11, 2023 12:05 am    Post subject: Reply with quote

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
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9846
Location: almost Mile High in the USA

PostPosted: Wed Oct 11, 2023 1:01 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo Chat All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum