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. Closes bazelbuild#13555. PiperOrigin-RevId: 378800212
- Loading branch information
1 parent
96f978b
commit 104025e
Showing
19 changed files
with
346 additions
and
84 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
package com.google.devtools.build.lib.actions; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.devtools.build.lib.events.ExtendedEventHandler.ProgressLike; | ||
|
||
/** Notifies that an in-flight action is checking the cache. */ | ||
@AutoValue | ||
public abstract class CachingActionEvent implements ProgressLike { | ||
|
||
public static CachingActionEvent create(ActionExecutionMetadata action, String strategy) { | ||
return new AutoValue_CachingActionEvent( | ||
action, checkNotNull(strategy, "Strategy names are not optional")); | ||
} | ||
|
||
/** Gets the metadata associated with the action. */ | ||
public abstract ActionExecutionMetadata action(); | ||
|
||
/** Gets the name of the strategy on which the action is caching. */ | ||
public abstract String 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
35 changes: 35 additions & 0 deletions
35
src/main/java/com/google/devtools/build/lib/exec/SpawnCheckingCacheEvent.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,35 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
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; | ||
|
||
/** Notifies that {@link SpawnRunner} is looking for a cache hit. */ | ||
@AutoValue | ||
public abstract class SpawnCheckingCacheEvent implements ProgressStatus { | ||
public static SpawnCheckingCacheEvent create(String name) { | ||
return new AutoValue_SpawnCheckingCacheEvent(name); | ||
} | ||
|
||
public abstract String name(); | ||
|
||
@Override | ||
public void postTo(ExtendedEventHandler eventHandler, ActionExecutionMetadata action) { | ||
eventHandler.post(CachingActionEvent.create(action, name())); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/com/google/devtools/build/lib/exec/SpawnExecutingEvent.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,42 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
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; | ||
|
||
/** | ||
* Notifies that {@link SpawnRunner} failed to find a cache hit and acquired the resources to | ||
* execute. 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 SpawnExecutingEvent implements ProgressStatus { | ||
public static SpawnExecutingEvent create(String name) { | ||
return new AutoValue_SpawnExecutingEvent(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
37 changes: 37 additions & 0 deletions
37
src/main/java/com/google/devtools/build/lib/exec/SpawnSchedulingEvent.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,37 @@ | ||
// Copyright 2021 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
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; | ||
|
||
/** | ||
* Notifies that {@link SpawnRunner} is waiting for local or remote resources to become available. | ||
*/ | ||
@AutoValue | ||
public abstract class SpawnSchedulingEvent implements ProgressStatus { | ||
public static SpawnSchedulingEvent create(String name) { | ||
return new AutoValue_SpawnSchedulingEvent(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
Oops, something went wrong.