From d866fa4c1f3f216f2d4ddab4d2841cf730e07b6f Mon Sep 17 00:00:00 2001 From: Robert Toyonaga Date: Thu, 27 Jun 2024 12:58:19 -0400 Subject: [PATCH] remove duplicate thread sleep events and use a constant clock for JFR chunks --- .../src/com/oracle/svm/core/jfr/JfrTicks.java | 3 ++- .../svm/core/thread/PlatformThreads.java | 18 ++---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java index 0c012bfb21e6..f1d13c66e87d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrTicks.java @@ -26,6 +26,7 @@ import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.util.TimeUtils; +import com.oracle.svm.core.util.PlatformTimeUtils; /** * Utility class to manage ticks for event timestamps based on an initial start point when the @@ -72,6 +73,6 @@ public static long millisToTicks(long millis) { } public static long currentTimeNanos() { - return TimeUtils.millisToNanos(System.currentTimeMillis()); + return PlatformTimeUtils.singleton().nanosNow(); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java index 02b739935554..af15dc896ac9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/PlatformThreads.java @@ -89,7 +89,6 @@ import com.oracle.svm.core.heap.VMOperationInfos; import com.oracle.svm.core.jdk.StackTraceUtils; import com.oracle.svm.core.jdk.UninterruptibleUtils; -import com.oracle.svm.core.jfr.HasJfrSupport; import com.oracle.svm.core.locks.VMMutex; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.memory.NativeMemory; @@ -110,7 +109,6 @@ import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.core.common.SuppressFBWarnings; -import jdk.internal.event.ThreadSleepEvent; import jdk.internal.misc.Unsafe; /** @@ -983,23 +981,11 @@ static void unpark(Thread thread) { } /** - * Sleeps for the given number of nanoseconds, dealing with JFR events, wakups and - * interruptions. + * Sleeps for the given number of nanoseconds, wake-ups and interruptions. */ static void sleep(long nanos) throws InterruptedException { assert !isCurrentThreadVirtual(); - if (HasJfrSupport.get() && ThreadSleepEvent.isTurnedOn()) { - ThreadSleepEvent event = new ThreadSleepEvent(); - try { - event.time = nanos; - event.begin(); - sleep0(nanos); - } finally { - event.commit(); - } - } else { - sleep0(nanos); - } + sleep0(nanos); } /** Sleep for the given number of nanoseconds, dealing with early wakeups and interruptions. */