GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — IoUring: extend user data from short to long (#16682) · netty/netty@7f00b24

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • transport-classes-io_uring/src/main/java/io/netty/channel/uring
    • AbstractIoUringChannel.java
    • IoUring.java
    • IoUringIoEvent.java
    • IoUringIoHandler.java
    • IoUringIoOps.java
    • PendingOpMap.java
    • UserData.java
  • transport-native-io_uring/src/test/java/io/netty/channel/uring
    • IoUringCustomIoHandleTest.java
    • PendingOpMapTest.java
    • UserDataTest.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringChannel.java‎

Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIoUringChannel.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ public final void handle(IoRegistration registration, IoEvent ioEvent) {
455455
byte op = event.opcode();
456456
int res = event.res();
457457
int flags = event.flags();
458-
short data = event.data();
458+
short data = (short) event.userData();
459459
switch (op) {
460460
case Native.IORING_OP_RECV:
461461
case Native.IORING_OP_ACCEPT:
Collapse file

‎transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUring.java‎

Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUring.java
+17-1Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.netty.channel.ChannelOption;
2020
import io.netty.channel.unix.Buffer;
2121
import io.netty.channel.unix.Limits;
22+
import io.netty.util.internal.MathUtil;
2223
import io.netty.util.internal.PlatformDependent;
2324
import io.netty.util.internal.SystemPropertyUtil;
2425
import io.netty.util.internal.logging.InternalLogger;
@@ -54,6 +55,7 @@ public final class IoUring {
5455
static final int NUM_ELEMENTS_IOVEC;
5556
static final int DEFAULT_RING_SIZE;
5657
static final int DEFAULT_CQ_SIZE;
58+
static final int DEFAULT_PENDING_OPS_INITIAL_CAPACITY;
5759
static final int DISABLE_SETUP_CQ_SIZE = -1;
5860

5961
private static final InternalLogger logger;
@@ -80,6 +82,7 @@ public final class IoUring {
8082
boolean registerBufferRingSupported = false;
8183
boolean registerBufferRingIncSupported = false;
8284
int numElementsIoVec = 10;
85+
int pendingOpsInitialCapacity;
8386

8487
String kernelVersion = "[unknown]";
8588
try {
@@ -178,7 +181,20 @@ public final class IoUring {
178181
NUM_ELEMENTS_IOVEC = numElementsIoVec;
179182

180183
DEFAULT_RING_SIZE = Math.max(16, SystemPropertyUtil.getInt("io.netty.iouring.ringSize", 128));
181-
184+
pendingOpsInitialCapacity = SystemPropertyUtil.getInt(
185+
"io.netty.iouring.pendingOpsInitialCapacity", DEFAULT_RING_SIZE);
186+
if (pendingOpsInitialCapacity <= 0) {
187+
int configuredCapacity = pendingOpsInitialCapacity;
188+
pendingOpsInitialCapacity = MathUtil.safeFindNextPositivePowerOfTwo(DEFAULT_RING_SIZE);
189+
logger.warn("Invalid value {} for -Dio.netty.iouring.pendingOpsInitialCapacity; using {} instead.",
190+
configuredCapacity, pendingOpsInitialCapacity);
191+
} else if (Integer.bitCount(pendingOpsInitialCapacity) != 1) {
192+
int configuredCapacity = pendingOpsInitialCapacity;
193+
pendingOpsInitialCapacity = MathUtil.safeFindNextPositivePowerOfTwo(pendingOpsInitialCapacity);
194+
logger.warn("Rounding -Dio.netty.iouring.pendingOpsInitialCapacity from {} up to {}.",
195+
configuredCapacity, pendingOpsInitialCapacity);
196+
}
197+
DEFAULT_PENDING_OPS_INITIAL_CAPACITY = pendingOpsInitialCapacity;
182198
if (IORING_SETUP_CQ_SIZE_SUPPORTED) {
183199
DEFAULT_CQ_SIZE = Math.max(DEFAULT_RING_SIZE,
184200
SystemPropertyUtil.getInt("io.netty.iouring.cqSize", 4096));
Collapse file

‎transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoEvent.java‎

Copy file name to clipboardExpand all lines: transport-classes-io_uring/src/main/java/io/netty/channel/uring/IoUringIoEvent.java
+31-6Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public final class IoUringIoEvent implements IoEvent {
2828
private byte opcode;
2929
private int res;
3030
private int flags;
31-
private short data;
31+
private long userData;
3232
private ByteBuffer extraCqeData;
3333

3434
/**
@@ -38,20 +38,34 @@ public final class IoUringIoEvent implements IoEvent {
3838
* @param flags the flags
3939
* @param opcode the op code
4040
* @param data the user data that was given as part of the submission.
41+
* @deprecated use {@link #IoUringIoEvent(int,int,byte,long)} instead.
4142
*/
43+
@Deprecated
4244
public IoUringIoEvent(int res, int flags, byte opcode, short data) {
45+
this(res, flags, opcode, (long) data);
46+
}
47+
48+
/**
49+
* Create a new instance
50+
*
51+
* @param res the result.
52+
* @param flags the flags
53+
* @param opcode the op code
54+
* @param userData the user data that was given as part of the submission.
55+
*/
56+
public IoUringIoEvent(int res, int flags, byte opcode, long userData) {
4357
this.res = res;
4458
this.flags = flags;
4559
this.opcode = opcode;
46-
this.data = data;
60+
this.userData = userData;
4761
}
4862

4963
// Used internally to reduce object creation
50-
void update(int res, int flags, byte opcode, short data, ByteBuffer extraCqeData) {
64+
void update(int res, int flags, byte opcode, long userData, ByteBuffer extraCqeData) {
5165
this.res = res;
5266
this.flags = flags;
5367
this.opcode = opcode;
54-
this.data = data;
68+
this.userData = userData;
5569
this.extraCqeData = extraCqeData;
5670
}
5771

@@ -86,9 +100,20 @@ public byte opcode() {
86100
* Returns the data that is passed as part of {@link IoUringIoOps}.
87101
*
88102
* @return data.
103+
* @deprecated use {@link #userData()} instead.
89104
*/
105+
@Deprecated
90106
public short data() {
91-
return data;
107+
return (short) userData;
108+
}
109+
110+
/**
111+
* Returns the user data that was passed as part of the submission.
112+
*
113+
* @return user data.
114+
*/
115+
public long userData() {
116+
return userData;
92117
}
93118

94119
/**
@@ -108,7 +133,7 @@ public String toString() {
108133
"opcode=" + opcode +
109134
", res=" + res +
110135
", flags=" + flags +
111-
", data=" + data +
136+
", userData=" + userData +
112137
'}';
113138
}
114139
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.