Delete top-down action caching prototype PiperOrigin-RevId: 417499871
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index e596d5c..8b7d2ec 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD
@@ -325,7 +325,6 @@ "//src/main/java/com/google/devtools/build/lib/skyframe:sky_value_dirtiness_checker", "//src/main/java/com/google/devtools/build/lib/skyframe:skyframe_cluster", "//src/main/java/com/google/devtools/build/lib/skyframe:target_pattern_phase_value", - "//src/main/java/com/google/devtools/build/lib/skyframe:top_down_action_cache", "//src/main/java/com/google/devtools/build/lib/skyframe:workspace_info", "//src/main/java/com/google/devtools/build/lib/unix", "//src/main/java/com/google/devtools/build/lib/util",
diff --git a/src/main/java/com/google/devtools/build/lib/actionsketch/ActionSketch.java b/src/main/java/com/google/devtools/build/lib/actionsketch/ActionSketch.java index 8e6cf49..4831aeb 100644 --- a/src/main/java/com/google/devtools/build/lib/actionsketch/ActionSketch.java +++ b/src/main/java/com/google/devtools/build/lib/actionsketch/ActionSketch.java
@@ -15,7 +15,6 @@ package com.google.devtools.build.lib.actionsketch; import com.google.auto.value.AutoValue; -import com.google.devtools.build.skyframe.SkyValue; import com.google.protobuf.ByteString; import java.math.BigInteger; import java.nio.ByteBuffer; @@ -24,25 +23,21 @@ /** * An {@link ActionSketch} encodes a transitive hash of an action sufficient to associate with it * the result of executing the action. Therefore, this must include a hash on some upper bound of - * all transitively consumed input files, as well as a transitive hash of all action keys. + * all transitively consumed input files. */ @AutoValue -public abstract class ActionSketch implements SkyValue { +public abstract class ActionSketch { public static final int BIGINTEGER_ENCODED_LENGTH = /*length=*/ 1 + /*payload=*/ 39; public static final int MAX_BYTES = /*hashes=*/ 2 * BIGINTEGER_ENCODED_LENGTH; private static final ActionSketch NULL_SKETCH = ActionSketch.builder() .setTransitiveSourceHash(null) - .setTransitiveActionLookupHash(null) .autoBuild(); @Nullable public abstract HashAndVersion transitiveSourceHash(); - @Nullable - public abstract BigInteger transitiveActionLookupHash(); - public static Builder builder() { return new AutoValue_ActionSketch.Builder(); } @@ -54,20 +49,13 @@ public abstract static class Builder { public abstract Builder setTransitiveSourceHash(HashAndVersion transitiveSourceHash); - public abstract Builder setTransitiveActionLookupHash(BigInteger transitiveActionLookupHash); - @Nullable abstract HashAndVersion transitiveSourceHash(); - @Nullable - abstract BigInteger transitiveActionLookupHash(); - abstract ActionSketch autoBuild(); public final ActionSketch build() { - return transitiveSourceHash() == null && transitiveActionLookupHash() == null - ? NULL_SKETCH - : autoBuild(); + return transitiveSourceHash() == null ? NULL_SKETCH : autoBuild(); } } @@ -79,7 +67,6 @@ public final void writeTo(ByteBuffer buffer) { writeNextValue(transitiveSourceHash(), buffer); - writeNextValue(transitiveActionLookupHash(), buffer); } private static void writeNextValue(HashAndVersion value, ByteBuffer buffer) { @@ -91,36 +78,12 @@ } } - private static void writeNextValue(BigInteger value, ByteBuffer buffer) { - if (value == null) { - buffer.put((byte) -1); - } else { - byte[] bytes = value.toByteArray(); - buffer.put((byte) bytes.length).put(bytes); - } - } - public static ActionSketch fromBytes(ByteString inputBytes) { return fromByteBuffer(inputBytes.asReadOnlyByteBuffer()); } public static ActionSketch fromByteBuffer(ByteBuffer buffer) { - Builder builder = - builder() - .setTransitiveSourceHash(readNextHashAndVersion(buffer)) - .setTransitiveActionLookupHash(readNextBigInteger(buffer)); - return builder.build(); - } - - @Nullable - private static BigInteger readNextBigInteger(ByteBuffer buffer) { - byte length = buffer.get(); - if (length < 0) { - return null; - } - byte[] val = new byte[length]; - buffer.get(val); - return new BigInteger(1, val); + return builder().setTransitiveSourceHash(readNextHashAndVersion(buffer)).build(); } @Nullable
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java index a1927de..0875b92 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -300,11 +300,7 @@ try (SilentCloseable c = Profiler.instance().profile("prepareSkyframeActionExecutorForExecution")) { skyframeExecutor.prepareSkyframeActionExecutorForExecution( - env.getReporter(), - executor, - request, - skyframeBuilder.getActionCacheChecker(), - skyframeBuilder.getTopDownActionCache()); + env.getReporter(), executor, request, skyframeBuilder.getActionCacheChecker()); } // Note that executionProgressReceiver accesses builtTargets concurrently (after wrapping in a @@ -886,7 +882,6 @@ .setVerboseExplanations(options.verboseExplanations) .setStoreOutputMetadata(options.actionCacheStoreOutputMetadata) .build()), - env.getTopDownActionCache(), request.getPackageOptions().checkOutputFiles // Do not skip invalidation in case the output tree is empty -- this can happen // after it's cleaned or corrupted.
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java index fb135ca..0baaa5d 100644 --- a/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/buildtool/SkyframeBuilder.java
@@ -53,7 +53,6 @@ import com.google.devtools.build.lib.skyframe.ConfiguredTargetKey; import com.google.devtools.build.lib.skyframe.DetailedException; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; -import com.google.devtools.build.lib.skyframe.TopDownActionCache; import com.google.devtools.build.lib.util.AbruptExitException; import com.google.devtools.build.lib.util.DetailedExitCode; import com.google.devtools.build.lib.util.DetailedExitCode.DetailedExitCodeComparator; @@ -87,7 +86,6 @@ private final MetadataProvider fileCache; private final ActionInputPrefetcher actionInputPrefetcher; private final ActionCacheChecker actionCacheChecker; - private final TopDownActionCache topDownActionCache; private final BugReporter bugReporter; @VisibleForTesting @@ -95,7 +93,6 @@ SkyframeExecutor skyframeExecutor, ResourceManager resourceManager, ActionCacheChecker actionCacheChecker, - TopDownActionCache topDownActionCache, ModifiedFileSet modifiedOutputFiles, MetadataProvider fileCache, ActionInputPrefetcher actionInputPrefetcher, @@ -103,7 +100,6 @@ this.resourceManager = resourceManager; this.skyframeExecutor = skyframeExecutor; this.actionCacheChecker = actionCacheChecker; - this.topDownActionCache = topDownActionCache; this.modifiedOutputFiles = modifiedOutputFiles; this.fileCache = fileCache; this.actionInputPrefetcher = actionInputPrefetcher; @@ -182,7 +178,6 @@ exclusiveTests, options, actionCacheChecker, - topDownActionCache, executionProgressReceiver, topLevelArtifactContext); // progressReceiver is finished, so unsynchronized access to builtTargets is now safe. @@ -212,7 +207,6 @@ exclusiveTest, options, actionCacheChecker, - topDownActionCache, topLevelArtifactContext); detailedExitCode = processResult( @@ -399,10 +393,6 @@ return actionCacheChecker; } - TopDownActionCache getTopDownActionCache() { - return topDownActionCache; - } - MetadataProvider getFileCache() { return fileCache; }
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java index c53ce5d..19f1d25 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeModule.java
@@ -35,7 +35,6 @@ import com.google.devtools.build.lib.packages.PackageOverheadEstimator; import com.google.devtools.build.lib.packages.PackageValidator; import com.google.devtools.build.lib.skyframe.PrecomputedValue; -import com.google.devtools.build.lib.skyframe.TopDownActionCache; import com.google.devtools.build.lib.util.AbruptExitException; import com.google.devtools.build.lib.util.DetailedExitCode; import com.google.devtools.build.lib.util.io.OutErr; @@ -99,17 +98,6 @@ return null; } - /** - * Returns the {@link TopDownActionCache} used by Bazel. It is an error if more than one module - * returns a top-down action cache. If all modules return null, there will be no top-down caching. - * - * <p>This method will be called at the beginning of Bazel startup (in-between {@link #globalInit} - * and {@link #blazeStartup}). - */ - public TopDownActionCache getTopDownActionCache() { - return null; - } - /** Tuple returned by {@link #getFileSystem}. */ @AutoValue public abstract static class ModuleFileSystem {
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java index 7cf7386..80020ca 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
@@ -42,7 +42,6 @@ import com.google.devtools.build.lib.server.FailureDetails.FailureDetail; import com.google.devtools.build.lib.skyframe.SkyframeBuildView; import com.google.devtools.build.lib.skyframe.SkyframeExecutor; -import com.google.devtools.build.lib.skyframe.TopDownActionCache; import com.google.devtools.build.lib.skyframe.WorkspaceInfoFromDiff; import com.google.devtools.build.lib.util.AbruptExitException; import com.google.devtools.build.lib.util.DetailedExitCode; @@ -106,7 +105,6 @@ private final Consumer<String> shutdownReasonConsumer; private OutputService outputService; - private TopDownActionCache topDownActionCache; private String workspaceName; private boolean hasSyncedPackageLoading = false; @Nullable private WorkspaceInfoFromDiff workspaceInfoFromDiff; @@ -601,11 +599,6 @@ return workspaceInfoFromDiff; } - /** Returns the top-down action cache to use, or null. */ - public TopDownActionCache getTopDownActionCache() { - return topDownActionCache; - } - public ResourceManager getLocalResourceManager() { return ResourceManager.instance(); } @@ -732,8 +725,6 @@ outputService = null; BlazeModule outputModule = null; - topDownActionCache = null; - BlazeModule topDownCachingModule = null; if (command.builds()) { for (BlazeModule module : runtime.getBlazeModules()) { OutputService moduleService = module.getOutputService(); @@ -747,18 +738,6 @@ outputService = moduleService; outputModule = module; } - - TopDownActionCache moduleCache = module.getTopDownActionCache(); - if (moduleCache != null) { - if (topDownActionCache != null) { - throw new IllegalStateException( - String.format( - "More than one module (%s and %s) returns a top down action cache", - module.getClass(), topDownCachingModule.getClass())); - } - topDownActionCache = moduleCache; - topDownCachingModule = module; - } } }
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java index 60d1d48..597601c 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ActionExecutionFunction.java
@@ -58,7 +58,6 @@ import com.google.devtools.build.lib.actions.MissingInputFileException; import com.google.devtools.build.lib.actions.PackageRootResolver; import com.google.devtools.build.lib.actions.SpawnMetrics; -import com.google.devtools.build.lib.actionsketch.ActionSketch; import com.google.devtools.build.lib.analysis.BlazeDirectories; import com.google.devtools.build.lib.bugreport.BugReport; import com.google.devtools.build.lib.bugreport.BugReporter; @@ -208,19 +207,6 @@ clientEnv = ImmutableMap.of(); } - ActionSketch sketch = null; - TopDownActionCache topDownActionCache = skyframeActionExecutor.getTopDownActionCache(); - if (topDownActionCache != null) { - sketch = (ActionSketch) env.getValue(ActionSketchFunction.key(actionLookupData)); - if (sketch == null) { - return null; - } - ActionExecutionValue actionExecutionValue = topDownActionCache.get(sketch, actionLookupData); - if (actionExecutionValue != null) { - return actionExecutionValue.transformForSharedAction(action); - } - } - // For restarts of this ActionExecutionFunction we use a ContinuationState variable, below, to // avoid redoing work. // @@ -382,9 +368,6 @@ // Remove action from state map in case it's there (won't be unless it discovers inputs). stateMap.remove(action); - if (sketch != null && actionLookupData.valueIsShareable()) { - topDownActionCache.put(sketch, result); - } return result; }
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ActionSketchFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ActionSketchFunction.java deleted file mode 100644 index 8ed0d68..0000000 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ActionSketchFunction.java +++ /dev/null
@@ -1,146 +0,0 @@ -// Copyright 2019 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.skyframe; - -import com.github.benmanes.caffeine.cache.Caffeine; -import com.github.benmanes.caffeine.cache.LoadingCache; -import com.google.devtools.build.lib.actions.Action; -import com.google.devtools.build.lib.actions.ActionKeyContext; -import com.google.devtools.build.lib.actions.ActionLookupData; -import com.google.devtools.build.lib.actions.ActionLookupValue; -import com.google.devtools.build.lib.actions.Artifact; -import com.google.devtools.build.lib.actions.Artifact.DerivedArtifact; -import com.google.devtools.build.lib.actions.FileArtifactValue; -import com.google.devtools.build.lib.actionsketch.ActionSketch; -import com.google.devtools.build.lib.actionsketch.HashAndVersion; -import com.google.devtools.build.lib.actionsketch.Sketches; -import com.google.devtools.build.lib.concurrent.BlazeInterners; -import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec; -import com.google.devtools.build.lib.util.BigIntegerFingerprintUtils; -import com.google.devtools.build.skyframe.AbstractSkyKey; -import com.google.devtools.build.skyframe.SkyFunction; -import com.google.devtools.build.skyframe.SkyFunctionName; -import com.google.devtools.build.skyframe.SkyKey; -import com.google.devtools.build.skyframe.SkyValue; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import javax.annotation.Nullable; - -/** - * {@link ActionSketchFunction} computes an {@link ActionSketch} for the given Action. This is a - * transitive hash of the dependent action keys and source file content hashes. - */ -public final class ActionSketchFunction implements SkyFunction { - private final ActionKeyContext actionKeyContext; - - public ActionSketchFunction(ActionKeyContext actionKeyContext) { - this.actionKeyContext = actionKeyContext; - } - - public static SketchKey key(ActionLookupData key) { - return SketchKey.create(key); - } - - @AutoCodec.VisibleForSerialization - @AutoCodec - static class SketchKey extends AbstractSkyKey<ActionLookupData> { - private static final LoadingCache<ActionLookupData, SketchKey> keyCache = - Caffeine.newBuilder() - .weakKeys() - .initialCapacity(BlazeInterners.concurrencyLevel()) - .build(SketchKey::new); - - private SketchKey(ActionLookupData arg) { - super(arg); - } - - @AutoCodec.VisibleForSerialization - @AutoCodec.Instantiator - static SketchKey create(ActionLookupData arg) { - return keyCache.get(arg); - } - - @Override - public SkyFunctionName functionName() { - return SkyFunctions.ACTION_SKETCH; - } - } - - @Nullable - @Override - public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedException { - ActionLookupData actionLookupData = (ActionLookupData) skyKey.argument(); - ActionLookupValue actionLookupValue = - ArtifactFunction.getActionLookupValue(actionLookupData.getActionLookupKey(), env); - if (actionLookupValue == null) { - return null; - } - - Action action = actionLookupValue.getAction(actionLookupData.getActionIndex()); - List<Artifact> srcArtifacts = new ArrayList<>(); - List<SketchKey> depActions = new ArrayList<>(); - for (Artifact artifact : action.getInputs().toList()) { - if (artifact.isSourceArtifact()) { - srcArtifacts.add(artifact); - } else { - depActions.add(SketchKey.create(((DerivedArtifact) artifact).getGeneratingActionKey())); - } - } - - Map<SkyKey, SkyValue> srcArtifactValues = env.getValues(srcArtifacts); - Map<SkyKey, SkyValue> depSketchValues = env.getValues(depActions); - if (env.valuesMissing()) { - return null; - } - - BigInteger transitiveActionKeyHash = Sketches.computeActionKey(action, actionKeyContext); - BigInteger transitiveSourceHash = BigInteger.ZERO; - - // Incorporate the direct source values. - for (SkyValue val : srcArtifactValues.values()) { - FileArtifactValue fileArtifactValue = (FileArtifactValue) val; - byte[] sourceFingerprint = fileArtifactValue.getValueFingerprint(); - if (sourceFingerprint != null) { - transitiveSourceHash = - BigIntegerFingerprintUtils.compose( - transitiveSourceHash, new BigInteger(1, sourceFingerprint)); - } else { - transitiveSourceHash = null; - break; - } - } - - // Incorporate the transitive action key and source values. - for (SkyValue sketchVal : depSketchValues.values()) { - ActionSketch depSketch = (ActionSketch) sketchVal; - transitiveActionKeyHash = - BigIntegerFingerprintUtils.compose( - transitiveActionKeyHash, depSketch.transitiveActionLookupHash()); - HashAndVersion hashAndVersion = depSketch.transitiveSourceHash(); - if (hashAndVersion != null) { - transitiveSourceHash = - BigIntegerFingerprintUtils.composeNullable(transitiveSourceHash, hashAndVersion.hash()); - } else { - transitiveSourceHash = null; - } - } - - return ActionSketch.builder() - .setTransitiveActionLookupHash(transitiveActionKeyHash) - .setTransitiveSourceHash(HashAndVersion.createNoVersion(transitiveSourceHash)) - .build(); - } -}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD index 86ea462..dd2b6cf 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/BUILD +++ b/src/main/java/com/google/devtools/build/lib/skyframe/BUILD
@@ -94,7 +94,6 @@ ":action_lookup_conflict_finding_value", ":action_metadata_handler", ":action_rewind_strategy", - ":action_sketch_function", ":action_template_expansion_function", ":action_utils", ":actiongraph/v2/aquery_output_handler", @@ -200,7 +199,6 @@ ":tests_for_target_pattern_value", ":toolchain_context_key", ":toolchain_exception", - ":top_down_action_cache", ":transitive_base_traversal_function", ":transitive_target_key", ":transitive_target_value", @@ -227,7 +225,6 @@ "//src/main/java/com/google/devtools/build/lib/actions:fileset_output_symlink", "//src/main/java/com/google/devtools/build/lib/actions:package_roots", "//src/main/java/com/google/devtools/build/lib/actions:thread_state_receiver", - "//src/main/java/com/google/devtools/build/lib/actionsketch:action_sketch", "//src/main/java/com/google/devtools/build/lib/analysis:actions/parameter_file_write_action", "//src/main/java/com/google/devtools/build/lib/analysis:actions/substitution", "//src/main/java/com/google/devtools/build/lib/analysis:actions/template_expansion_action", @@ -517,28 +514,6 @@ ) java_library( - name = "action_sketch_function", - srcs = ["ActionSketchFunction.java"], - deps = [ - ":artifact_function", - ":sky_functions", - "//src/main/java/com/google/devtools/build/lib/actions", - "//src/main/java/com/google/devtools/build/lib/actions:action_lookup_data", - "//src/main/java/com/google/devtools/build/lib/actions:artifacts", - "//src/main/java/com/google/devtools/build/lib/actions:file_metadata", - "//src/main/java/com/google/devtools/build/lib/actionsketch:action_sketch", - "//src/main/java/com/google/devtools/build/lib/actionsketch:hash_and_version", - "//src/main/java/com/google/devtools/build/lib/concurrent", - "//src/main/java/com/google/devtools/build/lib/skyframe/serialization/autocodec", - "//src/main/java/com/google/devtools/build/lib/util", - "//src/main/java/com/google/devtools/build/skyframe", - "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", - "//third_party:caffeine", - "//third_party:jsr305", - ], -) - -java_library( name = "action_template_expansion_function", srcs = ["ActionTemplateExpansionFunction.java"], deps = [ @@ -2551,17 +2526,6 @@ ) java_library( - name = "top_down_action_cache", - 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", - ], -) - -java_library( name = "track_source_directories_flag", srcs = ["TrackSourceDirectoriesFlag.java"], )
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java index 3c90c17..a1edb6e 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeActionExecutor.java
@@ -154,7 +154,6 @@ private ExtendedEventHandler progressSuppressingEventHandler; private ActionLogBufferPathGenerator actionLogBufferPathGenerator; private ActionCacheChecker actionCacheChecker; - @Nullable private TopDownActionCache topDownActionCache; private final Profiler profiler = Profiler.instance(); // We keep track of actions already executed this build in order to avoid executing a shared @@ -257,7 +256,6 @@ Executor executor, OptionsProvider options, ActionCacheChecker actionCacheChecker, - TopDownActionCache topDownActionCache, OutputService outputService, boolean incrementalAnalysis) { this.reporter = Preconditions.checkNotNull(reporter); @@ -270,7 +268,6 @@ this.lostDiscoveredInputsMap = Maps.newConcurrentMap(); this.hadExecutionError = false; this.actionCacheChecker = Preconditions.checkNotNull(actionCacheChecker); - this.topDownActionCache = topDownActionCache; // Don't cache possibly stale data from the last build. this.options = options; // Cache some option values for performance, since we consult them on every action. @@ -356,7 +353,6 @@ this.completedAndResetActions = null; this.lostDiscoveredInputsMap = null; this.actionCacheChecker = null; - this.topDownActionCache = null; this.outputDirectoryHelper = null; } @@ -506,10 +502,6 @@ return emitProgressEvents ? reporter : progressSuppressingEventHandler; } - TopDownActionCache getTopDownActionCache() { - return topDownActionCache; - } - private ActionExecutionContext getContext( Environment env, Action action,
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java index 8638d96..dd0c55d 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -618,7 +618,6 @@ new ActionExecutionFunction(skyframeActionExecutor, directories, tsgm, bugReporter); map.put(SkyFunctions.ACTION_EXECUTION, actionExecutionFunction); this.actionExecutionFunction = actionExecutionFunction; - map.put(SkyFunctions.ACTION_SKETCH, new ActionSketchFunction(actionKeyContext)); map.put( SkyFunctions.RECURSIVE_FILESYSTEM_TRAVERSAL, new RecursiveFilesystemTraversalFunction()); map.put(SkyFunctions.FILESET_ENTRY, new FilesetEntryFunction(directories::getExecRoot)); @@ -1599,7 +1598,6 @@ Set<ConfiguredTarget> exclusiveTests, OptionsProvider options, ActionCacheChecker actionCacheChecker, - TopDownActionCache topDownActionCache, @Nullable EvaluationProgressReceiver executionProgressReceiver, TopLevelArtifactContext topLevelArtifactContext) throws InterruptedException, AbruptExitException { @@ -1609,8 +1607,7 @@ deleteActionsIfRemoteOptionsChanged(options); try (SilentCloseable c = Profiler.instance().profile("skyframeActionExecutor.prepareForExecution")) { - prepareSkyframeActionExecutorForExecution( - reporter, executor, options, actionCacheChecker, topDownActionCache); + prepareSkyframeActionExecutorForExecution(reporter, executor, options, actionCacheChecker); } resourceManager.resetResourceUsage(); @@ -1652,14 +1649,12 @@ Reporter reporter, Executor executor, OptionsProvider options, - ActionCacheChecker actionCacheChecker, - TopDownActionCache topDownActionCache) { + ActionCacheChecker actionCacheChecker) { skyframeActionExecutor.prepareForExecution( reporter, executor, options, actionCacheChecker, - topDownActionCache, outputService, isAnalysisIncremental()); } @@ -1672,7 +1667,6 @@ ConfiguredTarget exclusiveTest, OptionsProvider options, ActionCacheChecker actionCacheChecker, - TopDownActionCache topDownActionCache, TopLevelArtifactContext topLevelArtifactContext) throws InterruptedException { checkActive(); @@ -1680,8 +1674,7 @@ try (SilentCloseable c = Profiler.instance().profile("skyframeActionExecutor.prepareForExecution")) { - prepareSkyframeActionExecutorForExecution( - reporter, executor, options, actionCacheChecker, topDownActionCache); + prepareSkyframeActionExecutorForExecution(reporter, executor, options, actionCacheChecker); } resourceManager.resetResourceUsage(); @@ -1705,13 +1698,8 @@ @VisibleForTesting public void prepareBuildingForTestingOnly( - Reporter reporter, - Executor executor, - OptionsProvider options, - ActionCacheChecker checker, - TopDownActionCache topDownActionCache) { - prepareSkyframeActionExecutorForExecution( - reporter, executor, options, checker, topDownActionCache); + Reporter reporter, Executor executor, OptionsProvider options, ActionCacheChecker checker) { + prepareSkyframeActionExecutorForExecution(reporter, executor, options, checker); } private void deleteActionsIfRemoteOptionsChanged(OptionsProvider options)
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/TopDownActionCache.java b/src/main/java/com/google/devtools/build/lib/skyframe/TopDownActionCache.java deleted file mode 100644 index 60fd2a7..0000000 --- a/src/main/java/com/google/devtools/build/lib/skyframe/TopDownActionCache.java +++ /dev/null
@@ -1,39 +0,0 @@ -// Copyright 2019 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.skyframe; - -import com.google.devtools.build.lib.actions.ActionLookupData; -import com.google.devtools.build.lib.actionsketch.ActionSketch; -import javax.annotation.Nullable; - -/** - * A top-down action cache is a cache of {@link ActionSketch} to {@link ActionExecutionValue}. - * - * <p>Unlike {@link com.google.devtools.build.lib.actions.ActionCacheChecker}, a top-down cache can - * cull large subgraphs by computing the transitive cache key (known as the {@link ActionSketch}). - */ -public interface TopDownActionCache { - - /** - * 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, ActionLookupData action); - - /** Puts the sketch into the top-down cache. May complete asynchronously. */ - void put(ActionSketch sketch, ActionExecutionValue value); -}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodec.java b/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodec.java deleted file mode 100644 index ab70756..0000000 --- a/src/main/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodec.java +++ /dev/null
@@ -1,41 +0,0 @@ -// Copyright 2019 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.skyframe.serialization; - -import com.google.protobuf.CodedInputStream; -import com.google.protobuf.CodedOutputStream; -import java.io.IOException; -import java.math.BigInteger; - -/** Codec for {@link BigInteger}. */ -public final class BigIntegerCodec implements ObjectCodec<BigInteger> { - - @Override - public Class<? extends BigInteger> getEncodedClass() { - return BigInteger.class; - } - - @Override - public void serialize(SerializationContext context, BigInteger obj, CodedOutputStream codedOut) - throws IOException { - codedOut.writeByteArrayNoTag(obj.toByteArray()); - } - - @Override - public BigInteger deserialize(DeserializationContext context, CodedInputStream codedIn) - throws SerializationException, IOException { - return new BigInteger(codedIn.readByteArray()); - } -}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/BUILD b/src/test/java/com/google/devtools/build/lib/skyframe/BUILD index 23a6fbc..58444b9 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/BUILD +++ b/src/test/java/com/google/devtools/build/lib/skyframe/BUILD
@@ -181,7 +181,6 @@ "//src/main/java/com/google/devtools/build/lib/skyframe:action_execution_inactivity_watchdog", "//src/main/java/com/google/devtools/build/lib/skyframe:action_execution_value", "//src/main/java/com/google/devtools/build/lib/skyframe:action_metadata_handler", - "//src/main/java/com/google/devtools/build/lib/skyframe:action_sketch_function", "//src/main/java/com/google/devtools/build/lib/skyframe:action_template_expansion_function", "//src/main/java/com/google/devtools/build/lib/skyframe:action_template_expansion_value", "//src/main/java/com/google/devtools/build/lib/skyframe:artifact_function", @@ -245,7 +244,6 @@ "//src/main/java/com/google/devtools/build/lib/skyframe:target_pattern_phase_value", "//src/main/java/com/google/devtools/build/lib/skyframe:tests_for_target_pattern_value", "//src/main/java/com/google/devtools/build/lib/skyframe:toolchain_exception", - "//src/main/java/com/google/devtools/build/lib/skyframe:top_down_action_cache", "//src/main/java/com/google/devtools/build/lib/skyframe:transitive_base_traversal_function", "//src/main/java/com/google/devtools/build/lib/skyframe:transitive_target_key", "//src/main/java/com/google/devtools/build/lib/skyframe:transitive_traversal_function",
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java index e9c3b4d..44a2f36 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutorTest.java
@@ -769,12 +769,11 @@ options, NULL_CHECKER, null, - null, null); reporter.removeHandler(failFastHandler); // Expect errors. skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); EvaluationResult<FileArtifactValue> result = evaluate(ImmutableList.of(output1, output2)); assertWithMessage(result.toString()).that(result.keyNames()).isEmpty(); assertThat(result.hasError()).isTrue(); @@ -867,11 +866,10 @@ options, NULL_CHECKER, null, - null, null); skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); EvaluationResult<FileArtifactValue> result = evaluate(Artifact.keys(ImmutableList.of(output1, output2))); assertThat(result.hasError()).isFalse(); @@ -1011,11 +1009,10 @@ options, NULL_CHECKER, null, - null, null); skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); reporter.removeHandler(failFastHandler); try { evaluate(Artifact.keys(ImmutableList.of(outputA, outputB, outputC))); @@ -1096,11 +1093,10 @@ options, NULL_CHECKER, null, - null, null); skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); EvaluationResult<TreeArtifactValue> result = evaluate(ImmutableList.of(output1, output2)); @@ -1204,11 +1200,10 @@ options, NULL_CHECKER, null, - null, null); skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); evaluate(ImmutableList.of(sharedOutput1, sharedOutput2)); } @@ -1416,16 +1411,15 @@ options, NULL_CHECKER, null, - null, null); // NULL_CHECKER here means action cache, which would be our savior, is not in play. skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); EvaluationResult<FileArtifactValue> result = evaluate(Artifact.keys(ImmutableList.of(output1))); assertThat(result.hasError()).isFalse(); skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); EvaluationResult<FileArtifactValue> result2 = evaluate(Artifact.keys(ImmutableList.of(top, output2))); assertThat(result2.hasError()).isFalse(); @@ -1512,11 +1506,10 @@ options, NULL_CHECKER, null, - null, null); skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); reporter.removeHandler(failFastHandler); // Expect errors. evaluate(Artifact.keys(ImmutableList.of(output, output2))); assertContainsEvent( @@ -1588,11 +1581,10 @@ options, NULL_CHECKER, null, - null, null); skyframeExecutor.prepareBuildingForTestingOnly( - reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER, null); + reporter, new DummyExecutor(fileSystem, rootDirectory), options, NULL_CHECKER); evaluate(ImmutableList.of(Artifact.key(output2))); assertContainsEvent("action 1"); assertContainsEvent("action 2"); @@ -1747,7 +1739,6 @@ skyframeExecutor, ResourceManager.instanceForTestingOnly(), NULL_CHECKER, - null, ModifiedFileSet.EVERYTHING_MODIFIED, /* fileCache= */ null, ActionInputPrefetcher.NONE, @@ -1884,7 +1875,6 @@ skyframeExecutor, ResourceManager.instanceForTestingOnly(), NULL_CHECKER, - null, ModifiedFileSet.EVERYTHING_MODIFIED, /*fileCache=*/ null, ActionInputPrefetcher.NONE, @@ -2009,7 +1999,6 @@ skyframeExecutor, ResourceManager.instanceForTestingOnly(), NULL_CHECKER, - null, ModifiedFileSet.EVERYTHING_MODIFIED, /*fileCache=*/ null, ActionInputPrefetcher.NONE, @@ -2128,7 +2117,6 @@ skyframeExecutor, ResourceManager.instanceForTestingOnly(), NULL_CHECKER, - null, ModifiedFileSet.EVERYTHING_MODIFIED, /* fileCache= */ null, ActionInputPrefetcher.NONE, @@ -2236,7 +2224,6 @@ skyframeExecutor, ResourceManager.instanceForTestingOnly(), NULL_CHECKER, - null, ModifiedFileSet.EVERYTHING_MODIFIED, /* fileCache= */ null, ActionInputPrefetcher.NONE, @@ -2334,7 +2321,6 @@ skyframeExecutor, ResourceManager.instanceForTestingOnly(), NULL_CHECKER, - null, ModifiedFileSet.EVERYTHING_MODIFIED, /* fileCache= */ null, ActionInputPrefetcher.NONE, @@ -2418,7 +2404,6 @@ skyframeExecutor, ResourceManager.instanceForTestingOnly(), NULL_CHECKER, - null, ModifiedFileSet.EVERYTHING_MODIFIED, /*fileCache=*/ null, ActionInputPrefetcher.NONE,
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java index 69cedd2..dcabd2d 100644 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
@@ -151,7 +151,6 @@ protected OptionsParser options; protected final ActionKeyContext actionKeyContext = new ActionKeyContext(); - private TopDownActionCache topDownActionCache; @Before public final void initialize() throws Exception { @@ -164,11 +163,6 @@ tsgm = new TimestampGranularityMonitor(clock); actions = new LinkedHashSet<>(); actionTemplateExpansionFunction = new ActionTemplateExpansionFunction(actionKeyContext); - topDownActionCache = initTopDownActionCache(); - } - - protected TopDownActionCache initTopDownActionCache() { - return null; } protected void clearActions() { @@ -314,7 +308,6 @@ .put( SkyFunctions.ACTION_TEMPLATE_EXPANSION, new DelegatingActionTemplateExpansionFunction()) - .put(SkyFunctions.ACTION_SKETCH, new ActionSketchFunction(actionKeyContext)) .put( SkyFunctions.ARTIFACT_NESTED_SET, ArtifactNestedSetFunction.createInstance( @@ -377,7 +370,6 @@ options, new ActionCacheChecker( actionCache, null, actionKeyContext, ALWAYS_EXECUTE_FILTER, null), - topDownActionCache, /*outputService=*/ null, /*incrementalAnalysis=*/ true); skyframeActionExecutor.setActionExecutionProgressReportingObjects(
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TopDownActionCacheTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TopDownActionCacheTest.java deleted file mode 100644 index f48780f..0000000 --- a/src/test/java/com/google/devtools/build/lib/skyframe/TopDownActionCacheTest.java +++ /dev/null
@@ -1,223 +0,0 @@ -// Copyright 2019 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.skyframe; - -import static com.google.common.truth.Truth.assertThat; - -import com.github.benmanes.caffeine.cache.Cache; -import com.github.benmanes.caffeine.cache.Caffeine; -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; -import com.google.devtools.build.lib.collect.nestedset.NestedSet; -import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder; -import com.google.devtools.build.lib.collect.nestedset.Order; -import com.google.devtools.build.lib.util.Fingerprint; -import com.google.devtools.build.lib.vfs.FileSystemUtils; -import javax.annotation.Nullable; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests for top-down, transitive action caching. */ -@RunWith(JUnit4.class) -public final class TopDownActionCacheTest extends TimestampBuilderTestCase { - - @Override - protected TopDownActionCache initTopDownActionCache() { - return new InMemoryTopDownActionCache(); - } - - private void buildArtifacts(Artifact... artifacts) throws Exception { - buildArtifacts(amnesiacBuilder(), artifacts); - } - - private static NestedSet<Artifact> asNestedSet(Artifact... artifacts) { - return NestedSetBuilder.create(Order.STABLE_ORDER, artifacts); - } - - @Test - public void testAmnesiacBuilderGetsTopDownHit() throws Exception { - Artifact hello = createDerivedArtifact("hello"); - Button button = createActionButton(emptyNestedSet, ImmutableSet.of(hello)); - - button.pressed = false; - buildArtifacts(hello); - assertThat(button.pressed).isTrue(); - - button.pressed = false; - buildArtifacts(hello); - assertThat(button.pressed).isFalse(); - } - - @Test - public void testTransitiveTopDownCache() throws Exception { - Artifact hello = createDerivedArtifact("hello"); - Artifact hello2 = createDerivedArtifact("hello2"); - Button button = createActionButton(emptyNestedSet, ImmutableSet.of(hello)); - Button button2 = createActionButton(asNestedSet(hello), ImmutableSet.of(hello2)); - - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isTrue(); - assertThat(button2.pressed).isTrue(); - - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isFalse(); - assertThat(button2.pressed).isFalse(); - } - - @Test - public void testActionKeyCaching() throws Exception { - Artifact hello = createDerivedArtifact("hello"); - Artifact hello2 = createDerivedArtifact("hello2"); - - ActionKeyButton button = createActionKeyButton(emptyNestedSet, ImmutableSet.of(hello), "abc"); - ActionKeyButton button2 = - createActionKeyButton(asNestedSet(hello), ImmutableSet.of(hello2), "xyz"); - - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isTrue(); - assertThat(button2.pressed).isTrue(); - - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isFalse(); - assertThat(button2.pressed).isFalse(); - - clearActions(); - hello = createDerivedArtifact("hello"); - hello2 = createDerivedArtifact("hello2"); - button = createActionKeyButton(emptyNestedSet, ImmutableSet.of(hello), "abc"); - button2 = createActionKeyButton(asNestedSet(hello), ImmutableSet.of(hello2), "123"); - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isFalse(); - assertThat(button2.pressed).isTrue(); - - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isFalse(); - assertThat(button2.pressed).isFalse(); - - clearActions(); - hello = createDerivedArtifact("hello"); - hello2 = createDerivedArtifact("hello2"); - button = createActionKeyButton(emptyNestedSet, ImmutableSet.of(hello), "456"); - button2 = createActionKeyButton(asNestedSet(hello), ImmutableSet.of(hello2), "123"); - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isTrue(); - assertThat(button2.pressed).isTrue(); - - button.pressed = false; - button2.pressed = false; - buildArtifacts(hello2); - assertThat(button.pressed).isFalse(); - assertThat(button2.pressed).isFalse(); - } - - @Test - public void testSingleSourceArtifactChanged() throws Exception { - Artifact hello = createSourceArtifact("hello"); - hello.getPath().getParentDirectory().createDirectoryAndParents(); - FileSystemUtils.writeContentAsLatin1(hello.getPath(), "content1"); - - Artifact goodbye = createDerivedArtifact("goodbye"); - Button button = createActionButton(asNestedSet(hello), ImmutableSet.of(goodbye)); - - button.pressed = false; - buildArtifacts(goodbye); - assertThat(button.pressed).isTrue(); - - button.pressed = false; - buildArtifacts(goodbye); - assertThat(button.pressed).isFalse(); // top-down cached - - FileSystemUtils.writeContentAsLatin1(hello.getPath(), "content1"); - button.pressed = false; - buildArtifacts(goodbye); - assertThat(button.pressed).isFalse(); // top-down cached - - FileSystemUtils.writeContentAsLatin1(hello.getPath(), "content2"); - button.pressed = false; - buildArtifacts(goodbye); - assertThat(button.pressed).isTrue(); // built - - button.pressed = false; - buildArtifacts(goodbye); - assertThat(button.pressed).isFalse(); // top-down cached - } - - private static class InMemoryTopDownActionCache implements TopDownActionCache { - private final Cache<ActionSketch, ActionExecutionValue> cache = Caffeine.newBuilder().build(); - - @Nullable - @Override - public ActionExecutionValue get(ActionSketch sketch, ActionLookupData action) { - return cache.getIfPresent(sketch); - } - - @Override - public void put(ActionSketch sketch, ActionExecutionValue value) { - cache.put(sketch, value); - } - } - - private static final class MutableActionKeyAction extends TestAction { - private final ActionKeyButton button; - - MutableActionKeyAction( - ActionKeyButton button, NestedSet<Artifact> inputs, ImmutableSet<Artifact> outputs) { - super(button, inputs, outputs); - this.button = button; - } - - @Override - protected void computeKey( - ActionKeyContext actionKeyContext, - @Nullable Artifact.ArtifactExpander artifactExpander, - Fingerprint fp) { - super.computeKey(actionKeyContext, artifactExpander, fp); - fp.addString(button.key); - } - } - - private static final class ActionKeyButton extends Button { - private final String key; - - ActionKeyButton(String key) { - this.key = key; - } - } - - private ActionKeyButton createActionKeyButton( - NestedSet<Artifact> inputs, ImmutableSet<Artifact> outputs, String key) { - ActionKeyButton button = new ActionKeyButton(key); - registerAction(new MutableActionKeyAction(button, inputs, outputs)); - return button; - } -}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodecTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodecTest.java deleted file mode 100644 index 560f102..0000000 --- a/src/test/java/com/google/devtools/build/lib/skyframe/serialization/BigIntegerCodecTest.java +++ /dev/null
@@ -1,42 +0,0 @@ -// Copyright 2019 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.skyframe.serialization; - -import com.google.devtools.build.lib.skyframe.serialization.testutils.SerializationTester; -import java.math.BigInteger; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -/** Tests for {@link BigIntegerCodec}. */ -@RunWith(JUnit4.class) -public class BigIntegerCodecTest { - - @Test - public void smoke() throws Exception { - BigInteger bigBigInt = - new BigInteger("9999999999999999999999999999999999999999999999999999999999999"); - - new SerializationTester( - BigInteger.ZERO, - BigInteger.ONE, - BigInteger.valueOf(-1), - BigInteger.valueOf(Long.MAX_VALUE), - BigInteger.valueOf(Long.MIN_VALUE), - bigBigInt, - bigBigInt.pow(10_000)) - .runTests(); - } -}