Skip to content

Commit

Permalink
Split SpawnMetrics into two classes to reduce memory footprint.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 545947586
Change-Id: I88cb1abe4cddd4a69421fef2364ad53486068593
  • Loading branch information
meisterT authored and copybara-github committed Jul 6, 2023
1 parent d6cefac commit 3f8bab9
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 132 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/actions/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ java_library(
"FilesetTraversalParams.java",
"FilesetTraversalParamsFactory.java",
"ForbiddenActionInputException.java",
"FullSpawnMetrics.java",
"HasDigest.java",
"InputFileErrorException.java",
"InputMetadataProvider.java",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Copyright 2018 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;


/** Includes limits to SpawnMetrics, if set. */
@SuppressWarnings("GoodTime") // Use ints instead of Durations to improve build time (cl/505728570)
public final class FullSpawnMetrics extends SpawnMetrics {

private final long inputBytesLimit;
private final long inputFilesLimit;
private final long outputBytesLimit;
private final long outputFilesLimit;
private final long memoryBytesLimit;
private final int timeLimitInMs;

FullSpawnMetrics(Builder builder) {
super(builder);
this.inputBytesLimit = builder.inputBytesLimit;
this.inputFilesLimit = builder.inputFilesLimit;
this.outputBytesLimit = builder.outputBytesLimit;
this.outputFilesLimit = builder.outputFilesLimit;
this.memoryBytesLimit = builder.memoryBytesLimit;
this.timeLimitInMs = builder.timeLimitInMs;
}

/** Limit of total size in bytes of inputs or 0 if unavailable. */
@Override
public long inputBytesLimit() {
return inputBytesLimit;
}

/** Limit of total number of input files or 0 if unavailable. */
@Override
public long inputFilesLimit() {
return inputFilesLimit;
}

/** Limit of total size in bytes of outputs or 0 if unavailable. */
@Override
public long outputBytesLimit() {
return outputBytesLimit;
}

/** Limit of total number of output files or 0 if unavailable. */
@Override
public long outputFilesLimit() {
return outputFilesLimit;
}

/** Memory limit or 0 if unavailable. */
@Override
public long memoryLimit() {
return memoryBytesLimit;
}

/** Time limit in milliseconds or 0 if unavailable. */
@Override
public int timeLimitInMs() {
return timeLimitInMs;
}

}
Loading

0 comments on commit 3f8bab9

Please sign in to comment.