Description
In #88091 we discovered a scaling limit on concurrent rustc
invocations when run outside of a build system that provides a jobserver pipe. In that configuration, the compiler creates its own pipe for internal thread scheduling, which means that each invocation of rustc
makes a pipe with two pages. On Linux, there is a soft limit on the number of per-user pipe pages which roughly nets out to allowing up to 512 concurrent rustc
s if there were no other processes using pipes.
Per @alexcrichton in #88091 (comment), this fallback jobserver doesn't need to be inherited by any forked processes which should mean it's OK to use an in-process concurrency controller instead of the jobserver client.
Looking at the code, I think it should be possible to refactor rustc_data_structures::jobserver::client()
to return a shim that can either dispatch to a real jobserver client or to an in-process semaphore. The client only seems to be used for rustc_data_structures::jobserver::{schedule_thread,release_thread}
and for LLVM thread creation, so it should be a smallish refactor.
cc @tmandry