-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Support multiplex workers in ResourceProcessorBusyBox #14428
Support multiplex workers in ResourceProcessorBusyBox #14428
Conversation
executionInfo.putAll(ExecutionRequirements.WORKER_MODE_ENABLED); | ||
|
||
if (dataContext.isPersistentMultiplexBusyboxTools()) { | ||
executionInfo.putAll(ExecutionRequirements.WORKER_MULTIPLEX_MODE_ENABLED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this flag would override --noexperimental_worker_multiplex
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing --noexperimental_worker_multiplex
would disable multiplex workers entirely while isPersistentMultiplexBusyboxTools
just instructs BusyBoxActionBuilder
to register it's actions with with supports-multiplex-worker
specified as part of it's execution info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
D'uh. You're right.
String s = buf.toString().trim(); | ||
buf.reset(); | ||
if (!s.isEmpty()) { | ||
pw.print(s); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sends everything sent to stdout/err into the output
field of the response. However, since System.out/err are global, output from all threads gets interleaved here. These should be sent to realStdErr
, any actual error messages from processing this request should go to pw
. See discussion in #14201
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merging #14201 first would be the preferred solution here so that we aren't having to duplicate any of the system stream remapping logic between workers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed the changes to swap System.err
in for System.out
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also worth noting that swapping System.err
in for System.out
technically changes where the outputs are delivered for this rule, where the prior implementation would write the captured outputs directly to the work response output vs. the new implementation dumps them to System.err
and only writes the contents of the PrintWriter
provided by WorkRequestHandler
to the work response output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you need to be sure that that's the desired behaviour. Things the user should see should go into the work response output, things that should go into the log should go to System.out
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to roll back to the previous behavior to preserve the existing logs/error delivery that exists today.
cb97b32
to
1b64c9c
Compare
d4052d1
to
a463a50
Compare
String captured = buf.toString().trim(); | ||
buf.reset(); | ||
if (!captured.isEmpty()) { | ||
pw.print(captured); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This preserves the previous logging behavior seen here https://github.com/bazelbuild/bazel/pull/14428/files#diff-6bbb0aaf4cf2d425734021815617e2b6203223abe7dc76ca8030a90e9f043873L204
src/tools/android/java/com/google/devtools/build/android/ResourceProcessorBusyBox.java
Show resolved
Hide resolved
exitCode = 1; | ||
} finally { | ||
// Write the captured buffer to the work response | ||
String captured = buf.toString().trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a race condition here: buf
is shared among all threads, so if something gets written between this line and the next, it gets lost. Synchronizing on buf
should be OK, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated but synchronizing on a static object to avoid having to synchronize on function arguments.
127449d
to
23f76f1
Compare
7ff4278
to
32557fd
Compare
32557fd
to
db2cc0f
Compare
synchronized (LOCK) { | ||
String captured = buf.toString().trim(); | ||
buf.reset(); | ||
if (!captured.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if
is not really necessary. Printing nothing should not be an issue.
} finally { | ||
// Write the captured buffer to the work response. We synchronize to avoid race conditions | ||
// while reading from and calling reset on the shared ByteArrayOutputStream. | ||
synchronized (LOCK) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need an extra lock object. Locking on buf
would be sufficient and clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
db2cc0f
to
7ced7c5
Compare
7ced7c5
to
6f08b15
Compare
Any updates on this? |
Awesome, thanks for taking this one across the finish line @ted-xie! |
Adding support for multiplex workers inside of `ResourceProcessorBusyBox` and moving it's worker implementation over to the generic work request handler. These PRs need to land for this to work: - bazelbuild#14424 - bazelbuild#14425 - bazelbuild#14427 For those not on rolling releases, the other required PRs that have already merged are: - bazelbuild#14144 - bazelbuild#14145 - bazelbuild#14146 Closes bazelbuild#14428. PiperOrigin-RevId: 456561596 Change-Id: I098d5a323ac6558ad0f5f8190e29f45a7a37b4d4
Final step for PR #14428. RELNOTES: None PiperOrigin-RevId: 457734764 Change-Id: I2b14bf31c665a6b9803e21492c5d32502e25f0ea
Should have been included in #14428 but was not caught before submission. RELNOTES: Test for experimental multiplexed persistent resource processor. PiperOrigin-RevId: 457743677 Change-Id: Ifd746ec716d45aa3065f4b15ad715d52155008c6
Adding support for multiplex workers inside of
ResourceProcessorBusyBox
and moving it's worker implementation over to the generic work request handler.These PRs need to land for this to work:
For those not on rolling releases, the other required PRs that have already merged are: