Mark workunits blocked, and skip rendering completed workunits (cherrypick of #12369) #12376
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Our "graph" of execution is a DAG, while the workunits (used to visualize and record traces) form a tree. Because they form a tree, workunits do not always report that they are blocked on work that they didn't start, but which some other node started (common when lots of @rules are waiting on another single @rule which only one of them started).
To fix this, we make the
blocked
property of a workunit an atomic mutable, and skip rendering the parents of blocked leaves. We use theblocked
flag both forTasks
(which wait directly for memoized Nodes, and so frequently block in this way), and inBoundedCommandRunner
, which temporarily blocks the workunit while we're acquiring the semaphore. Additionally, we skip rendering or walking throughCompleted
workunits, which can happen in the case of speculation if a parent workunit completes before a child.In order to toggle the
blocked
property on workunits, we expose the currentRunningWorkunit
in two new places: theCommandRunner
andWrappedNode
. In both cases, this is to allow the generic code to consume the workunit created by their callers and mark it blocked (forTask
andBoundedCommandRunner
).Fixes #12349.
[ci skip-build-wheels]