From 175e58b2e321b779276a9a98a5e72cedb9638d0c Mon Sep 17 00:00:00 2001 From: Theo Weidmann Date: Mon, 27 Jan 2025 08:19:55 +0000 Subject: [PATCH] 8332980: [IR Framework] Add option to measure IR rule processing time Reviewed-by: kvn, chagedorn --- .../jtreg/compiler/lib/ir_framework/README.md | 1 + .../lib/ir_framework/TestFramework.java | 3 ++- .../driver/irmatching/irmethod/IRMethod.java | 20 +++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/README.md b/test/hotspot/jtreg/compiler/lib/ir_framework/README.md index c807a2651b6..6bdae262599 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/README.md +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/README.md @@ -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. diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java index caef911f73a..889bd39413b 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java @@ -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"); diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java index dbd431d22e0..714af5c6519 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/driver/irmatching/irmethod/IRMethod.java @@ -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 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); } }