How to reduce the number of ninja processes?

Questions, problems and discussion about compiling FreeOrion.

Moderators:Oberlus, Oberlus

Post Reply
Message
Author
Uriuk
Pupating Mass
Posts:99
Joined:Wed Jan 01, 2020 9:06 am
How to reduce the number of ninja processes?

#1 Post by Uriuk » Mon Jan 06, 2020 10:59 pm

I want to build the freeorion program on a machine with low RAM (8 GB). During the compilation it uses command "ninja" with the parameter -j 16.

http://manpages.org/ninja
-j N
run N jobs in parallel [default=derived from CPUs available]

How to reduce that number, to avoid such high memory usage?
I tried to pass -j 1 to emerge command

https://dev.gentoo.org/~zmedico/portage ... rge.1.html
j [JOBS], --jobs[=JOBS]
Specifies the number of packages to build simultaneously. If this option is given without an argument, emerge will not limit the number of jobs that can run simultaneously. Also see the related --load-average option. Similarly to the --quiet-build option, the --jobs option causes all build output to be redirected to logs. Note that interactive packages currently force a setting of --jobs=1. This issue can be temporarily avoided by specifying --accept-properties=-interactive.

but ebuild doesn't respect it.

Code: Select all

...
>>> Working in BUILD_DIR: "/var/tmp/portage/games-strategy/freeorion-0.4.8_p20190501/work/freeorion-0.4.8_p20190501_build"
ninja -v -j16 -l0
[1/268] /usr/bin/x86_64-pc-linux-gnu-g++ -DBINPATH=\"/usr/bin\" -DBOOST_ALL_DYN_LINK -DBOOST_ALL_NO_LIB -DBOOST_GIL_IO_ENABLE_GRAY_ALPHA -DBOOST_LOG_DYN_LINK -DBOOST_LOG_NO_LIB -DENABLE_BINRELOC -DFONS_USE_FREETYPE -DFREEORION_LINUX -DGiGi_EXPORTS -DSHAREPATH=\"/usr/share\" -I/var/tmp/portage/games-strategy/freeorion-0.4.8_p20190501/work/freeorion-2a49c05796f1c92b96ce9b2aeaf0124fc8be7a77/GG -IGG -isystem /usr/include/freetype2  -DNDEBUG -O2 -g1 -march=x86-64 -pipe -fPIC   -Wall -std=c++11 -MD -MT GG/CMakeFiles/GiGi.dir/src/RichText/BlockControl.cpp.o -MF GG/CMakeFiles/GiGi.dir/src/RichText/BlockControl.cpp.o.d -o GG/CMakeFiles/GiGi.dir/src/RichText/BlockControl.cpp.o -c /var/tmp/portage/games-strategy/freeorion-0.4.8_p20190501/work/freeorion-2a49c05796f1c92b96ce9b2aeaf0124fc8be7a77/GG/src/RichText/BlockControl.cpp
The instruction on the URL https://github.com/freeorion/freeorion/ ... r/BUILD.md
contain a broken link under the words "check out the the make jobs parameter of make."

The instruction at
https://www.freeorion.org/index.php/Compile
https://www.freeorion.org/index.php/Compile_In_Linux
doesn't describe the ninja.

which file to patch before compilation, and how to do that in gentoo?

User avatar
adrian_broher
Programmer
Posts:1155
Joined:Fri Mar 01, 2013 9:52 am
Location:Germany

Re: How to reduce the number of ninja processes?

#2 Post by adrian_broher » Tue Jan 07, 2020 12:12 am

which file to patch before compilation, and how to do that in gentoo?
None of the the project files, thats for certain. The cmake build setup of freeorion doesn't enforce a specific build system or job count. Those are set by the person or the plaform that invokes the compile.

The `-j` parameter of ebuild states:
Specifies the number of packages to build simultaneously.
I don't know the specific lingo that gentoo uses, but a package is most certainly corresponds to to application or library. So you are instructing ebuild to build a single application at a time and not how many compiler jobs it should start at the same time.

Also what about the ninja-utils.eclass. According to their manual https://devmanual.gentoo.org/eclass-ref ... index.html
This eclass provides a single function -- eninja -- that can be used to run the ninja builder alike emake. It does not define any dependencies, you need to depend on dev-util/ninja yourself. Since ninja is rarely used stand-alone, most of the time this eclass will be used indirectly by the eclasses for other build systems (CMake, Meson).
I do no use gentoo, but I would assume you can set the corresponding ninja build options via the NINJAOPTS environment variable:

Code: Select all

NINJAOPTS="-j 1" emerge freeorion
or something similar.
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

Uriuk
Pupating Mass
Posts:99
Joined:Wed Jan 01, 2020 9:06 am

Re: How to reduce the number of ninja processes?

#3 Post by Uriuk » Tue Jan 07, 2020 12:20 am

yes, with NINJAOPTS now it's much better:
>>> Working in BUILD_DIR: "/var/tmp/portage/games-strategy/freeorion-0.4.8_p20190501/work/freeorion-0.4.8_p20190501_build"
ninja -v -j 1
[1/268] /usr/bin/x86_64-pc-linux-gnu-g++

Post Reply