Skip to content

Commit

Permalink
PLANNER-712 Benchmark should warm up for 30 seconds by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ge0ffrey committed Jan 3, 2017
1 parent bb8f078 commit 0b069f3
Show file tree
Hide file tree
Showing 40 changed files with 79 additions and 38 deletions.
Expand Up @@ -44,6 +44,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;

@XStreamAlias("plannerBenchmark")
public class PlannerBenchmarkConfig {

Expand All @@ -61,6 +63,7 @@ public class PlannerBenchmarkConfig {
private Long warmUpSecondsSpentLimit = null;
private Long warmUpMinutesSpentLimit = null;
private Long warmUpHoursSpentLimit = null;
private Long warmUpDaysSpentLimit = null;

@XStreamAlias("benchmarkReport")
private BenchmarkReportConfig benchmarkReportConfig = null;
Expand Down Expand Up @@ -148,6 +151,14 @@ public void setWarmUpHoursSpentLimit(Long warmUpHoursSpentLimit) {
this.warmUpHoursSpentLimit = warmUpHoursSpentLimit;
}

public Long getWarmUpDaysSpentLimit() {
return warmUpDaysSpentLimit;
}

public void setWarmUpDaysSpentLimit(Long warmUpDaysSpentLimit) {
this.warmUpDaysSpentLimit = warmUpDaysSpentLimit;
}

public BenchmarkReportConfig getBenchmarkReportConfig() {
return benchmarkReportConfig;
}
Expand Down Expand Up @@ -198,7 +209,7 @@ public PlannerBenchmark buildPlannerBenchmark(SolverConfigContext solverConfigCo
plannerBenchmarkResult.setAggregation(false);
int parallelBenchmarkCount = resolveParallelBenchmarkCount();
plannerBenchmarkResult.setParallelBenchmarkCount(parallelBenchmarkCount);
plannerBenchmarkResult.setWarmUpTimeMillisSpentLimit(calculateWarmUpTimeMillisSpentLimit());
plannerBenchmarkResult.setWarmUpTimeMillisSpentLimit(defaultIfNull(calculateWarmUpTimeMillisSpentLimit(), 30L));
plannerBenchmarkResult.setUnifiedProblemBenchmarkResultList(new ArrayList<>());
plannerBenchmarkResult.setSolverBenchmarkResultList(new ArrayList<>(
effectiveSolverBenchmarkConfigList.size()));
Expand Down Expand Up @@ -331,19 +342,46 @@ protected int resolveParallelBenchmarkCountAutomatically(int availableProcessorC
}
}

protected long calculateWarmUpTimeMillisSpentLimit() {
protected Long calculateWarmUpTimeMillisSpentLimit() {
if (warmUpMillisecondsSpentLimit == null && warmUpSecondsSpentLimit == null
&& warmUpMinutesSpentLimit == null && warmUpHoursSpentLimit == null && warmUpDaysSpentLimit == null) {
return null;
}
long warmUpTimeMillisSpentLimit = 0L;
if (warmUpMillisecondsSpentLimit != null) {
if (warmUpMillisecondsSpentLimit < 0L) {
throw new IllegalArgumentException("The warmUpMillisecondsSpentLimit (" + warmUpMillisecondsSpentLimit
+ ") cannot be negative.");
}
warmUpTimeMillisSpentLimit += warmUpMillisecondsSpentLimit;
}
if (warmUpSecondsSpentLimit != null) {
warmUpTimeMillisSpentLimit += warmUpSecondsSpentLimit * 1000L;
if (warmUpSecondsSpentLimit < 0L) {
throw new IllegalArgumentException("The warmUpSecondsSpentLimit (" + warmUpSecondsSpentLimit
+ ") cannot be negative.");
}
warmUpTimeMillisSpentLimit += warmUpSecondsSpentLimit * 1_000L;
}
if (warmUpMinutesSpentLimit != null) {
warmUpTimeMillisSpentLimit += warmUpMinutesSpentLimit * 60000L;
if (warmUpMinutesSpentLimit < 0L) {
throw new IllegalArgumentException("The warmUpMinutesSpentLimit (" + warmUpMinutesSpentLimit
+ ") cannot be negative.");
}
warmUpTimeMillisSpentLimit += warmUpMinutesSpentLimit * 60_000L;
}
if (warmUpHoursSpentLimit != null) {
warmUpTimeMillisSpentLimit += warmUpHoursSpentLimit * 3600000L;
if (warmUpHoursSpentLimit < 0L) {
throw new IllegalArgumentException("The warmUpHoursSpentLimit (" + warmUpHoursSpentLimit
+ ") cannot be negative.");
}
warmUpTimeMillisSpentLimit += warmUpHoursSpentLimit * 3_600_000L;
}
if (warmUpDaysSpentLimit != null) {
if (warmUpDaysSpentLimit < 0L) {
throw new IllegalArgumentException("The warmUpDaysSpentLimit (" + warmUpDaysSpentLimit
+ ") cannot be negative.");
}
warmUpTimeMillisSpentLimit += warmUpDaysSpentLimit * 86_400_000L;
}
return warmUpTimeMillisSpentLimit;
}
Expand Down
Expand Up @@ -151,7 +151,7 @@ public void calculateWarmUpTimeMillisSpentLimit() {
config.setWarmUpMinutesSpentLimit(2L);
config.setWarmUpSecondsSpentLimit(5L);
config.setWarmUpMillisecondsSpentLimit(753L);
assertEquals(3_725_753L, config.calculateWarmUpTimeMillisSpentLimit());
assertEquals(3_725_753L, (long) config.calculateWarmUpTimeMillisSpentLimit());
}

}
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>target/benchmarkTest/output</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>
<solverBenchmark>
<problemBenchmarks>
<solutionFileIOClass>org.optaplanner.persistence.common.api.domain.solution.RigidTestdataSolutionFileIO</solutionFileIOClass>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>target/benchmarkTest/output</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>
<#list ['FIRST_FIT', 'CHEAPEST_INSERTION'] as constructionHeuristicType>
<solverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>target/benchmarkTest/output</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>
<solverBenchmark>
<problemBenchmarks>
<solutionFileIOClass>org.optaplanner.persistence.common.api.domain.solution.RigidTestdataSolutionFileIO</solutionFileIOClass>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>target/benchmarkTest/output</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>
<#list ['FIRST_FIT', 'CHEAPEST_INSERTION'] as constructionHeuristicType>
<solverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -358,28 +358,28 @@ public Long calculateTimeMillisSpentLimit() {
throw new IllegalArgumentException("The termination secondsSpentLimit (" + secondsSpentLimit
+ ") cannot be negative.");
}
timeMillisSpentLimit += secondsSpentLimit * 1000L;
timeMillisSpentLimit += secondsSpentLimit * 1_000L;
}
if (minutesSpentLimit != null) {
if (minutesSpentLimit < 0L) {
throw new IllegalArgumentException("The termination minutesSpentLimit (" + minutesSpentLimit
+ ") cannot be negative.");
}
timeMillisSpentLimit += minutesSpentLimit * 60000L;
timeMillisSpentLimit += minutesSpentLimit * 60_000L;
}
if (hoursSpentLimit != null) {
if (hoursSpentLimit < 0L) {
throw new IllegalArgumentException("The termination hoursSpentLimit (" + hoursSpentLimit
+ ") cannot be negative.");
}
timeMillisSpentLimit += hoursSpentLimit * 3600000L;
timeMillisSpentLimit += hoursSpentLimit * 3_600_000L;
}
if (daysSpentLimit != null) {
if (daysSpentLimit < 0L) {
throw new IllegalArgumentException("The termination daysSpentLimit (" + daysSpentLimit
+ ") cannot be negative.");
}
timeMillisSpentLimit += daysSpentLimit * 86400000L;
timeMillisSpentLimit += daysSpentLimit * 86_400_000L;
}
return timeMillisSpentLimit;
}
Expand Down
Expand Up @@ -235,17 +235,29 @@ Otherwise, an unstable network connection can ruin a long running benchmark.
[[warmingUpTheHotSpotCompiler]]
=== Warming Up The HotSpot Compiler

