Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--jobs not respected in Bazel 7 #20521

Closed
chiragramani opened this issue Dec 13, 2023 · 4 comments
Closed

--jobs not respected in Bazel 7 #20521

chiragramani opened this issue Dec 13, 2023 · 4 comments
Assignees
Labels
team-Performance Issues for Performance teams type: bug untriaged

Comments

@chiragramani
Copy link
Contributor

chiragramani commented Dec 13, 2023

Description of the bug:

We have used --jobs to control the number of jobs that should be executed concurrently. This works as expected in Bazel 6 however, in Bazel 7, this functionality does not work as expected.

Which category does this issue belong to?

Core

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. This is a modified version of the official bazel examples.
    JobsRepro.zip
  2. With bazel 7,
build :hello-time :hello-time1 :hello-time2 :hello-time3 :hello-time4

even though jobs=1 is specified in the .bazelrc, we still see parallel jobs > 1.
Screenshot 2023-12-13 at 12 57 12 PM
3. But the same example, with Bazel 6.4, respects --jobs=1.
Screenshot 2023-12-13 at 12 58 43 PM

  1. With Bazel 7, if I use --local_cpu_resources=1, then it seems to work as expected. But from the documentation, --jobs is a global override to control such parallelism, wondering if this is a regression or if this behavior is driven differently in Bazel 7 intentionally.

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

7.0.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@coeuvre
Copy link
Member

coeuvre commented Dec 13, 2023

It's due to the upgrade to JDK21 where the implementation of ForkJoinPool has changed -- the number of core threads is larger than --jobs. I can get the old behaviour by using --experimental_use_semaphore_for_jobs with your repro. We probably should flip and remove this flag.

@coeuvre
Copy link
Member

coeuvre commented Dec 13, 2023

@bazel-io fork 7.1.0

@chiragramani
Copy link
Contributor Author

It's due to the upgrade to JDK21 where the implementation of ForkJoinPool has changed -- the number of core threads is larger than --jobs. I can get the old behaviour by using --experimental_use_semaphore_for_jobs with your repro. We probably should flip and remove this flag.

Thanks for looking into it. Yes, using --experimental_use_semaphore_for_jobs helped. Thanks for sharing this workaround!

bazel-io pushed a commit to bazel-io/bazel that referenced this issue Dec 21, 2023
Bazel 7 upgrades its runtime JVM to 21. However, the implementation of `ForkJoinPool` in JDK 21 is changed so that the number of concurrent actions may be larger than `--jobs`.

Flag `--experimental_use_semaphore_for_jobs` was introduced to fix this problem. This CL flips it to make `--jobs` work again by default.

Fixes bazelbuild#20521.

PiperOrigin-RevId: 590834204
Change-Id: I0ddf1e1a088eb4d917036350533df94c17ac48e6
github-merge-queue bot pushed a commit that referenced this issue Jan 11, 2024
Bazel 7 upgrades its runtime JVM to 21. However, the implementation of
`ForkJoinPool` in JDK 21 is changed so that the number of concurrent
actions may be larger than `--jobs`.

Flag `--experimental_use_semaphore_for_jobs` was introduced to fix this
problem. This CL flips it to make `--jobs` work again by default.

Fixes #20521.

Commit
3c298fd

PiperOrigin-RevId: 590834204
Change-Id: I0ddf1e1a088eb4d917036350533df94c17ac48e6

Co-authored-by: Googler <chiwang@google.com>
Co-authored-by: Yun Peng <pcloudy@google.com>
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Performance Issues for Performance teams type: bug untriaged
Projects
None yet
Development

No branches or pull requests

6 participants