mikemccand commented on code in PR #15983:
URL: https://github.com/apache/lucene/pull/15983#discussion_r3147024813


##########
build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ProfileResults.java:
##########
@@ -101,10 +101,16 @@ public static void main(String[] args) throws IOException 
{
   }
 
   /** true if we care about this event */
-  static boolean isInteresting(String mode, RecordedEvent event) {
+  static boolean isInteresting(String mode, RecordedEvent event, boolean 
hasCPUTimeSamples) {
     String name = event.getEventType().getName();
     switch (mode) {
       case "cpu":
+        if (hasCPUTimeSamples) {
+          // Prefer jdk.CPUTimeSample (Java 25+, JEP 509): samples by CPU 
time, not wall-clock
+          // time, so idle threads (like gradle epoll) are inherently excluded 
— no filtering
+          // needed. When available, we skip legacy execution samples to avoid 
double-counting.
+          return name.equals("jdk.CPUTimeSample");
+        }
         return (name.equals("jdk.ExecutionSample") || 
name.equals("jdk.NativeMethodSample"))

Review Comment:
   I think `NativeMethodSample` is also a dup, if CPUTime and wall-clock 
sampling are both enabled?



##########
build-tools/build-infra/src/main/java/org/apache/lucene/gradle/plugins/java/ProfileResults.java:
##########
@@ -173,6 +199,11 @@ public static void printReport(
     if (count < 1) {
       throw new IllegalArgumentException("tests.profile.count must be 
positive");
     }
+
+    // Pre-scan to detect if CPU-time samples (Java 25+, JEP 509) are 
available.
+    // If so, prefer them over legacy execution samples to avoid 
double-counting.
+    boolean hasCPUTimeSamples = "cpu".equals(mode) && 
detectCPUTimeSamples(files);

Review Comment:
   Could we make this stricter?  Throw an exception if we see a mix of 
`CPUTime` and legacy events?  Lucene (and in general anyone profiling, hmm 
except maybe profiler debuggers heh) should only have one sampler enabled at a 
time?



##########
gradle/testing/profiling.jfc:
##########
@@ -29,6 +29,11 @@ Collects only execution and method samples at a low interval
     <setting name="period">1 ms</setting>
   </event>
 
+  <event name="jdk.CPUTimeSample">

Review Comment:
   Could we turn off the old (wall-clock) sampling (`jdk.ExecutionSample`, 
`jdk.NativeMethodSample`) and just fully commit to `CPUTime`.  In nightly 
benchmarks we've found the 1 msec sampling to add non-trivial overhead (I think 
~5-7% slower).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to