Skip to content

rustc_data_structures::jobserver should fall back to an in-process implementation if no jobserver in environment #88117

Open
@anp

Description

@anp

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 rustcs 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions