From 1d02b44447f827cd078b2e2f541f71f27f378c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20H=C3=A4ssig?= Date: Thu, 4 Sep 2025 15:15:22 +0200 Subject: [PATCH 1/3] Use timeuot factor --- .../jtreg/compiler/arguments/TestCompileTaskTimeout.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java b/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java index cb52e5a24a056..f19223e6dceef 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java +++ b/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java @@ -37,6 +37,11 @@ public class TestCompileTaskTimeout { public static void main(String[] args) throws Throwable { + double timeoutFactor = 1.0; + try { + timeoutFactor = Double.parseDouble(System.getProperty("test.timeout.factor", "1.0")); + } catch (NumberFormatException ignored) {} + ProcessTools.executeTestJava("-Xcomp", "-XX:CompileTaskTimeout=1", "--version") .shouldHaveExitValue(134) .shouldContain("timed out after"); @@ -49,7 +54,8 @@ public static void main(String[] args) throws Throwable { .shouldHaveExitValue(134) .shouldContain("timed out after"); - ProcessTools.executeTestJava("-Xcomp", "-XX:CompileTaskTimeout=2000", "--version") + int timeout = (int)(500.0 * timeoutFactor); + ProcessTools.executeTestJava("-Xcomp", "-XX:CompileTaskTimeout=" + timeout, "--version") .shouldHaveExitValue(0); } } From bbcd2b62753f9156f95d01e00f914cdb6fe8b4c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20H=C3=A4ssig?= Date: Fri, 5 Sep 2025 17:12:56 +0200 Subject: [PATCH 2/3] Add regression test --- .../compiler/arguments/TestCompileTaskTimeout.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java b/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java index f19223e6dceef..9ec3beb0d89c0 100644 --- a/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java +++ b/test/hotspot/jtreg/compiler/arguments/TestCompileTaskTimeout.java @@ -25,7 +25,7 @@ /* * @test TestCompileTaskTimeout - * @bug 8308094 8365909 + * @bug 8308094 8365909 8366875 * @requires vm.debug & vm.flagless & os.name == "Linux" * @summary Check functionality of CompileTaskTimeout * @library /test/lib @@ -42,6 +42,7 @@ public static void main(String[] args) throws Throwable { timeoutFactor = Double.parseDouble(System.getProperty("test.timeout.factor", "1.0")); } catch (NumberFormatException ignored) {} + // Short timeouts crash the VM. ProcessTools.executeTestJava("-Xcomp", "-XX:CompileTaskTimeout=1", "--version") .shouldHaveExitValue(134) .shouldContain("timed out after"); @@ -54,8 +55,17 @@ public static void main(String[] args) throws Throwable { .shouldHaveExitValue(134) .shouldContain("timed out after"); + // A long enough timeout succeeds. int timeout = (int)(500.0 * timeoutFactor); ProcessTools.executeTestJava("-Xcomp", "-XX:CompileTaskTimeout=" + timeout, "--version") .shouldHaveExitValue(0); + + // Each repeated compilation has a new timeout. + ProcessTools.executeTestJava("-Xcomp", + "-XX:CompileTaskTimeout=" + timeout, + "-XX:RepeatCompilation=100", + "-XX:CompileCommand=compileonly,java/util/concurrent/ConcurrentHashMap.*", + "--version") + .shouldHaveExitValue(0); } } From cfe842c77ec657a396541512ff30d52595ba37eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20H=C3=A4ssig?= Date: Fri, 5 Sep 2025 17:13:43 +0200 Subject: [PATCH 3/3] Reset timeout on repeated compilations --- src/hotspot/os/linux/compilerThreadTimeout_linux.hpp | 4 ++++ src/hotspot/share/compiler/compileBroker.cpp | 1 + src/hotspot/share/compiler/compilerThread.hpp | 1 + 3 files changed, 6 insertions(+) diff --git a/src/hotspot/os/linux/compilerThreadTimeout_linux.hpp b/src/hotspot/os/linux/compilerThreadTimeout_linux.hpp index 2dc6fa7b9c9eb..7c27080eb5e79 100644 --- a/src/hotspot/os/linux/compilerThreadTimeout_linux.hpp +++ b/src/hotspot/os/linux/compilerThreadTimeout_linux.hpp @@ -46,6 +46,10 @@ class CompilerThreadTimeoutLinux : public CHeapObj { bool init_timeout(); void arm(); void disarm(); + void reset() { + disarm(); + arm(); + }; }; #endif //LINUX_COMPILER_THREAD_TIMEOUT_LINUX_HPP diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index 5f3bdc5ee3c41..530639618a4fe 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -2346,6 +2346,7 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) { while (repeat_compilation_count > 0) { ResourceMark rm(thread); task->print_ul("NO CODE INSTALLED"); + thread->timeout()->reset(); comp->compile_method(&ci_env, target, osr_bci, false, directive); repeat_compilation_count--; } diff --git a/src/hotspot/share/compiler/compilerThread.hpp b/src/hotspot/share/compiler/compilerThread.hpp index e4641780a1296..e5b145608722e 100644 --- a/src/hotspot/share/compiler/compilerThread.hpp +++ b/src/hotspot/share/compiler/compilerThread.hpp @@ -51,6 +51,7 @@ class CompilerThreadTimeoutGeneric : public CHeapObj { CompilerThreadTimeoutGeneric() {}; void arm() {}; void disarm() {}; + void reset() {}; bool init_timeout() { return true; }; }; #endif // !LINUX