diff options
author | Mark Schaller <mschaller@google.com> | 2015-02-20 23:14:47 +0000 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@google.com> | 2015-02-20 23:14:47 +0000 |
commit | 5d81dd5ac3a5af12c69ead07c70d062e70deb361 (patch) | |
tree | b03a075edcb2e121285d3d65bd6cc138697c9f16 /src/main/java/com/google/devtools/build/lib/rules | |
parent | a998ff5b152d10feb551480d42dcc648e51c5b28 (diff) |
Convert ResourceSet ctor calls to factory method
Most current invocations of the ResourceSet constructor shouldn't
care about any new dimensions we add to restrict test execution. This
change allows us to make those changes, keep the ResourceSet ctor
symmetrical, and avoid contaminating those ctor call sites with noise.
--
MOS_MIGRATED_REVID=86826112
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
8 files changed, 24 insertions, 20 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java index 29a8fb1921..02c4ddbaba 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppCompileAction.java @@ -956,7 +956,7 @@ public class CppCompileAction extends AbstractAction implements IncludeScannable public ResourceSet estimateResourceConsumptionLocal() { // We use a local compile, so much of the time is spent waiting for IO, // but there is still significant CPU; hence we estimate 50% cpu usage. - return new ResourceSet(/*memoryMb=*/200, /*cpuUsage=*/0.5, /*ioUsage=*/0.0); + return ResourceSet.createWithRamCpuIo(/*memoryMb=*/200, /*cpuUsage=*/0.5, /*ioUsage=*/0.0); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java index ecf3431b4f..36ad55f3b3 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkAction.java @@ -93,13 +93,16 @@ public final class CppLinkAction extends AbstractAction { // thrash the machine to the point where it stops // responding to keystrokes or mouse clicks. // CPU and IO do not scale similarly and still use the static minimum estimate. - public static final ResourceSet LINK_RESOURCES_PER_INPUT = new ResourceSet(1, 0, 0); + public static final ResourceSet LINK_RESOURCES_PER_INPUT = + ResourceSet.createWithRamCpuIo(1, 0, 0); // This defines the minimum of each resource that will be reserved. - public static final ResourceSet MIN_STATIC_LINK_RESOURCES = new ResourceSet(1536, 1, 0.3); + public static final ResourceSet MIN_STATIC_LINK_RESOURCES = + ResourceSet.createWithRamCpuIo(1536, 1, 0.3); // Dynamic linking should be cheaper than static linking. - public static final ResourceSet MIN_DYNAMIC_LINK_RESOURCES = new ResourceSet(1024, 0.3, 0.2); + public static final ResourceSet MIN_DYNAMIC_LINK_RESOURCES = + ResourceSet.createWithRamCpuIo(1024, 0.3, 0.2); /** * Use {@link Builder} to create instances of this class. Also see there for @@ -452,13 +455,13 @@ public final class CppLinkAction extends AbstractAction { final int inputSize = Iterables.size(getLinkCommandLine().getLinkerInputs()) + Iterables.size(getLinkCommandLine().getRuntimeInputs()); - return new ResourceSet( - Math.max(inputSize * LINK_RESOURCES_PER_INPUT.getMemoryMb(), - minLinkResources.getMemoryMb()), - Math.max(inputSize * LINK_RESOURCES_PER_INPUT.getCpuUsage(), - minLinkResources.getCpuUsage()), - Math.max(inputSize * LINK_RESOURCES_PER_INPUT.getIoUsage(), - minLinkResources.getIoUsage()) + return ResourceSet.createWithRamCpuIo( + Math.max(inputSize * LINK_RESOURCES_PER_INPUT.getMemoryMb(), + minLinkResources.getMemoryMb()), + Math.max(inputSize * LINK_RESOURCES_PER_INPUT.getCpuUsage(), + minLinkResources.getCpuUsage()), + Math.max(inputSize * LINK_RESOURCES_PER_INPUT.getIoUsage(), + minLinkResources.getIoUsage()) ); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java index a503f1f8d8..23005c37d1 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/CppModuleMapAction.java @@ -162,7 +162,7 @@ public class CppModuleMapAction extends AbstractFileWriteAction { @Override public ResourceSet estimateResourceConsumptionLocal() { - return new ResourceSet(/*memoryMb=*/0, /*cpuUsage=*/0, /*ioUsage=*/0.02); + return ResourceSet.createWithRamCpuIo(/*memoryMb=*/0, /*cpuUsage=*/0, /*ioUsage=*/0.02); } @VisibleForTesting diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java index 2fb8580e6f..0f8ab42fb2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FakeCppCompileAction.java @@ -197,7 +197,7 @@ public class FakeCppCompileAction extends CppCompileAction { @Override public ResourceSet estimateResourceConsumptionLocal() { - return new ResourceSet(/*memoryMb=*/1, /*cpuUsage=*/0.1, /*ioUsage=*/0.0); + return ResourceSet.createWithRamCpuIo(/*memoryMb=*/1, /*cpuUsage=*/0.1, /*ioUsage=*/0.0); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/SolibSymlinkAction.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/SolibSymlinkAction.java index 120ba86a34..d597465366 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/SolibSymlinkAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/SolibSymlinkAction.java @@ -92,7 +92,7 @@ public final class SolibSymlinkAction extends AbstractAction { @Override public ResourceSet estimateResourceConsumption(Executor executor) { - return new ResourceSet(/*memoryMb=*/0, /*cpuUsage=*/0, /*ioUsage=*/0.0); + return ResourceSet.createWithRamCpuIo(/*memoryMb=*/0, /*cpuUsage=*/0, /*ioUsage=*/0.0); } @Override diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/DeployArchiveBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/java/DeployArchiveBuilder.java index b9fe186ebd..9af470e649 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/DeployArchiveBuilder.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/DeployArchiveBuilder.java @@ -236,7 +236,7 @@ public class DeployArchiveBuilder { List<String> jvmArgs = ImmutableList.of("-client", SINGLEJAR_MAX_MEMORY); ResourceSet resourceSet = - new ResourceSet(/*memoryMb = */200.0, /*cpuUsage = */.2, /*ioUsage=*/.2); + ResourceSet.createWithRamCpuIo(/*memoryMb = */200.0, /*cpuUsage = */.2, /*ioUsage=*/.2); ruleContext.registerAction(new SpawnAction.Builder() .addInputs(inputs.build()) diff --git a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java index 397fa18685..006a5df5eb 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java +++ b/src/main/java/com/google/devtools/build/lib/rules/java/JavaCompileAction.java @@ -77,7 +77,7 @@ public class JavaCompileAction extends AbstractAction { private static final String GUID = "786e174d-ed97-4e79-9f61-ae74430714cf"; private static final ResourceSet LOCAL_RESOURCES = - new ResourceSet(750 /*MB*/, 0.5 /*CPU*/, 0.0 /*IO*/); + ResourceSet.createWithRamCpuIo(750 /*MB*/, 0.5 /*CPU*/, 0.0 /*IO*/); private final CommandLine javaCompileCommandLine; private final CommandLine commandLine; diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java b/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java index 8cf26b8dc1..0834ca9464 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/TestTargetProperties.java @@ -38,10 +38,11 @@ public class TestTargetProperties { /** * Resources used by local tests of various sizes. */ - private static final ResourceSet SMALL_RESOURCES = new ResourceSet(20, 0.9, 0.00); - private static final ResourceSet MEDIUM_RESOURCES = new ResourceSet(100, 0.9, 0.1); - private static final ResourceSet LARGE_RESOURCES = new ResourceSet(300, 0.8, 0.1); - private static final ResourceSet ENORMOUS_RESOURCES = new ResourceSet(800, 0.7, 0.4); + private static final ResourceSet SMALL_RESOURCES = ResourceSet.createWithRamCpuIo(20, 0.9, 0.00); + private static final ResourceSet MEDIUM_RESOURCES = ResourceSet.createWithRamCpuIo(100, 0.9, 0.1); + private static final ResourceSet LARGE_RESOURCES = ResourceSet.createWithRamCpuIo(300, 0.8, 0.1); + private static final ResourceSet ENORMOUS_RESOURCES = + ResourceSet.createWithRamCpuIo(800, 0.7, 0.4); private static ResourceSet getResourceSetFromSize(TestSize size) { switch (size) { |