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

Allow parallel blaze invocations #532

Open
schroederc opened this issue Oct 26, 2015 · 13 comments
Open

Allow parallel blaze invocations #532

schroederc opened this issue Oct 26, 2015 · 13 comments
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Performance Issues for Performance teams type: feature request

Comments

@schroederc
Copy link
Contributor

The time spent waiting for another Bazel command seems wasted. Can Bazel accomplish some work in tandem with the other command since Bazel uses a server daemon?

In particular, can bazel build //some:target and bazel build //some/other:target have their action graphs joined together and each separate command finish when its requested targets are completed?

However, at the very least, can Bazel show the progress of the other command?

@ulfjack
Copy link
Contributor

ulfjack commented Oct 26, 2015

Doing multiple builds in parallel over possibly slightly different files is - in general - a tricky problem. That said, we're currently not even able to run commands in parallel even if we know that they can't interfere (say bazel help and bazel info).

Even passing information from one command to another isn't currently possible. The client takes an exclusive lock every time you run bazel, and the server doesn't have the ability to handle two connections at the same time.

I've made some progress on updating our core code for this, recently. Check out my changes to BlazeRuntime.java and CommandEnvironment.java. It's not a high priority for me right now, though, so progress will likely be patchy.

@ahumesky
Copy link
Contributor

If you're building the targets with the same configuration though (e.g.,
same flags, same target architecture, etc), you can build both targets with
the same invocation:
bazel build //some:target //some/other:target
or even:
bazel build //some/...:all

and if they have any shared dependencies, bazel will build those only once.
If these are under different configurations, you could use --output_base to
start a separate bazel server for the same workspace, but the two servers
won't share work.

On Mon, Oct 26, 2015 at 4:56 PM Ulf Adams notifications@github.com wrote:

Doing multiple builds in parallel over possibly slightly different files
is - in general - a tricky problem. That said, we're currently not even
able to run commands in parallel even if we know that they can't interfere
(say bazel help and bazel info).

Even passing information from one command to another isn't currently
possible. The client takes an exclusive lock every time you run bazel, and
the server doesn't have the ability to handle two connections at the same
time.

I've made some progress on updating our core code for this, recently.
Check out my changes to BlazeRuntime.java and CommandEnvironment.java. It's
not a high priority for me right now, though, so progress will likely be
patchy.


Reply to this email directly or view it on GitHub
#532 (comment).

@jart
Copy link
Contributor

jart commented Apr 11, 2018

@ulfjack I've been thinking about adding ibazel functionality to rules_closure. The way I'd do it is with fork() on POSIX. That way I can escape the bazel run restriction. I don't need bazel query since Skylark will give me the build graph information. Then in my forked process, I can use java.nio.file.WatchEvent (see code) to farm out bazel build //foo commands, assuming what I did originally was bazel run //foo.

@ulfjack
Copy link
Contributor

ulfjack commented Apr 12, 2018

bazel run now has a --direct_run option that releases the lock before running the tool (and also allows the tool direct access to the terminal), so you don't need to work around that specifically anymore. We're working on enabling that by default for all bazel run invocations, but are seeing issues due to minor changes in semantics. @lberki

@lberki
Copy link
Contributor

lberki commented Apr 12, 2018

Actually, I think we can just flip the default in Bazel. In the worst case, we can force it to be turned off internally. Let me send a change...

@jart
Copy link
Contributor

jart commented Apr 12, 2018

@ulfjack That's the best news ever. Just added run --direct_run to my ~/.bazelrc.

@jart
Copy link
Contributor

jart commented Apr 12, 2018

@ulfjack While we're on the topic, maybe consider making --distinct_host_configuration=false the default for Bazel. It makes protobuf take half as long to build. The TensorBoard team has found this very helpful for our Travis CI builds.

@meisterT meisterT changed the title Alternatives to "Another Bazel command is running (pid = 12345). Waiting for it to complete..." Allow parallel blaze invocations Nov 29, 2018
@meisterT meisterT added team-Performance Issues for Performance teams and removed category: performance labels Nov 29, 2018
@meisterT meisterT removed this from the 1.0 milestone May 11, 2020
@jgarvin
Copy link

jgarvin commented Jan 11, 2021

With bazel 3.2.0 I get a message saying --direct_run is deprecated and independent commands still block each other.

@lberki
Copy link
Contributor

lberki commented Jan 11, 2021

--direct_run is deprecated in the sense that now --nodirect_run is not an option anymore, i.e. it's always on and you thus don't need the command line option anymore.

It only makes it possible to run the binary run by bazel run and another Bazel command at the same time; two Bazel commands at the same time still won't work. IOW, if you run bazel run and another command at the same time, the second command will still have to wait until the binary is built and only then can it execute.

@ShreeM01 ShreeM01 added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 16, 2023
@ShreeM01
Copy link
Contributor

Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

@ShreeM01 ShreeM01 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2023
@cpsauer
Copy link
Contributor

cpsauer commented Feb 22, 2023

@kshyanashree, to me this seems interesting enough--certainly long term--to be worth keeping open!

@sgowroji sgowroji removed the stale Issues or PRs that are stale (no activity for 30 days) label Feb 22, 2023
@sgowroji sgowroji reopened this Feb 22, 2023
@sgowroji sgowroji added the not stale Issues or PRs that are inactive but not considered stale label Feb 22, 2023
@meisterT meisterT added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed P2 We'll consider working on this in future. (Assignee optional) labels Apr 5, 2023
@guw
Copy link
Contributor

guw commented Mar 19, 2024

Does it make sense to create a new issue for allowing multiple bazel query operations in parallel? Would that be easier to implement?

@lberki
Copy link
Contributor

lberki commented Mar 19, 2024

Unfortunately, no. bazel query is somewhat simpler since it doesn't need the build machinery, but the first few hurdles (BlazeModule life cycle and multiple Skyframe requests) are common between the two. So I think it's best to keep it as a single issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not stale Issues or PRs that are inactive but not considered stale P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Performance Issues for Performance teams type: feature request
Projects
None yet
Development

No branches or pull requests