Skip to content

Commit

Permalink
Upgrade JCTools to 4.0.1 (#12788)
Browse files Browse the repository at this point in the history
Motivation:
The new JCTools include the ability to use unpadded queues, which is useful for our LocalChannel.

Modification:
Upgrade our JCTools dependency and make LocalChannel use an unpadded queue to save a small amount of memory.

Result:
Updated dependencies.
  • Loading branch information
chrisvest committed Sep 10, 2022
1 parent e346b4c commit cd6a80d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
import org.jctools.queues.MpscArrayQueue;
import org.jctools.queues.MpscChunkedArrayQueue;
import org.jctools.queues.MpscUnboundedArrayQueue;
import org.jctools.queues.SpscLinkedQueue;
import org.jctools.queues.atomic.MpscAtomicArrayQueue;
import org.jctools.queues.atomic.MpscChunkedAtomicArrayQueue;
import org.jctools.queues.atomic.MpscUnboundedAtomicArrayQueue;
import org.jctools.queues.atomic.SpscLinkedAtomicQueue;
import org.jctools.queues.unpadded.SpscLinkedUnpaddedQueue;
import org.jctools.util.Pow2;
import org.jctools.util.UnsafeAccess;

Expand Down Expand Up @@ -946,9 +946,6 @@ public static int hashCodeAscii(CharSequence bytes) {
private static final class Mpsc {
private static final boolean USE_MPSC_CHUNKED_ARRAY_QUEUE;

private Mpsc() {
}

static {
Object unsafe = null;
if (hasUnsafe()) {
Expand Down Expand Up @@ -1020,7 +1017,7 @@ public static <T> Queue<T> newMpscQueue(final int chunkSize, final int maxCapaci
* consumer (one thread!).
*/
public static <T> Queue<T> newSpscQueue() {
return hasUnsafe() ? new SpscLinkedQueue<>() : new SpscLinkedAtomicQueue<>();
return hasUnsafe() ? new SpscLinkedUnpaddedQueue<>() : new SpscLinkedAtomicQueue<>();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
<dependency>
<groupId>org.jctools</groupId>
<artifactId>jctools-core</artifactId>
<version>3.1.0</version>
<version>4.0.1</version>
</dependency>

<!-- Annotations for IDE integration and analysis -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public class LocalChannel extends AbstractChannel<LocalServerChannel, LocalAddre

private enum State { OPEN, BOUND, CONNECTED, CLOSED }

// To further optimize this we could write our own SPSC queue.
final Queue<Object> inboundBuffer = PlatformDependent.newSpscQueue();
private final Runnable readNowTask = () -> {
// Ensure the inboundBuffer is not empty as readInbound() will always call fireChannelReadComplete()
Expand Down

0 comments on commit cd6a80d

Please sign in to comment.