c97bee80

By: Tom Sydney Kerckhove <syd@cs-syd.eu>

Respect the cores nix gave the build

A test suite compiled with -N asks the RTS for every core of the machine
it runs on, which inside a nix build is not what the build was given.
Nix's cores setting reaches a build only as NIX_BUILD_CORES, so read
that, and let it decide how parallel to run when nothing else does.
Nix's --max-jobs is not visible to a build at all, so there is nothing
to respect there.

It narrows, and only narrows. Anything configured explicitly still
decides: --jobs, --synchronous, SYDTEST_JOBS, threads in the config
file, and --debug all win, so an ambient variable cannot override a
config file. More cores than the RTS has capabilities leaves the count
alone rather than raising it, because running more tests at once than
the RTS can overlap is contention with no parallelism to show for it: a
suite not compiled with -N has one capability, and running it 64 ways
because the builder has 64 cores would be a change for the worse. The
narrowing also happens after the warning about compiling with -N is
decided, so a suite stuck on one capability is still told to add it.

Zero threads now means every capability rather than an asynchronous
runner with no workers. --jobs 0 left nothing to take tests off the
queue and the suite died with "thread blocked indefinitely in an STM
transaction". Nix documents 0 as "use every core", which is how
NIX_BUILD_CORES=0 reaches a build wherever stdenv has not already
replaced it with a core count, and the mutation driver's own job counts
have always treated it that way, so every route into a thread count now
agrees.
GitHub

Total

3m47s

Created Started Finished

Time to Start Worker time Duration Time to finish Idle
Config 3m57s 0s 0s 3m58s 3m57s
Eval 3m58s 3m46s 3m46s 7m44s 1m16s
Build - - - - -
Suite 3m57s 3m46s 3m47s 7m44s 5m14s

Timeline

Config Eval Failed Retried Compressed gap
0s4m4m20s4m40s5m5m20s5m40s6m6m20s6m40s7m7m20s7m40s