From dffb6ee9dbf19e47b65c50c5f1955014e1e8f68c Mon Sep 17 00:00:00 2001 From: Mark Schaller Date: Wed, 25 Feb 2015 20:01:01 +0000 Subject: Add --local_test_jobs to limit local test concurrency Users have asked for ways to control the concurrency level of their local tests. They can do it right now using the --local_resources option, but that is unintuitive and affects the parallelism of non-test actions. This option changes the kind of resources obtained for local tests. If set, the CPU, RAM, and IO dimensions for local tests will not be used, and a new localTestCount dimension will be used, where the capacity is equal to the option's value, and each local test consumes one unit. -- MOS_MIGRATED_REVID=87177698 --- .../build/lib/rules/test/StandaloneTestStrategy.java | 5 +++-- .../build/lib/rules/test/TestTargetProperties.java | 17 ++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/test') diff --git a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java index 72970a83ae..d0ff9573fc 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java +++ b/src/main/java/com/google/devtools/build/lib/rules/test/StandaloneTestStrategy.java @@ -86,7 +86,7 @@ public class StandaloneTestStrategy extends TestStrategy { Spawn spawn = new BaseSpawn(getArgs(action), env, action.getTestProperties().getExecutionInfo(), action, - action.getTestProperties().getLocalResourceUsage()); + action.getTestProperties().getLocalResourceUsage(executionOptions.usingLocalTestJobs())); Executor executor = actionExecutionContext.getExecutor(); @@ -97,7 +97,8 @@ public class StandaloneTestStrategy extends TestStrategy { fileOutErr = new FileOutErr(action.getTestLog().getPath(), action.resolve(actionExecutionContext.getExecutor().getExecRoot()).getTestStderr()); - resources = action.getTestProperties().getLocalResourceUsage(); + resources = action.getTestProperties() + .getLocalResourceUsage(executionOptions.usingLocalTestJobs()); ResourceManager.instance().acquireResources(action, resources); TestResultData data = execute( actionExecutionContext.withFileOutErr(fileOutErr), spawn, action); 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 0834ca9464..0e0befc4d2 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,11 +38,12 @@ public class TestTargetProperties { /** * Resources used by local tests of various sizes. */ - 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 final ResourceSet SMALL_RESOURCES = ResourceSet.create(20, 0.9, 0.00, 1); + private static final ResourceSet MEDIUM_RESOURCES = ResourceSet.create(100, 0.9, 0.1, 1); + private static final ResourceSet LARGE_RESOURCES = ResourceSet.create(300, 0.8, 0.1, 1); + private static final ResourceSet ENORMOUS_RESOURCES = ResourceSet.create(800, 0.7, 0.4, 1); + private static final ResourceSet LOCAL_TEST_JOBS_BASED_RESOURCES = + ResourceSet.createWithLocalTestCount(1); private static ResourceSet getResourceSetFromSize(TestSize size) { switch (size) { @@ -115,8 +116,10 @@ public class TestTargetProperties { return isExternal; } - public ResourceSet getLocalResourceUsage() { - return TestTargetProperties.getResourceSetFromSize(size); + public ResourceSet getLocalResourceUsage(boolean usingLocalTestJobs) { + return usingLocalTestJobs + ? LOCAL_TEST_JOBS_BASED_RESOURCES + : TestTargetProperties.getResourceSetFromSize(size); } /** -- cgit v1.2.3