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 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",