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

Support --experimental_java_classpath=bazel #16906

Closed
cushon opened this issue Dec 2, 2022 · 1 comment
Closed

Support --experimental_java_classpath=bazel #16906

cushon opened this issue Dec 2, 2022 · 1 comment
Labels
team-Rules-Java Issues for Java rules type: bug

Comments

@cushon
Copy link
Contributor

cushon commented Dec 2, 2022

See #16426 (comment)

Originally the reduced classpath reduction happened during action execution, so changes in inputs would cause invalidation even if those inputs were pruned off the reduced classpath. But the classpath reduction now happens in Bazel, so in the example if libZ changes the action will still be a cache hit and won't be reexecuted:

https://cs.github.com/bazelbuild/bazel/blob/60ded2b53d4d9180c213e9e44a8c640368e60822/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java#L244

That optimization was implemented for Blaze, but parts of it are not wired up in Bazel, and attempting to enable it results in an NPE.

With Bazel built at 0dcfe21:

$ bazel build --experimental_java_classpath=bazel //src:bazel
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ActionLookupData{actionLookupKey=ConfiguredTargetKey{label=//src/main/java/com/google/devtools/build/lib/analysis/starlark/annotations/processor:annotation_preprocessor_lib, config=BuildConfigurationKey[a8f24905613097a24a99584d488eea2b48312ca68542cff50751864e342cea1f]}, actionIndex=0}' (requested by nodes 'ArtifactNestedSetKey{rawChildren=[File:[[<execution_root>]bazel-out/k8-opt-exec-EDC14992/bin]src/main/java/com/google/devtools/build/lib/analysis/starlark/annotations/processor/libannotation_preprocessor_lib.jar, File:[[<execution_root>]bazel-out/k8-opt-exec-EDC14992/bin]src/main/java/com/google/devtools/build/lib/analysis/starlark/annotations/libannotations_internal.jar]}')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:642)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot invoke "com.google.devtools.build.lib.rules.java.JavaCompileActionContext.getDependencies(com.google.devtools.build.lib.actions.Artifact, com.google.devtools.build.lib.actions.ActionExecutionContext)" because "context" is null
        at com.google.devtools.build.lib.rules.java.JavaCompileAction.getReducedClasspath(JavaCompileAction.java:259)
        at com.google.devtools.build.lib.rules.java.JavaCompileAction.execute(JavaCompileAction.java:408)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.executeAction(SkyframeActionExecutor.java:1045)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:966)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:160)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:93)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:497)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:826)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:323)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:161)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:571)
        ... 4 more

This bug tracks making --experimental_java_classpath=bazel work, to improve performance of incremental Java builds.

@cushon
Copy link
Contributor Author

cushon commented Dec 5, 2022

This is a duplicate of #16635

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

No branches or pull requests

2 participants