From a5c24ea168d82670ed841a46296a621b105f95c7 Mon Sep 17 00:00:00 2001 From: Gareth Ellis Date: Mon, 22 Jan 2024 16:47:51 +0100 Subject: [PATCH] Make Jit telelmetry compatible with JDK 9+ --- esrally/mechanic/launcher.py | 2 +- esrally/telemetry.py | 26 ++++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/esrally/mechanic/launcher.py b/esrally/mechanic/launcher.py index 6ef3ee7c8..18d21f90b 100644 --- a/esrally/mechanic/launcher.py +++ b/esrally/mechanic/launcher.py @@ -149,7 +149,7 @@ def _start_node(self, node_configuration, node_count_on_host): telemetry_params = self.cfg.opts("telemetry", "params") node_telemetry = [ telemetry.FlightRecorder(telemetry_params, node_telemetry_dir, java_major_version), - telemetry.JitCompiler(node_telemetry_dir), + telemetry.JitCompiler(node_telemetry_dir, java_major_version), telemetry.Gc(telemetry_params, node_telemetry_dir, java_major_version), telemetry.Heapdump(node_telemetry_dir), telemetry.DiskIo(node_count_on_host), diff --git a/esrally/telemetry.py b/esrally/telemetry.py index 2ffff9827..9343fead9 100644 --- a/esrally/telemetry.py +++ b/esrally/telemetry.py @@ -283,21 +283,31 @@ class JitCompiler(TelemetryDevice): human_name = "JIT Compiler Profiler" help = "Enables JIT compiler logs." - def __init__(self, log_root): + def __init__(self, log_root, java_major_version): super().__init__() self.log_root = log_root + self.java_major_version = java_major_version def instrument_java_opts(self): io.ensure_dir(self.log_root) log_file = os.path.join(self.log_root, "jit.log") console.info("%s: Writing JIT compiler log to [%s]" % (self.human_name, log_file), logger=self.logger) - return [ - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+TraceClassLoading", - "-XX:+LogCompilation", - f"-XX:LogFile={log_file}", - "-XX:+PrintAssembly", - ] + if self.java_major_version < 9: + return [ + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+TraceClassLoading", + "-XX:+LogCompilation", + f"-XX:LogFile={log_file}", + "-XX:+PrintAssembly", + ] + else: + return [ + "-XX:+UnlockDiagnosticVMOptions", + "-Xlog:class+load=info", + "-XX:+LogCompilation", + f"-XX:LogFile={log_file}", + "-XX:+PrintAssembly", + ] class Gc(TelemetryDevice):