aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/actions/cache/StubActionCache.java40
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java8
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java11
3 files changed, 59 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/actions/cache/StubActionCache.java b/src/main/java/com/google/devtools/build/lib/actions/cache/StubActionCache.java
new file mode 100644
index 0000000000..9e1cdd3663
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/actions/cache/StubActionCache.java
@@ -0,0 +1,40 @@
+// Copyright 2017 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.cache;
+
+import java.io.PrintStream;
+
+/** An {@link ActionCache} which does not store entries. */
+public class StubActionCache implements ActionCache {
+
+ @Override
+ public void put(String key, Entry entry) {}
+
+ @Override
+ public Entry get(String key) {
+ return null;
+ }
+
+ @Override
+ public void remove(String key) {}
+
+ @Override
+ public long save() {
+ return 0;
+ }
+
+ @Override
+ public void dump(PrintStream out) {}
+}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
index fe4fe8cfe1..3f6bcf1dc5 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeServerStartupOptions.java
@@ -298,4 +298,12 @@ public class BlazeServerStartupOptions extends OptionsBase {
+ "Please do not use this flag."
)
public boolean useCustomExitCodeOnAbruptExit;
+
+ @Option(
+ name = "use_action_cache",
+ defaultValue = "true",
+ category = "server startup",
+ help = "Whether to use the action cache"
+ )
+ public boolean useActionCache;
}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java
index 98c56c48c8..e2d08b1298 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeWorkspace.java
@@ -21,6 +21,7 @@ import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.SubscriberExceptionHandler;
import com.google.devtools.build.lib.actions.cache.ActionCache;
import com.google.devtools.build.lib.actions.cache.CompactPersistentActionCache;
+import com.google.devtools.build.lib.actions.cache.StubActionCache;
import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.analysis.WorkspaceStatusAction;
import com.google.devtools.build.lib.analysis.config.BinTools;
@@ -219,6 +220,16 @@ public final class BlazeWorkspace {
*/
public ActionCache getPersistentActionCache(Reporter reporter) throws IOException {
if (actionCache == null) {
+ boolean useActionCache =
+ runtime
+ .getStartupOptionsProvider()
+ .getOptions(BlazeServerStartupOptions.class)
+ .useActionCache;
+ if (!useActionCache) {
+ reporter.handle(Event.info("Action cache disabled"));
+ actionCache = new StubActionCache();
+ return actionCache;
+ }
try (AutoProfiler p = profiledAndLogged("Loading action cache", ProfilerTask.INFO, LOG)) {
try {
actionCache = new CompactPersistentActionCache(getCacheDirectory(), runtime.getClock());