8332980: [IR Framework] Add option to measure IR rule processing time

Reviewed-by: kvn, chagedorn
This commit is contained in:
Theo Weidmann 2025-01-27 08:19:55 +00:00 committed by Christian Hagedorn
parent b8c68c0e8c
commit 175e58b2e3
3 changed files with 21 additions and 3 deletions

View File

@ -178,6 +178,7 @@ The framework provides various stress and debug flags. They should mainly be use
- `-DVerbose=true`: Enable more fain-grained logging (slows the execution down).
- `-DReproduce=true`: Flag to use when directly running a test VM to bypass dependencies to the driver VM state (for example, when reproducing an issue).
- `-DPrintTimes=true`: Print the execution time measurements of each executed test.
- `-DPrintRuleMatchingTime=true`: Print the time of matching IR rules per method. Slows down the execution as the rules are warmed up before meassurement.
- `-DVerifyVM=true`: The framework runs the test VM with additional verification flags (slows the execution down).
- `-DExcluceRandom=true`: The framework randomly excludes some methods from compilation. IR verification is disabled completely with this flag.
- `-DFlipC1C2=true`: The framework compiles all `@Test` annotated method with C1 if a C2 compilation would have been applied and vice versa. IR verification is disabled completely with this flag.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -148,6 +148,7 @@ public class TestFramework {
);
public static final boolean VERBOSE = Boolean.getBoolean("Verbose");
public static final boolean PRINT_RULE_MATCHING_TIME = Boolean.getBoolean("PrintRuleMatchingTime");
public static final boolean TESTLIST = !System.getProperty("Test", "").isEmpty();
public static final boolean EXCLUDELIST = !System.getProperty("Exclude", "").isEmpty();
private static final boolean REPORT_STDOUT = Boolean.getBoolean("ReportStdout");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -39,6 +39,8 @@ import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import static compiler.lib.ir_framework.TestFramework.PRINT_RULE_MATCHING_TIME;
/**
* This class represents a {@link Test @Test} annotated method that has an associated non-empty list of applicable
* {@link IR @IR} rules.
@ -83,6 +85,20 @@ public class IRMethod implements IRMethodMatchable {
*/
@Override
public MatchResult match() {
return new IRMethodMatchResult(method, matcher.match());
if (!PRINT_RULE_MATCHING_TIME) {
return new IRMethodMatchResult(method, matcher.match());
}
List<MatchResult> match;
for (int i = 0; i < 10; i++) { // warm up
match = matcher.match();
}
long startTime = System.nanoTime();
match = matcher.match();
long endTime = System.nanoTime();
long duration = (endTime - startTime);
System.out.println("Verifying IR rules for " + name() + ": " + duration + " ns = " + (duration / 1000000) + " ms");
return new IRMethodMatchResult(method, match);
}
}