**Without a warm up, the results of the first (or first few) benchmarks are not reliable**,
because they will have lost CPU time on HotSpot JIT compilation (and possibly DRL compilation too).
Without a warm up, the results of the first (or first few) benchmarks are not reliable,
because they will lose CPU time on HotSpot JIT compilation (and possibly DRL compilation too).

To avoid that distortion, the benchmarker can run some of the benchmarks for a specified amount of time, before running the real benchmarks.
Generally, a warm up of 30 seconds suffices:
To avoid that distortion, the benchmarker runs some of the benchmarks for 30 seconds,
before running the real benchmarks.
That default warm up of 30 seconds usually suffices. Change it, for example to give it 60 seconds:

[source,xml,options="nowrap"]
----
<plannerBenchmark>
...
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>
<warmUpSecondsSpentLimit>60</warmUpSecondsSpentLimit>
...
</plannerBenchmark>
----

Turn off the warm up phase altogether by setting it to zero:

[source,xml,options="nowrap"]
----
<plannerBenchmark>
...
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>
...
</plannerBenchmark>
----
Expand All @@ -267,7 +279,6 @@ To quickly configure and run a benchmark for typical solver configs, use a `solv
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/nqueens</benchmarkDirectory>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>
<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/general</benchmarkDirectory>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/general/template</benchmarkDirectory>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/cheaptime</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/cheaptime</benchmarkDirectory>
<!--<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>-->
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/cloudbalancing</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/cloudbalancing/template</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/cloudbalancing/scoreDirector</benchmarkDirectory>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/cloudbalancing/stepLimit</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/curriculumcourse</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/curriculumcourse/template</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/curriculumcourse/stepLimit</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/examination</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/examination/stepLimit</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/machinereassignment</benchmarkDirectory>
<!--<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>-->
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/machinereassignment/stepLimit</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/nqueens</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/nqueens/scoreDirector</benchmarkDirectory>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/nqueens/stepLimit</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/nurserostering/long</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/nurserostering/medium</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plannerBenchmark>
<benchmarkDirectory>local/data/nurserostering/stepLimit</benchmarkDirectory>
<warmUpSecondsSpentLimit>0</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/pas</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down
Expand Up @@ -2,7 +2,6 @@
<plannerBenchmark>
<benchmarkDirectory>local/data/projectjobscheduling/template</benchmarkDirectory>
<parallelBenchmarkCount>AUTO</parallelBenchmarkCount>
<warmUpSecondsSpentLimit>30</warmUpSecondsSpentLimit>

<inheritedSolverBenchmark>
<problemBenchmarks>
Expand Down

0 comments on commit 0b069f3

Please sign in to comment.