-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stdenv: allow for jobservers across multiple nix builds #314888
base: staging
Are you sure you want to change the base?
Conversation
doc/stdenv/stdenv.chapter.md
Outdated
@@ -1355,6 +1355,30 @@ name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" | |||
someVar=$(stripHash $name) | |||
``` | |||
|
|||
### `runInJobServer` \<command\> \-\-\-\- \<defArgs\> \-\-\-\- \<args\> {#fun-runInJobServer} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### `runInJobServer` \<command\> \-\-\-\- \<defArgs\> \-\-\-\- \<args\> {#fun-runInJobServer} | |
### `runInJobserver` \<command\> \-\-\-\- \<defArgs\> \-\-\-\- \<args\> {#fun-runInJobServer} |
(multiple places)
config = mkIf cfg.enable { | ||
nix.sandboxPaths = [ "/build-support/jobserver=${tokenFile}?" ]; | ||
|
||
systemd.services.nixos-jobserver = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
running this as root is most unwise in practice but running it as another user seems to be nearly impossible. when fuse doesn't fuck us over systemd does.
|
||
struct stat jobserver_st = { | ||
.st_ino = FUSE_ROOT_ID, | ||
.st_mode = S_IFREG | 0660, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.st_mode = S_IFREG | 0660, | |
.st_mode = S_IFREG | 0666, |
won't work otherwise
pkgs/stdenv/generic/setup.sh
Outdated
if [[ -n "$enableParallelChecking" ]]; then | ||
runInJobserver \ | ||
make ---- \ | ||
-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES} ---- \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-j${NIX_BUILD_CORES} -l${NIX_BUILD_CORES} ---- \ | |
-j${NIX_BUILD_CORES} ---- \ |
multiple places
cargo apparently no longer accepts jobserver fds that aren't pipes. that's somewhat problematic. |
initially only make and cargo support using the jobserver. other build systems may follow suit later.
Co-authored-by: Raito Bezarius <[email protected]>
Is this work dead? It looked very promising. |
I have some patches lying around locally to make it work with ninja, so anyone interested in picking this up, feel free to write me about it. |
Description of changes
Retake of #143820 where I unfortunately fucked up trying to debug kernel issues and btrfs.
Original motivations by @pennae:
make -jN -lN
in stdenv is a very blunt instrument. it works well when max-jobs=1, but as nix-level paralellism increases it becomes increasingly deficient. starting from a low-load situation we start max-jobs * N compilers, loadavg goes through the roof, the-lN
load limit kicks in and inhibits new compilers starting until loadavg has fallen below N—at which point all make instances spawn a lot of new compilers and loadavg goes through the roof again. this oscillation leaves the system underutilized in low phases and overcommitted in high phases.testing the current stdenv against a jobserver with 26 tokens on a 12C/24T machine shows that parallel builds of llvm_{8..11} run about 7% faster (35:52min for stdenv, 33:30min with jobserver), a larger build of llvm{5..13} is about about 11% faster (1:27h for stdenv, 1:17h with jobserver). (
removing the[more testing says that-l
from stdenv also improves utilization but is less efficient. preliminary testing here shows that-l${1.5 * N}
may be a good alternative to-lN
as used currently, #141266 could be a good vector to go for that instead of this whole mess.-l2N
would be a minimum to get better utilization, but so far every-l
setting we've tried has produced some underutilization except excessive large numbers like 6N or higher])nothing in here should be regarded as a final suggestion in any way, it's more of a "hey look, this might just work". as such it's extremely rough around the edges, eg to use the jobserver the experimenter currently has to bring a
/jobserver
fifo filled with tokens into the nix sandbox:is this something worth pursuing? a 10% speedup for hydra does seem tempting
todos before this is more generally usable:
Things done
nix.conf
? (See Nix manual)sandbox = true