Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Commit

Permalink
Exclude formc output from ijars
Browse files Browse the repository at this point in the history
The assumption here is that formc does not generate any new APIs that
would be referenced by downstream Java/Kotlin code. Thus we do not
need to include formc output in ijars.

The benefit of this is that we can produce 'full_ijar' without needing
to wait for the formc action to complete. By producing 'full_ijar'
earlier, we can begin downstream module compilations sooner, thereby
reducing the critical path slightly.

Also, note that formc takes as input the "full" Java jar. So, by
moving formc off the critical path, we no longer need to wait for
the full Javac action either; instead we only need the hjar, which is
produced very quickly by Turbine.

Test scenario: add a new public Java method in android-common, then
build //tools/adt/idea/android/...

Results:

  Before this change:
    trial #1: 338 seconds
    trial #2: 323 seconds
    trial #3: 333 seconds

  After this change:
    trial #1: 316 seconds
    trial #2: 308 seconds
    trial #3: 305 seconds

The improvement is relatively small in practice, it seems. But I did
observe that compilation of downstream modules now starts in parallel
with the "*.pjava.jar" and "*.java.jar" actions, which is good.

Bug: relates to b/200690965
Test: Bazel build
Change-Id: I3051c2328bebacf2f1c3de9af9950c4577388e0b
  • Loading branch information
gharrma authored and Tom Renn committed Feb 1, 2022
1 parent 2146667 commit 999bdf1
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions bazel/bazel.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ def _iml_module_jar_impl(
sourcepath = sourcepath,
# TODO(b/216385876) After updating to Bazel 5.0, use enable_compile_jar_action = use_ijar,
)
if use_ijar:
# Note: we exclude formc output from ijars, since formc does not generate APIs used downstream.
ijars += [java_output.ijar for java_output in java_provider.outputs.jars]

# Forms
if form_srcs:
Expand Down Expand Up @@ -170,15 +173,6 @@ def _iml_module_jar_impl(
execution_requirements = {"supports-workers": "1"},
)

if use_ijar:
ijars += [java_common.run_ijar(
actions = ctx.actions,
jar = java_jar,
java_toolchain = find_java_toolchain(ctx, ctx.attr._java_toolchain),
)]
elif use_ijar:
ijars += [java_output.ijar for java_output in java_provider.outputs.jars]

jars += [java_jar]

if form_srcs and not java_srcs:
Expand Down

0 comments on commit 999bdf1

Please sign in to comment.