-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
RFC: -j/--jobs for zig subcommands #12101
Copy link
Copy link
Open
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.Tokenization, parsing, AstGen, Sema, and Liveness.
Reason: bazel-zig-cc invokes
zig cc. Bazel takes care of parallelism itself, so it will assume zig is a "simple" command that uses a single core. It is not, however.On many-core machines this leads to many parallel processes using many cores. Thus we should use
zig cc -j1(or equivalent) in bazel-zig-cc. Otherwise the number of jobs multiples quickly. (Unfortunately, Bazel neither supports jobserver nor can limit the number of downstream cores via cgroups or similar.)I have almost implemented
-jN, --jobs=Nlike this:ThreadPool.init()accepts a new argumentjobs: ?usizejobsis set, uses that variable forthread_count, otherwise the behavior is as before.And interesting questions ensued:
-jN, --jobs=Na reasonable argument to add tozig cc,zig build-*et al?clang/include/clang/Driver/Options.td). Is this OK as a precedent to havezig ccoptions that are not validclangoptions? I can also do this go-style viaZIGMAXPROCS. :)EDIT: removed a long question about two thread pools in
src/test.zig, that was somewhat answered in a commit message where they were introduced.