AdaCore / gprbuild

GPRbuild is an advanced build system designed to help automate the construction of multi-language systems.
Other
65 stars 21 forks source link

Do not use all available threads for bootstrap #134

Closed Irvise closed 1 year ago

Irvise commented 1 year ago

https://github.com/AdaCore/gprbuild/blob/1baa403991b49487a59ec44ff99b7a59cd200d83/bootstrap.sh#L18

The bootstrap script uses the -j0 option, which tells gnatmake to use all cores/threads that are available in the system to build the bootstrap. This, in principle is okay and should not cause any issues. However, gnat/gnatmake can consume quite a bit of memory. If the system that is running the build does not have much free memory and it does have quite a few cores, this will overwhelm the machine. For example, my Raspberry Pi 3 cannot handle the bootstrapping procedure, as the 4 CPUs get used and each build consumes about 300MB at its peak. This requires more than the 900MB of free memory that my system has.

I think a bootstrap script should not be trying to be performant, but have a simple and easy way of building the tool. Later down the line, more powerful options can be used if desired by the user. I propose that it is set to -j1 or be made an option.

Feedback is welcome. I did not submit a patch since I would like to get feedback first. Regards, Fer

t-14 commented 1 year ago

I propose that it is set to -j1 or be made an option.

But it is, precisely, an option, i.e. you can override it. E.g.:

GNATMAKEFLAGS=-j1 bootstrap.sh

will run it at -j1. Isn't this what you need?

Irvise commented 1 year ago

Uhh... My shell-fu is not that great. I did not recognise it as an option. Yes, that is what I needed. Thank you for your time and I am sorry for the inconvenience.

t-14 commented 1 year ago

No problem! Glad to hear this was indeed what you were looking for.