Skip to content

Commit

Permalink
Pass ActionLookupData to TopDownActionCache.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 369647733
  • Loading branch information
justinhorvitz authored and copybara-github committed Apr 21, 2021
1 parent 6bf5a45 commit c51bcbd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ private SkyValue computeInternal(SkyKey skyKey, Environment env)
if (sketch == null) {
return null;
}
ActionExecutionValue actionExecutionValue = topDownActionCache.get(sketch);
ActionExecutionValue actionExecutionValue = topDownActionCache.get(sketch, actionLookupData);
if (actionExecutionValue != null) {
return actionExecutionValue.transformForSharedAction(action.getOutputs());
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/skyframe/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2568,6 +2568,7 @@ java_library(
srcs = ["TopDownActionCache.java"],
deps = [
":action_execution_value",
"//src/main/java/com/google/devtools/build/lib/actions:action_lookup_data",
"//src/main/java/com/google/devtools/build/lib/actionsketch:action_sketch",
"//third_party:jsr305",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;

import com.google.devtools.build.lib.actions.ActionLookupData;
import com.google.devtools.build.lib.actionsketch.ActionSketch;
import javax.annotation.Nullable;

Expand All @@ -24,9 +25,14 @@
*/
public interface TopDownActionCache {

/** Retrieves the cached value for the given action sketch, or null. */
/**
* Retrieves the cached value for the given action sketch, or null.
*
* <p>The sketch alone is expected to suffice as the cache key, but the {@link ActionLookupData}
* is also provided for context.
*/
@Nullable
ActionExecutionValue get(ActionSketch sketch);
ActionExecutionValue get(ActionSketch sketch, ActionLookupData action);

/** Puts the sketch into the top-down cache. May complete asynchronously. */
void put(ActionSketch sketch, ActionExecutionValue value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.common.cache.CacheBuilder;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.ActionKeyContext;
import com.google.devtools.build.lib.actions.ActionLookupData;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.actions.util.TestAction;
import com.google.devtools.build.lib.actionsketch.ActionSketch;
Expand All @@ -34,7 +35,7 @@

/** Tests for top-down, transitive action caching. */
@RunWith(JUnit4.class)
public class TopDownActionCacheTest extends TimestampBuilderTestCase {
public final class TopDownActionCacheTest extends TimestampBuilderTestCase {

@Override
protected TopDownActionCache initTopDownActionCache() {
Expand Down Expand Up @@ -177,7 +178,7 @@ private static class InMemoryTopDownActionCache implements TopDownActionCache {

@Nullable
@Override
public ActionExecutionValue get(ActionSketch sketch) {
public ActionExecutionValue get(ActionSketch sketch, ActionLookupData action) {
return cache.getIfPresent(sketch);
}

Expand All @@ -187,11 +188,10 @@ public void put(ActionSketch sketch, ActionExecutionValue value) {
}
}

private static class MutableActionKeyAction extends TestAction {

private static final class MutableActionKeyAction extends TestAction {
private final ActionKeyButton button;

public MutableActionKeyAction(
MutableActionKeyAction(
ActionKeyButton button, NestedSet<Artifact> inputs, ImmutableSet<Artifact> outputs) {
super(button, inputs, outputs);
this.button = button;
Expand All @@ -207,10 +207,10 @@ protected void computeKey(
}
}

private static class ActionKeyButton extends Button {
private static final class ActionKeyButton extends Button {
private final String key;

public ActionKeyButton(String key) {
ActionKeyButton(String key) {
this.key = key;
}
}
Expand Down

0 comments on commit c51bcbd

Please sign in to comment.