forked from bazelbuild/bazel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remote: Report checking cache status before the action is scheduled t…
…o run remotely. Add a Caching state to ActionState. This state indicates the action is checking the cache and should be happened before Scheduling state. Change ProgressStatus from enum to interface so that we can pass more data to the event handler (which is required to report upload/download details later). Fixes bazelbuild#13531.
- Loading branch information
Showing
19 changed files
with
270 additions
and
83 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/com/google/devtools/build/lib/actions/CachingActionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.google.devtools.build.lib.actions; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import com.google.devtools.build.lib.events.ExtendedEventHandler.ProgressLike; | ||
|
||
/** | ||
* Notifies that an in-flight action is checking the cache. | ||
*/ | ||
public class CachingActionEvent implements ProgressLike { | ||
|
||
private final ActionExecutionMetadata action; | ||
private final String strategy; | ||
|
||
/** | ||
* Constructs a new event. | ||
*/ | ||
public CachingActionEvent(ActionExecutionMetadata action, String strategy) { | ||
this.action = action; | ||
this.strategy = checkNotNull(strategy, "Strategy names are not optional"); | ||
} | ||
|
||
/** | ||
* Gets the metadata associated with the action. | ||
*/ | ||
public ActionExecutionMetadata getActionMetadata() { | ||
return action; | ||
} | ||
|
||
/** | ||
* Gets the name of the strategy on which the action is caching. | ||
*/ | ||
public String getStrategy() { | ||
return strategy; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/com/google/devtools/build/lib/exec/SpawnCheckingCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.google.devtools.build.lib.exec; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.devtools.build.lib.actions.ActionExecutionMetadata; | ||
import com.google.devtools.build.lib.actions.CachingActionEvent; | ||
import com.google.devtools.build.lib.events.ExtendedEventHandler; | ||
import com.google.devtools.build.lib.exec.SpawnRunner.ProgressStatus; | ||
|
||
/** The {@link SpawnRunner} is looking for a cache hit. */ | ||
@AutoValue | ||
public abstract class SpawnCheckingCache implements ProgressStatus { | ||
public static SpawnCheckingCache create(String name) { | ||
return new AutoValue_SpawnCheckingCache(name); | ||
} | ||
|
||
public abstract String name(); | ||
|
||
@Override | ||
public void postTo(ExtendedEventHandler eventHandler, ActionExecutionMetadata action) { | ||
eventHandler.post(new CachingActionEvent(action, name())); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/google/devtools/build/lib/exec/SpawnExecuting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.google.devtools.build.lib.exec; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.devtools.build.lib.actions.ActionExecutionMetadata; | ||
import com.google.devtools.build.lib.actions.RunningActionEvent; | ||
import com.google.devtools.build.lib.events.ExtendedEventHandler; | ||
import com.google.devtools.build.lib.exec.SpawnRunner.ProgressStatus; | ||
|
||
/** | ||
* Resources are acquired, and there was probably no cache hit. This MUST be posted before | ||
* attempting to execute the subprocess. | ||
* | ||
* <p>Caching {@link SpawnRunner} implementations should only post this after a failed cache | ||
* lookup, but may post this if cache lookup and execution happen within the same step, e.g. as | ||
* part of a single RPC call with no mechanism to report cache misses. | ||
*/ | ||
@AutoValue | ||
public abstract class SpawnExecuting implements ProgressStatus { | ||
public static SpawnExecuting create(String name) { | ||
return new AutoValue_SpawnExecuting(name); | ||
} | ||
|
||
public abstract String name(); | ||
|
||
@Override | ||
public void postTo(ExtendedEventHandler eventHandler, ActionExecutionMetadata action) { | ||
eventHandler.post(new RunningActionEvent(action, name())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/google/devtools/build/lib/exec/SpawnScheduling.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.google.devtools.build.lib.exec; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.devtools.build.lib.actions.ActionExecutionMetadata; | ||
import com.google.devtools.build.lib.actions.SchedulingActionEvent; | ||
import com.google.devtools.build.lib.events.ExtendedEventHandler; | ||
import com.google.devtools.build.lib.exec.SpawnRunner.ProgressStatus; | ||
|
||
/** | ||
* Spawn is waiting for local or remote resources to become available. | ||
*/ | ||
@AutoValue | ||
public abstract class SpawnScheduling implements ProgressStatus { | ||
public static SpawnScheduling create(String name) { | ||
return new AutoValue_SpawnScheduling(name); | ||
} | ||
|
||
public abstract String name(); | ||
|
||
@Override | ||
public void postTo(ExtendedEventHandler eventHandler, ActionExecutionMetadata action) { | ||
eventHandler.post(new SchedulingActionEvent(action, name())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.