From 5a90ad9412191d097f6fa309b4684bd4b9923c38 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Fri, 19 Aug 2022 13:14:51 +0200 Subject: [PATCH] 8293019: [JVMCI] change ratio of libgraal to C1 threads and use one isolate per libgraal thread Reviewed-by: never, iveresov --- src/hotspot/share/jvmci/jvmci_globals.cpp | 2 ++ src/hotspot/share/jvmci/jvmci_globals.hpp | 12 +++++++++--- .../share/runtime/tieredThresholdPolicy.cpp | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/jvmci/jvmci_globals.cpp b/src/hotspot/share/jvmci/jvmci_globals.cpp index d828bcc80e9..d82409f2dfd 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.cpp +++ b/src/hotspot/share/jvmci/jvmci_globals.cpp @@ -144,6 +144,7 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { CHECK_NOT_SET(JVMCIThreadsPerNativeLibraryRuntime, EnableJVMCI) CHECK_NOT_SET(JVMCICompilerIdleDelay, EnableJVMCI) CHECK_NOT_SET(UseJVMCINativeLibrary, EnableJVMCI) + CHECK_NOT_SET(JVMCINativeLibraryThreadFraction, EnableJVMCI) CHECK_NOT_SET(JVMCILibPath, EnableJVMCI) CHECK_NOT_SET(JVMCINativeLibraryErrorFile, EnableJVMCI) CHECK_NOT_SET(JVMCILibDumpJNIConfig, EnableJVMCI) @@ -193,6 +194,7 @@ bool JVMCIGlobals::enable_jvmci_product_mode(JVMFlag::Flags origin) { "JVMCILibPath", "JVMCILibDumpJNIConfig", "UseJVMCINativeLibrary", + "JVMCINativeLibraryThreadFraction", "JVMCINativeLibraryErrorFile", NULL }; diff --git a/src/hotspot/share/jvmci/jvmci_globals.hpp b/src/hotspot/share/jvmci/jvmci_globals.hpp index f249f8dcf28..f60f5febf93 100644 --- a/src/hotspot/share/jvmci/jvmci_globals.hpp +++ b/src/hotspot/share/jvmci/jvmci_globals.hpp @@ -54,9 +54,10 @@ "JVMCI flags to be non-experimental and defaults " \ "UseJVMCICompiler and EnableJVMCI to true.") \ \ - experimental(uint, JVMCIThreadsPerNativeLibraryRuntime, 0, \ + experimental(uint, JVMCIThreadsPerNativeLibraryRuntime, 1, \ "Max number of threads per JVMCI native runtime. " \ - "Specify 0 to force use of a single JVMCI native runtime. ") \ + "Specify 0 to force use of a single JVMCI native runtime. " \ + "Specify 1 to force a single JVMCI native runtime per thread. ") \ \ experimental(uint, JVMCICompilerIdleDelay, DEFAULT_COMPILER_IDLE_DELAY, \ "Number of milliseconds a JVMCI compiler queue should wait for " \ @@ -136,11 +137,16 @@ "and methods the JVMCI shared library must provide") \ \ experimental(bool, UseJVMCINativeLibrary, false, \ - "Execute JVMCI Java code from a shared library " \ + "Execute JVMCI Java code from a shared library (\"libjvmci\") " \ "instead of loading it from class files and executing it " \ "on the HotSpot heap. Defaults to true if UseJVMCICompiler is " \ "true and a JVMCI native library is available.") \ \ + experimental(double, JVMCINativeLibraryThreadFraction, 0.33, \ + "The fraction of compiler threads used by libjvmci. " \ + "The remaining compiler threads are used by C1.") \ + range(0.0, 1.0) \ + \ experimental(ccstr, JVMCINativeLibraryErrorFile, NULL, \ "If an error in the JVMCI native library occurs, save the " \ "error data to this file" \ diff --git a/src/hotspot/share/runtime/tieredThresholdPolicy.cpp b/src/hotspot/share/runtime/tieredThresholdPolicy.cpp index 371d3879898..3595e8b631f 100644 --- a/src/hotspot/share/runtime/tieredThresholdPolicy.cpp +++ b/src/hotspot/share/runtime/tieredThresholdPolicy.cpp @@ -257,8 +257,18 @@ void TieredThresholdPolicy::initialize() { // No C2 compiler thread required set_c1_count(count); } else { - set_c1_count(MAX2(count / 3, 1)); - set_c2_count(MAX2(count - c1_count(), 1)); +#if INCLUDE_JVMCI + if (UseJVMCICompiler && UseJVMCINativeLibrary) { + int libjvmci_count = MAX2((int) (count * JVMCINativeLibraryThreadFraction), 1); + int c1_count = MAX2(count - libjvmci_count, 1); + set_c2_count(libjvmci_count); + set_c1_count(c1_count); + } else +#endif + { + set_c1_count(MAX2(count / 3, 1)); + set_c2_count(MAX2(count - c1_count(), 1)); + } } assert(count == c1_count() + c2_count(), "inconsistent compiler thread count");