-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support jdk.CPUTimeSample event in ProfileResults for Java 25+ (JEP 509) #15983
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
78af0c1
f952eb7
254196d
5125d0e
ed3c9bf
d076437
30d4510
0d78f10
6f2c12f
0e18580
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import java.io.File; | ||
| import java.io.IOException; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import org.apache.lucene.gradle.plugins.LuceneGradlePlugin; | ||
| import org.gradle.api.DefaultTask; | ||
| import org.gradle.api.GradleException; | ||
|
|
@@ -189,7 +190,7 @@ public void apply(Project project) { | |
| task.jvmArgs( | ||
| List.of( | ||
| "-XX:StartFlightRecording=dumponexit=true,maxsize=250M,settings=" | ||
| + gradlePluginResource(project, "testing/profiling.jfc"), | ||
| + gradlePluginResource(project, profilingSettingsPath()), | ||
| "-XX:+UnlockDiagnosticVMOptions", | ||
| "-XX:+DebugNonSafepoints")); | ||
| task.dependsOn(cleanPreviousProfiles); | ||
|
|
@@ -254,4 +255,14 @@ private record ProfilingOptions( | |
| Provider<Integer> countOption, | ||
| Provider<Boolean> lineNumbersOption, | ||
| Provider<Boolean> frametypesOption) {} | ||
|
|
||
| /** | ||
| * JEP 509 CPU-time sampling ({@code jdk.CPUTimeSample}) is implemented on Linux. Use a Linux-only | ||
| * JFR template with CPU-time sampling only; other hosts keep wall-clock execution sampling for | ||
| * short tests. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, it's for all tests, not just short tests right? Maybe just remove
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done. Updated. Thanks! |
||
| */ | ||
| private static String profilingSettingsPath() { | ||
| String os = System.getProperty("os.name", "").toLowerCase(Locale.ROOT); | ||
| return os.contains("linux") ? "testing/profiling.linux.jfc" : "testing/profiling.jfc"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, instead of baking
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, makes sense. Thanks! |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,9 @@ | |
| limitations under the License. | ||
| --> | ||
| <!-- | ||
| Collects only execution and method samples at a low interval | ||
| Wall-clock execution samples for CPU profiling on platforms where JEP 509 CPU-time sampling | ||
| is unavailable (non-Linux). On Linux, CodeProfilingPlugin uses profiling.linux.jfc instead. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my bad, missed it in adding in previous commit. Thanks! |
||
| Heap allocation events are enabled on all platforms. | ||
| --> | ||
| <configuration version="2.0" label="TestProfiling" description="Sampling for unit tests" provider="Apache"> | ||
| <event name="jdk.ExecutionSample"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| Licensed to the Apache Software Foundation (ASF) under one or more | ||
| contributor license agreements. See the NOTICE file distributed with | ||
| this work for additional information regarding copyright ownership. | ||
| The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --> | ||
| <!-- | ||
| Linux: JEP 509 jdk.CPUTimeSample only (no jdk.ExecutionSample / jdk.NativeMethodSample). | ||
| Wall-clock sampling at 1 ms added measurable overhead in long runs; CPU-time sampling keeps | ||
| short tests useful via a 1 ms throttle while avoiding duplicate wall-clock + CPU samplers. | ||
| --> | ||
| <configuration version="2.0" label="TestProfilingLinux" description="CPU-time sampling for unit tests (Linux)" provider="Apache"> | ||
| <event name="jdk.ExecutionSample"> | ||
| <setting name="enabled">false</setting> | ||
| </event> | ||
|
|
||
| <event name="jdk.NativeMethodSample"> | ||
| <setting name="enabled">false</setting> | ||
| </event> | ||
|
|
||
| <event name="jdk.CPUTimeSample"> | ||
| <setting name="enabled">true</setting> | ||
| <setting name="throttle">1 ms</setting> | ||
| </event> | ||
|
|
||
| <event name="jdk.ObjectAllocationInNewTLAB"> | ||
| <setting name="enabled">true</setting> | ||
| <setting name="stackTrace">true</setting> | ||
| </event> | ||
|
|
||
| <event name="jdk.ObjectAllocationOutsideTLAB"> | ||
| <setting name="enabled">true</setting> | ||
| <setting name="stackTrace">true</setting> | ||
| </event> | ||
| </configuration> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -185,6 +185,11 @@ Changes in Runtime Behavior | |
|
|
||
| Build | ||
| --------------------- | ||
| * GITHUB#15926: Support jdk.CPUTimeSample event (Java 25+, JEP 509) in ProfileResults. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we word a bit more user-friendly-y? Maybe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, done. thanks! |
||
| Linux test JVMs use gradle/testing/profiling.linux.jfc (CPU-time sampling only); other hosts | ||
| keep wall-clock jdk.ExecutionSample/jdk.NativeMethodSample. CodeProfilingPlugin selects the | ||
| JFR settings file by host OS. (Prithvi S) | ||
|
|
||
| * GITHUB#15327: New low-level build options to detect abuse of LuceneTestCase.random(): | ||
| tests.random.maxacquires and tests.random.maxcalls (Robert Muir, Dawid Weiss) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
is currently (Java 25) implemented only on Linux, so we use a Linux-only JFR template...?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, updated. Thanks!