Skip to content

x.py doesn't limit job concurrency effectively #81957

Closed
@tgnottingham

Description

@tgnottingham

tl;dr -- I believe Cargo -jN limits you to N concurrent codegen workers, while x.py -jN limits you to N * number of CPUs concurrent codegen workers, which is rough for memory usage during bootstrap. E.g. on an 8 CPU system, -j4 would not limit you to 4, but to 32 concurrent codegen workers.


With Cargo, my understanding is that -j4 limits you not only to compiling at most four crates at once, but that it limits you to running at most four of certain types of jobs within rustc at once, across all rustc instances under that Cargo invocation (maybe across multiple concurrent Cargo invocations?). This relates to jobs whose concurrency is dictated by the jobserver mechanism, like codegen.

(Actually, I'm not sure that's 100% correct. It's easy to see that -j limits the max number of codegen workers active within an individual rustc instance, but I don't know how to verify if it limits them across all instances. The number of rustc threads in general isn't limited by this from what I've seen.)

But with x.py, -j4 only seems to limit you to compiling at most four crates at once. I can see that each rustc instance is still able to have up to 8 codegen workers simultaneously, including the main thread (probably 8 because my system has 8 CPUs). But I'm not sure if all of the rustc instances are globally limited to 8 concurrent jobs, or if they're individually limited to 8, so that the global limit is effectively 32 concurrent jobs.

I expect that changing this to limit concurrency the way Cargo does would significantly reduce memory usage during bootstrap. It would also reduce the amount of concurrency, unless you increase the -j setting, but it's possible that the extra concurrency was overkill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions