From 7575def0808b7645bdc72ff4529df5a2439f7d48 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Sat, 6 Aug 2022 11:06:07 -0400 Subject: [PATCH 1/2] Improve the overall fidelity of JFR profiles and reduce sampling bias Note due to https://bugs.openjdk.org/browse/JDK-8201516 there may still be potentially small incorrect attribution, but overall this tradeoff is worth the sampling bias impact. See references: * http://hirt.se/blog/?p=609 * https://docs.oracle.com/javacomponents/jmc-5-5/jfr-runtime-guide/about.htm#JFRRT111 * https://jpbempel.github.io/2022/06/22/debug-non-safepoints.html --- .../gradle/dist/service/tasks/LaunchConfigTask.java | 5 +++++ .../dist/service/JavaServiceDistributionPluginTests.groovy | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/gradle-sls-packaging/src/main/java/com/palantir/gradle/dist/service/tasks/LaunchConfigTask.java b/gradle-sls-packaging/src/main/java/com/palantir/gradle/dist/service/tasks/LaunchConfigTask.java index 97c8d6b65..4db07fa98 100644 --- a/gradle-sls-packaging/src/main/java/com/palantir/gradle/dist/service/tasks/LaunchConfigTask.java +++ b/gradle-sls-packaging/src/main/java/com/palantir/gradle/dist/service/tasks/LaunchConfigTask.java @@ -74,6 +74,11 @@ public abstract class LaunchConfigTask extends DefaultTask { // AWS-managed systems that modify DNS records on failover. "-Dsun.net.inetaddr.ttl=20", "-XX:NativeMemoryTracking=summary", + // Improve the overall fidelity of JFR profiles and reduce sampling bias, + // see http://hirt.se/blog/?p=609 & https://jpbempel.github.io/2022/06/22/debug-non-safepoints.html + // Per https://bugs.openjdk.org/browse/JDK-8201516 may still be potentially incorrect attribution. + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+DebugNonSafepoints", // Increase default JFR stack depth beyond the default (conservative) 64 frames. // This can be overridden by user-provided options. // See sls-packaging#1230 diff --git a/gradle-sls-packaging/src/test/groovy/com/palantir/gradle/dist/service/JavaServiceDistributionPluginTests.groovy b/gradle-sls-packaging/src/test/groovy/com/palantir/gradle/dist/service/JavaServiceDistributionPluginTests.groovy index c48d3a7e7..ea4ba4620 100644 --- a/gradle-sls-packaging/src/test/groovy/com/palantir/gradle/dist/service/JavaServiceDistributionPluginTests.groovy +++ b/gradle-sls-packaging/src/test/groovy/com/palantir/gradle/dist/service/JavaServiceDistributionPluginTests.groovy @@ -407,6 +407,8 @@ class JavaServiceDistributionPluginTests extends GradleIntegrationSpec { '-XX:HeapDumpPath=var/log', '-Dsun.net.inetaddr.ttl=20', '-XX:NativeMemoryTracking=summary', + '-XX:+UnlockDiagnosticVMOptions', + '-XX:+DebugNonSafepoints', '-XX:FlightRecorderOptions=stackdepth=256', '-XX:+UseParallelGC', '-Xmx4M', @@ -432,6 +434,8 @@ class JavaServiceDistributionPluginTests extends GradleIntegrationSpec { '-XX:HeapDumpPath=var/log', '-Dsun.net.inetaddr.ttl=20', '-XX:NativeMemoryTracking=summary', + '-XX:+UnlockDiagnosticVMOptions', + '-XX:+DebugNonSafepoints', '-XX:FlightRecorderOptions=stackdepth=256', '-Xmx4M', '-Djavax.net.ssl.trustStore=truststore.jks']) @@ -471,6 +475,8 @@ class JavaServiceDistributionPluginTests extends GradleIntegrationSpec { '-XX:HeapDumpPath=var/log', '-Dsun.net.inetaddr.ttl=20', '-XX:NativeMemoryTracking=summary', + '-XX:+UnlockDiagnosticVMOptions', + '-XX:+DebugNonSafepoints', '-XX:FlightRecorderOptions=stackdepth=256', "-XX:+PrintGCDateStamps", "-XX:+PrintGCDetails", From b5ad347f205cf46d80e997674438b68b8bdd051e Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Sat, 6 Aug 2022 15:14:27 +0000 Subject: [PATCH 2/2] Add generated changelog entries --- changelog/@unreleased/pr-1376.v2.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 changelog/@unreleased/pr-1376.v2.yml diff --git a/changelog/@unreleased/pr-1376.v2.yml b/changelog/@unreleased/pr-1376.v2.yml new file mode 100644 index 000000000..a5af29a29 --- /dev/null +++ b/changelog/@unreleased/pr-1376.v2.yml @@ -0,0 +1,16 @@ +type: improvement +improvement: + description: |- + Improve the overall fidelity of JFR profiles and reduce safepoint sampling bias + + Note due to https://bugs.openjdk.org/browse/JDK-8201516 there may still + be potentially small incorrect attribution, but overall this tradeoff is + worth the sampling bias impact. + + See references: + * http://hirt.se/blog/?p=609 + * https://docs.oracle.com/javacomponents/jmc-5-5/jfr-runtime-guide/about.htm#JFRRT111 + * https://psy-lob-saw.blogspot.com/2016/02/why-most-sampling-java-profilers-are.html + * https://jpbempel.github.io/2022/06/22/debug-non-safepoints.html + links: + - https://github.com/palantir/sls-packaging/pull/1376