You are not logged in.
I maintain several AUR programs that use ninja as build system.
By default ninja uses nproc + 2 as jobs setting.
On my 12C/24T threadripper system with 16 Gib memory (ECC ram is expensive...) this results in my system becoming unresponsive and needing to swap parts out of memory .
I have $MAKEFLAGS=--j20 in makepkg.conf , but ninja doesn't use $MAKEFLAGS envvar .
I've found topics going back to 2015 about this and similar issues, https://github.com/ninja-build/ninja/issues/1482 looks promising.
No idea if/when it will be available from ninja.
executing ninja like this
ninja "$MAKEFLAGS" all ocaml_doc
does mean my system has capacity for other things and doesn't need to swap stuff out from memory.
This fails however if MAKEFLAGS is unset.
I can test whether MAKEFLAGS is set, and assign an arbitrary value like "-j$(nproc)" but feel this is still to high.
something like 85% of nproc , rounded down works well for me, but I have no idea how to calculate such a value and store it in MAKEFLAGS.
Before I implement such a solution in my aur packages using ninja i'd like to hear the opinion of other aur users & maintainers.
Last edited by Lone_Wolf (2019-04-27 12:59:12)
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
Looking at https://github.com/ninja-build/ninja/bl … il.cc#L493 ninja checks sched_getaffinity
so if you start makepkg with `taskset --cpu-list 0-11 makepkg` does that cause ninja to use 14 threads of your 24 core system?
Offline
It does influence performance and load by a lot, but no idea how to check how many threads/ jobs ninja uses.
comparing performance of taskset 0-19 with that of -j20 suggests the performance is worse with taskset.
Maybe scheduler overhead is causing that ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
ninja adds 2 to the number of processes it uses when it detects more than 2 cores [1] so 0-19 should be equivalent to -j22 but run on 20 cores.
Offline
Reduced cpulist to 0-17 to have ninja run 20 jobs, this does bring performance with this specific task much closer to running with -j20.
Ninja is very fast and reliable, but I sometimes wish the effort to create ninja (and meson) had been spend to improve make / autotools.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
I build some more ninja packages and observed.
Using taskset is more restrictive then ninja -j option .
I'll use something like this :
if [[ ! $MAKEFLAGS ]]; then
ninja
else
ninja "$MAKEFLAGS"
fi
EDIT:
I've configured several packages this way now and it does appear to work fine.
I'm not marking this as solved yet, as both taskset and this if-then-else are workarounds.
Still hoping there are other options.
Last edited by Lone_Wolf (2019-04-28 11:13:38)
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
Aur comments by lahwaacz made me realise ninja supports only a small part of the options MAKEFLAGS allow.
Running ninja "$MAKEFLAGS" does have a high chance of failing if those options are used.
I will switch to a dedicated envvar, NINJAFLAGS .
Add to makepkg.conf :
# limit ninja to 20 jobs
# requires special code in PKGBUILD
# see ninja --help for additonal options
NINJAFLAGS="-j20"
in PKGBUILD :
if [[ ! $NINJAFLAGS ]]; then
ninja
else
ninja "$NINJAFLAGS"
fi
This should allow users to configure ninja in whatever way they want without clashing with other programs.
Those that prefer ninja defaults have to do nothing.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline