Skip to content

Commit

Permalink
IMproved handling of timebudget so it can no longer be confused
Browse files Browse the repository at this point in the history
  • Loading branch information
judovana committed Jul 31, 2024
1 parent 99b291f commit 66751b3
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 96 deletions.
21 changes: 9 additions & 12 deletions system/jcstress/Generate.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public class Generate {
private static final String[] NOT_SPLIT_ABLE_GROUPS = parseSplitImsplittable();

private static final int DEFAULT_CORES = 2;
private static final String DEFAULT_TIMEBUDGET = "1h";

private static final String TEMPLATE = """
<test>
Expand All @@ -67,7 +68,7 @@ public class Generate {
-DISABLED-
<command>
if [ "x$${JC_CORES}" = "x" ] ; then JC_CORES="-CORES-" ; else if [ "$${JC_CORES}" -eq "0" ] ; then JC_CORES="" ; else JC_CORES="-c $${JC_CORES}" ;fi;fi;\\
if [ "x$${JC_TIME_BUDGET}" = "x" ] ; then JC_TIME_BUDGET="-TB-" ; else JC_TIME_BUDGET="-tb $${JC_TIME_BUDGET}" ;fi;\\
if [ "x$${JC_TIME_BUDGET}" = "x" ] ; then JC_TIME_BUDGET="-TB-" ; else if [ "$${JC_TIME_BUDGET}" -eq "0" ] ; then JC_TIME_BUDGET="" ; else JC_TIME_BUDGET="-tb $${JC_TIME_BUDGET}" ;fi;fi;\\
if [ "x$${PRINT_INTERVAL_MS}" = "x" ] ; then PRINT_INTERVAL_MS="-PRINT_INTERVAL_MS-" ; else PRINT_INTERVAL_MS="-Djcstress.console.printIntervalMs=$${PRINT_INTERVAL_MS}" ;fi;\\
$(JAVA_COMMAND) $(JVM_OPTIONS) $${PRINT_INTERVAL_MS}} -jar $(Q)$(LIB_DIR)$(D)-JARFILE-$(Q) $(APPLICATION_OPTIONS) $${JC_TIME_BUDGET} $${JC_CORES} -t "-REGEX-"; \\
$(TEST_STATUS)
Expand Down Expand Up @@ -208,10 +209,10 @@ private static void setAndPrintSetup() {
} else {
System.err.println("Cores for final playlist are " + getCoresForPlaylist() + ". Intentional? 0 is All.");
}
if (isTimeBudgetSet()) {
System.err.println("Time budget is " + getTimeBudget() + ". Intentional?");
if (getTimeBudget() == DEFAULT_TIMEBUDGET) {
System.err.println("Time budget is default " + getTimeBudget() + ". Intentional? 0 is unlimited");
} else {
System.err.println("Time budget is not used. Intentional?");
System.err.println("Time budget is " + getTimeBudget() + ". Intentional? 0 is unlimited");
}
System.err.println("PRINT_INTERVAL_MS is set as " + getOutputDelay() + " (milliseconds)");
if (getOutputStyle() == OutputType.GENERATE) {
Expand Down Expand Up @@ -281,7 +282,7 @@ private static boolean isAnnotationPresent(Method method, String[] annotationTyp

private static void printPlaylist(String jarName, List<GroupWithCases> groups) {
String timeBudgetString = "";
if (isTimeBudgetSet()) {
if (!getTimeBudget().equals("0")) {
timeBudgetString = "-tb " + getTimeBudget();
}
int cores = getCoresForPlaylist();
Expand Down Expand Up @@ -325,10 +326,6 @@ private static void printPlaylist(String jarName, List<GroupWithCases> groups) {
System.out.println(FOOTER);
}

private static boolean isTimeBudgetSet() {
return !(getTimeBudget() == null || getTimeBudget().trim().equals("0") || getTimeBudget().trim().equals(""));
}

private static void testTimesByRunningJcstress(List<GroupWithCases> groups) throws IOException, InterruptedException {
final List<GroupWithCases> results = new ArrayList<>();
//It may happen we will kill it in runtime... good to print at least something
Expand Down Expand Up @@ -414,7 +411,7 @@ private static String getOutputDelay() {
* @return time with unit. Eg 100s or 30m
*/
private static String getTimeBudget() {
return System.getenv("TIME_BUDGET") == null ? null : System.getenv("TIME_BUDGET");
return System.getenv("TIME_BUDGET") == null ? DEFAULT_TIMEBUDGET : System.getenv("TIME_BUDGET");
}

private static OutputType getOutputStyle() {
Expand Down Expand Up @@ -653,7 +650,7 @@ private static List<String> getBasicJcstressCommand(String jvm) {
args.add("-c");
args.add(cores + "");
}
if (isTimeBudgetSet()) {
if (!getTimeBudget().equals("0")) {
args.add("-tb");
args.add(getTimeBudget());
}
Expand Down Expand Up @@ -722,7 +719,7 @@ public static void calculateStats(List<GroupWithCases> results, List<GroupWithCa
totalTime += (long) (time.tests.getMainOne());
}
long avgTimeExpected = totalTime / results.size();
if (isTimeBudgetSet()) {
if (!getTimeBudget().equals("0")) {
System.out.println(" - The calculations from real run are provided. They are based on meassured times and real results (not expected results)");
System.out.println(" - You had -tb " + getTimeBudget() + " set, so yours expected avg tim is " + getTimeBudget() + " and not the measured real values bellow");
System.out.println(" - Your workload should have run " + resultsExpected.size() + " * " + getTimeBudget() + " but run " + secondsToDays(totalTime) + " and was finished " + results.size() + " from " + resultsExpected.size());
Expand Down
2 changes: 1 addition & 1 deletion system/jcstress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ In order of importance and reasonability
* SPLIT_BIG_BASES - true/false. **default is false**. Each natural group group bigger then LIMIT is split once it reaches limit.
* MAX_NATURAL_ITERATIONS - number, usually 1-10, how many namespaces can be cut for natural grouping.
* CORES - number, **defaults to 2**. Set to 0 to use all cores (recomeded by upstream, but runing surprsingly long)
* TIME_BUDGET - string, **defaults to 1h**. set to anything you think your tests will fit. This is just best effort, not a strict cut. It is upstream bug.
* TIME_BUDGET - string, **defaults to 1h**. set to anything you think your tests will fit. This is just best effort, not a strict cut. It is upstream bug. 0 i sunlimited.
* VERBOSE - set to true to see a lot of weird stuff
* FQN - set to true to use fully qualified names instead of shortened ones. This may casue soem targets to not fit to OS cmdline limit.
<details>
Expand Down
Loading

0 comments on commit 66751b3

Please sign in to comment.