-
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 workers in CompatDexBuilder #14623
The head ref may contain hidden characters: "Support-multiplex\u2013workers-in-CompatDexBuilder"
Support workers in CompatDexBuilder #14623
Conversation
c1f902d
to
446f8bf
Compare
This looks good from a worker perspective. At a quick glance, CompatDexBuilder is thread-safe, which is good. It looks like it never truly supported workers, though, so maybe release the worker support first to weed out bugs in that before adding the complexity of multiplex workers? |
I can make that change if you think that's the safest path forward. We've been using a version of this internally for quite some time and have seen no issues so far (both worker and multiplex worker impls). |
f5def1f
to
8b42308
Compare
Reverted the multiplex changes out of this PR and will follow up in a second PR with those additional changes. |
How does the CompatDexBuilder normally output warnings and errors for the user to see? |
|
We can provide out own implementation of I see two options:
|
9cb6a71
to
dbc6116
Compare
4080687
to
89f8dc6
Compare
Pulled some benchmarks for this worker changes (includes multiplex). We saw a 29% improvement in clean build times and a 14% improvement in incremental build times where the ABI was invalidated. |
fc45e04
to
ebde27c
Compare
@larsrc-google are there next steps here for getting in? |
return 1; | ||
} finally { | ||
// Write the captured buffer to the work response | ||
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 a separate lock object, it would be enough to lock on buf
.
@@ -77,11 +87,62 @@ public void finished(DiagnosticsHandler handler) { | |||
public static void main(String[] args) | |||
throws IOException, InterruptedException, ExecutionException, OptionsParsingException { | |||
CompatDexBuilder compatDexBuilder = new CompatDexBuilder(); | |||
compatDexBuilder.processRequest(args); | |||
if (args.length == 1 && args[0].equals("--persistent_worker")) { |
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.
It would be more future-proof if you test for args.length >= 1
.
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.
Updating using ImmutableSet.copyOf(args).contains("--persistent_worker")
to better align with the example worker
bazel/src/test/java/com/google/devtools/build/lib/worker/ExampleWorkerMultiplexer.java
Line 71 in 6d1b972
if (ImmutableSet.copyOf(args).contains("--persistent_worker")) { |
Happy to revert back to args.length >= 1 && args[0].equals("--persistent_worker")
if you think the extra copy isn't necessary though.
} finally { | ||
// Write the captured buffer to the work response | ||
synchronized (buf) { | ||
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 should apply a charset (UTF_8) to the toString() method.
@@ -41,6 +41,8 @@ java_library( | |||
}), | |||
visibility = ["//src/test/java/com/google/devtools/build/android/r8:__pkg__"], | |||
deps = [ | |||
"//src/main/java/com/google/devtools/build/lib/worker:work_request_handlers", | |||
"//src/main/java/com/google/devtools/build/lib/worker:worker", |
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.
Do you actually need to depend on :worker
? That should only be for internal (server-side) use.
ebde27c
to
ba874ea
Compare
ba874ea
to
e4c794e
Compare
e4c794e
to
ba874ea
Compare
Hi Ben, Thanks for this PR. We're in the process of importing it upstream now. We've discovered that this PR actually requires a manual update and release for the remote Android tools repo, so we'll need a little longer before we can close this out. |
Prerequisite to merge #14623 RELNOTES: Advance android_tools_pkg version to 0.24.0. PiperOrigin-RevId: 442930486
This also fixes the
--use_workers_with_dexbuilder
flag which would pass the worker execution requirements toCompatDexBuilder
without it knowing how to handle the work requests.Using a worker here should help with some OOMs issues, and drastically improves build performance. We saw a 29% improvement in clean build times and a 14% improvement in incremental build times where the ABI was invalidated.