diff options
author | 2017-08-30 22:07:10 +0200 | |
---|---|---|
committer | 2017-08-31 13:44:40 +0200 | |
commit | ccb43ee3eb2940883ef57c2e6491b8e1a9bd24ef (patch) | |
tree | f4bec864969ff02b7169df3efebb34586bb0050f /src/main/java/com/google/devtools | |
parent | 50f46e290b7f52123d99edb125d7b53dbe2b7b4d (diff) |
Turn ActionCacheStatistics into a proto.
This is to avoid having to maintain an almost-equal Java data type once
we start externalizing statistics.
RELNOTES: None.
PiperOrigin-RevId: 167037360
Diffstat (limited to 'src/main/java/com/google/devtools')
3 files changed, 6 insertions, 48 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index deb506d2e4..8559c70e59 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD @@ -1173,13 +1173,13 @@ java_library( "//src/main/java/com/google/devtools/build/skyframe:skyframe-objects", "//src/main/java/com/google/devtools/common/options", "//src/main/java/com/google/devtools/common/options:invocation_policy", + "//src/main/protobuf:action_cache_java_proto", "//src/main/protobuf:build_java_proto", "//src/main/protobuf:command_server_java_grpc", "//src/main/protobuf:command_server_java_proto", "//src/main/protobuf:extra_actions_base_java_proto", "//src/main/protobuf:invocation_policy_java_proto", "//src/main/protobuf:test_status_java_proto", - "//third_party:auto_value", "//third_party:guava", "//third_party:joda_time", "//third_party:jsr305", diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ActionCacheStatistics.java b/src/main/java/com/google/devtools/build/lib/buildtool/ActionCacheStatistics.java deleted file mode 100644 index d1ccee635c..0000000000 --- a/src/main/java/com/google/devtools/build/lib/buildtool/ActionCacheStatistics.java +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2014 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.buildtool; - -import com.google.auto.value.AutoValue; -import java.time.Duration; - -/** Statistics about the action cache during a single build. */ -@AutoValue -public abstract class ActionCacheStatistics { - /** Gets the time it took to save the action cache to disk. */ - public abstract Duration saveTime(); - - /** Gets the size of the action cache in bytes as persisted on disk. */ - public abstract long sizeInBytes(); - - /** Returns a new builder. */ - static Builder builder() { - return new AutoValue_ActionCacheStatistics.Builder(); - } - - @AutoValue.Builder - abstract static class Builder { - /** Sets the time it took to save the action cache to disk. */ - abstract Builder setSaveTime(Duration duration); - - /** Sets the size of the action cache in bytes as persisted to disk. */ - abstract Builder setSizeInBytes(long sizeInBytes); - - /** Constructs and returns the {@link ActionCacheStatistics}. */ - abstract ActionCacheStatistics build(); - } -} 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 dc81d34317..56b1b906b3 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 @@ -48,6 +48,7 @@ import com.google.devtools.build.lib.actions.ResourceSet; import com.google.devtools.build.lib.actions.SpawnActionContext; import com.google.devtools.build.lib.actions.TestExecException; import com.google.devtools.build.lib.actions.cache.ActionCache; +import com.google.devtools.build.lib.actions.cache.Protos.ActionCacheStatistics; import com.google.devtools.build.lib.analysis.BuildView.AnalysisResult; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.TopLevelArtifactContext; @@ -96,7 +97,6 @@ import com.google.devtools.build.lib.vfs.PathFragment; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; -import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -107,6 +107,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.UUID; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; @@ -720,7 +721,7 @@ public class ExecutionTool { * capturing statistics. */ private void saveActionCache(ActionCache actionCache) { - ActionCacheStatistics.Builder builder = ActionCacheStatistics.builder(); + ActionCacheStatistics.Builder builder = ActionCacheStatistics.newBuilder(); AutoProfiler p = AutoProfiler.profiledAndLogged("Saving action cache", ProfilerTask.INFO, log); try { @@ -729,7 +730,8 @@ public class ExecutionTool { builder.setSizeInBytes(0); getReporter().handle(Event.error("I/O error while writing action log: " + e.getMessage())); } finally { - builder.setSaveTime(Duration.ofNanos(p.completeAndGetElapsedTimeNanos())); + builder.setSaveTimeInMs( + TimeUnit.MILLISECONDS.convert(p.completeAndGetElapsedTimeNanos(), TimeUnit.NANOSECONDS)); } env.getEventBus().post(builder.build()); |