Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Skymeld] Perform ALV collection in the same FJP that runs BuildDrive…
…rFunction. Prior to this CL, we created a separate FJP ("find-action-lookup-values-in-build") and use `invoke(ForkJoinTask)` to start a new traversal. This would cause a StackOverflowError where the stack trace didn't make sense: ``` at com.google.devtools.build.lib.skyframe.SkyframeExecutor$TransitiveActionLookupKeysCollector.collect(SkyframeExecutor.java:3910) at com.google.devtools.build.lib.skyframe.SkyframeExecutor.collectTransitiveActionLookupValuesOfKey(SkyframeExecutor.java:3476) at com.google.devtools.build.lib.skyframe.SkyframeExecutor$1.collect(SkyframeExecutor.java:736) at com.google.devtools.build.lib.skyframe.BuildDriverFunction.checkActionConflicts(BuildDriverFunction.java:566) at com.google.devtools.build.lib.skyframe.BuildDriverFunction.compute(BuildDriverFunction.java:188) at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:506) at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:399) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool.awaitJoin(ForkJoinPool.java:1708) at java.base/java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:397) at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:721) at java.base/java.util.concurrent.ForkJoinPool.invoke(ForkJoinPool.java:2423) at com.google.devtools.build.lib.skyframe.SkyframeExecutor$TransitiveActionLookupKeysCollector.collect(SkyframeExecutor.java:3910) at com.google.devtools.build.lib.skyframe.SkyframeExecutor.collectTransitiveActionLookupValuesOfKey(SkyframeExecutor.java:3476) at com.google.devtools.build.lib.skyframe.SkyframeExecutor$1.collect(SkyframeExecutor.java:736) at com.google.devtools.build.lib.skyframe.BuildDriverFunction.checkActionConflicts(BuildDriverFunction.java:566) at com.google.devtools.build.lib.skyframe.BuildDriverFunction.compute(BuildDriverFunction.java:188) at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:506) at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:399) at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1426) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool.awaitJoin(ForkJoinPool.java:1708) at java.base/java.util.concurrent.ForkJoinTask.doJoin(ForkJoinTask.java:397) at java.base/java.util.concurrent.ForkJoinTask.join(ForkJoinTask.java:721) at java.base/java.util.concurrent.ForkJoinPool.invoke(ForkJoinPool.java:2423) ``` There's no recursion expected that would cause this stack trace. Turns out, this odd behavior was the result of using `invoke(ForkJoinTask)` in the wrong context. It's only supposed to be used from non fork/join clients [1]. The internal implementation of FJP also just checks if the current thread is a FJP, but not which pool, so it's possible that this caused this undefined behavior. This CL changed that by running the traversal directly in the same CPU-heavy thread pool that runs the BuildDriverFunction, instead of spinning up an extra FJP for that. This makes sense also from a performance perspective because this traversal is CPU-bound. [1] https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ForkJoinPool.html PiperOrigin-RevId: 540546910 Change-Id: Ia1bc573ff350b0a803ec96d710e4d9696eb49421
- Loading branch information