From fcdbf5d4c0987aa13e66dddc72c9a0595d54093a Mon Sep 17 00:00:00 2001 From: Peter Veentjer Date: Wed, 22 Jan 2025 06:41:43 +0200 Subject: [PATCH] Removal of ThreadHints Replaced it by direct call to Thread.onSpinWait. --- .../benchmarks/aeron/ipc/A1BaselineBenchmark.java | 9 ++++----- .../benchmarks/aeron/ipc/AeronExclusiveIpcBenchmark.java | 7 +++---- .../benchmarks/aeron/ipc/AeronIpcBenchmark.java | 7 +++---- .../aeron/ipc/ArrayBlockingQueueBenchmark.java | 9 ++++----- .../aeron/ipc/ConcurrentLinkedQueueBenchmark.java | 9 ++++----- .../benchmarks/aeron/ipc/DisruptorBenchmark.java | 5 ++--- .../aeron/ipc/LinkedBlockingQueueBenchmark.java | 9 ++++----- .../ipc/ManyToOneConcurrentArrayQueueBenchmark.java | 9 ++++----- .../ipc/ManyToOneConcurrentLinkedQueueBenchmark.java | 9 ++++----- .../aeron/ipc/ManyToOneRingBufferBenchmark.java | 7 +++---- 10 files changed, 35 insertions(+), 45 deletions(-) diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/A1BaselineBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/A1BaselineBenchmark.java index b6b49c46..e9a48efb 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/A1BaselineBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/A1BaselineBenchmark.java @@ -16,7 +16,6 @@ package uk.co.real_logic.benchmarks.aeron.ipc; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -72,7 +71,7 @@ public synchronized void setup() break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } else { @@ -82,7 +81,7 @@ public synchronized void setup() final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -146,7 +145,7 @@ private Integer sendBurst(final PerThreadState state) { while (!sendQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -159,7 +158,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronExclusiveIpcBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronExclusiveIpcBenchmark.java index 2df3a589..383268a7 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronExclusiveIpcBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronExclusiveIpcBenchmark.java @@ -29,7 +29,6 @@ import org.agrona.concurrent.IdleStrategy; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; import org.agrona.concurrent.UnsafeBuffer; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -175,7 +174,7 @@ public void onFragment(final DirectBuffer buffer, final int offset, final int le final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(SENTINEL)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -199,7 +198,7 @@ private Integer sendBurst(final PerThreadState state) buffer.putInt(0, value); while (publication.offer(buffer, 0, SIZE_OF_INT) < 0) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -212,7 +211,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronIpcBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronIpcBenchmark.java index 1061aa37..f11e81c4 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronIpcBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/AeronIpcBenchmark.java @@ -29,7 +29,6 @@ import org.agrona.concurrent.IdleStrategy; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; import org.agrona.concurrent.UnsafeBuffer; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -175,7 +174,7 @@ public void onFragment(final DirectBuffer buffer, final int offset, final int le final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(SENTINEL)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -215,7 +214,7 @@ private Integer sendBurst(final PerThreadState state) buffer.putInt(0, value); while (publication.offer(buffer, 0, SIZE_OF_INT) < 0) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -228,7 +227,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ArrayBlockingQueueBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ArrayBlockingQueueBenchmark.java index 8394dbbe..d12a69f6 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ArrayBlockingQueueBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ArrayBlockingQueueBenchmark.java @@ -16,7 +16,6 @@ package uk.co.real_logic.benchmarks.aeron.ipc; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -73,7 +72,7 @@ public synchronized void setup() break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } else { @@ -83,7 +82,7 @@ public synchronized void setup() final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -155,7 +154,7 @@ private Integer sendBurst(final PerThreadState state) { while (!sendQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -168,7 +167,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ConcurrentLinkedQueueBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ConcurrentLinkedQueueBenchmark.java index 25156df6..425acc97 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ConcurrentLinkedQueueBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ConcurrentLinkedQueueBenchmark.java @@ -16,7 +16,6 @@ package uk.co.real_logic.benchmarks.aeron.ipc; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -73,7 +72,7 @@ public synchronized void setup() break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } else { @@ -83,7 +82,7 @@ public synchronized void setup() final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -155,7 +154,7 @@ private Integer sendBurst(final PerThreadState state) { while (!sendQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -168,7 +167,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/DisruptorBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/DisruptorBenchmark.java index 9e29517c..66892dff 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/DisruptorBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/DisruptorBenchmark.java @@ -22,7 +22,6 @@ import com.lmax.disruptor.dsl.Disruptor; import com.lmax.disruptor.dsl.ProducerType; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -131,7 +130,7 @@ public void onEvent(final Message event, final long sequence, final boolean endO final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(SENTINEL)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -206,7 +205,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/LinkedBlockingQueueBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/LinkedBlockingQueueBenchmark.java index b34d4024..22c81d0b 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/LinkedBlockingQueueBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/LinkedBlockingQueueBenchmark.java @@ -16,7 +16,6 @@ package uk.co.real_logic.benchmarks.aeron.ipc; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -73,7 +72,7 @@ public synchronized void setup() break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } else { @@ -83,7 +82,7 @@ public synchronized void setup() final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -155,7 +154,7 @@ private Integer sendBurst(final PerThreadState state) { while (!sendQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -168,7 +167,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentArrayQueueBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentArrayQueueBenchmark.java index 64490c49..47dad0e4 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentArrayQueueBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentArrayQueueBenchmark.java @@ -17,7 +17,6 @@ import org.agrona.concurrent.ManyToOneConcurrentArrayQueue; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -72,7 +71,7 @@ public synchronized void setup() break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } else { @@ -82,7 +81,7 @@ public synchronized void setup() final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -154,7 +153,7 @@ private Integer sendBurst(final PerThreadState state) { while (!sendQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -167,7 +166,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentLinkedQueueBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentLinkedQueueBenchmark.java index f407c3a3..81963258 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentLinkedQueueBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneConcurrentLinkedQueueBenchmark.java @@ -17,7 +17,6 @@ import org.agrona.concurrent.ManyToOneConcurrentLinkedQueue; import org.agrona.concurrent.OneToOneConcurrentArrayQueue; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.util.Arrays; @@ -73,7 +72,7 @@ public synchronized void setup() break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } else { @@ -83,7 +82,7 @@ public synchronized void setup() final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -155,7 +154,7 @@ private Integer sendBurst(final PerThreadState state) { while (!sendQueue.offer(value)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -168,7 +167,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value; diff --git a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneRingBufferBenchmark.java b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneRingBufferBenchmark.java index fd5462bb..3dbec1bd 100644 --- a/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneRingBufferBenchmark.java +++ b/benchmarks-aeron/src/main/java/uk/co/real_logic/benchmarks/aeron/ipc/ManyToOneRingBufferBenchmark.java @@ -23,7 +23,6 @@ import org.agrona.concurrent.ringbuffer.ManyToOneRingBuffer; import org.agrona.concurrent.ringbuffer.RingBuffer; import org.agrona.concurrent.ringbuffer.RingBufferDescriptor; -import org.agrona.hints.ThreadHints; import org.openjdk.jmh.annotations.*; import java.nio.ByteBuffer; @@ -141,7 +140,7 @@ public void onMessage(final int msgTypeId, final MutableDirectBuffer buffer, fin final Queue responseQueue = responseQueues[value]; while (!responseQueue.offer(SENTINEL)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } } @@ -181,7 +180,7 @@ private Integer sendBurst(final PerThreadState state) tempBuffer.putInt(0, value); while (!ringBuffer.write(1, tempBuffer, 0, BitUtil.SIZE_OF_INT)) { - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } } @@ -194,7 +193,7 @@ private Integer sendBurst(final PerThreadState state) break; } - ThreadHints.onSpinWait(); + Thread.onSpinWait(); } return value;