-
-
Notifications
You must be signed in to change notification settings - Fork 15.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate io_uring transport into 4.2 #14045
Conversation
This "version" is a combination of what we had in netty-incubator-transport-native-io_uring and our main branch. The good news is that with this implementation it should be trivial to support things like file IO, as all it would take is to write a Beside this I also want to take another stab on the We should also remove all the methods on the |
transport-classes-io_uring/src/main/java/io/netty/channel/uring/ObjectRing.java
Outdated
Show resolved
Hide resolved
Also in the future we should look into using provided buffers: https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#provided-buffers |
transport-classes-io_uring/src/main/java/io/netty/channel/uring/SubmissionQueue.java
Outdated
Show resolved
Hide resolved
And I think we also should move from |
07e51df
to
e165296
Compare
transport-classes-io_uring/src/main/java/io/netty/channel/uring/IOUringDatagramChannel.java
Outdated
Show resolved
Hide resolved
And before I forget shout out to @axboe for all the help in answering my questions and also for working on future changes for io_uring based on some of my feedback. OSS rocks :) |
* @param data the data | ||
* @return ops. | ||
*/ | ||
public static IOUringIoOps newAsyncCancel(int fd, int flags, long udata, short data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could basically add a method for any OP_
that io_uring supports. I just focused on the ones that we need. At the end people can just construct the IOUringIoOps
themselves. These methods just make things easier the same way as liburing makes things easier compared to use the raw io_uring interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First round seems ok, but wanna run it and see if I am convinced the same :P
Related the dead code, that's why is not yet approved: need to delete quite a few no longer used methods!
For sure :) Keep me posted.
Yes will do more cleanup etc. Just wanted to show something first |
Motivation: We should include our io_uring transport as part of 4.2 Modifications: Add io_uring transport based on our incubator version and main version Result: Fixes #14010
e165296
to
6a3d1ad
Compare
Need to investigate why I see some AssertionError on the CI while I never see it here... |
…bmit that ca used assert error
Nevermind I did mess up while cleanup ... should be fixed now |
@franz1981 @chrisvest I think this is ready to go now. |
I will rename everything from |
283b099
to
56a7dc2
Compare
56a7dc2
to
ea08054
Compare
It's a lot to review, but I'm having a look now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had some comments. Mostly small stuff.
transport-classes-io_uring/src/main/java/io/netty/channel/uring/Native.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/IOUringIoOps.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/IOUringIoOps.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/LinuxSocket.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/SockaddrIn.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/SockaddrIn.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/SockaddrIn.java
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/SockaddrIn.java
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/IOUringServerSocketChannel.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Chris Vest <christianvest_hansen@apple.com>
…make this an implementation detail
@chrisvest addressed and also did some more simplification... PTAL again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to give another round because I see there's some new changes
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/AbstractIOUringChannel.java
Outdated
Show resolved
Hide resolved
if (shutdownOutputFuture.isDone()) { | ||
shutdownOutputDone(shutdownOutputFuture, promise); | ||
} else { | ||
shutdownOutputFuture.addListener(new ChannelFutureListener() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably can find a way to turn these in labmdas too, where it makes sense: personally not super happy because lambdas still put pressure on lambda metafactory, but still...they make the code more succint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we can for sure. It's just what we had in the incubator version so I didn't touch it yet.
assert iovArray == null; | ||
assert writeId == 0; | ||
int numElements = Math.min(in.size(), Limits.IOV_MAX); | ||
ByteBuf iovArrayBuffer = alloc().directBuffer(numElements * IovArray.IOV_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could pool the IovArray
to save netty/netty-incubator-transport-io_uring#154
on the instance and just let it go if we could reuse it, right after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but like you said we can optimize later. Let's get this in first.
transport-classes-io_uring/src/main/java/io/netty/channel/uring/CompletionQueue.java
Outdated
Show resolved
Hide resolved
transport-classes-io_uring/src/main/java/io/netty/channel/uring/CompletionQueue.java
Show resolved
Hide resolved
|
||
// These buffers are used for msghdr, iov, sockaddr_in / sockaddr_in6 when doing recvmsg / sendmsg | ||
// | ||
// TODO: Alternative we could also allocate these everytime from the ByteBufAllocator or we could use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better have an issue for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is existing code that we also have in the incubator version. it is just a copy and paste and we can decide later if we want an issue or not imho.
|
||
@Override | ||
protected void doDisconnect() throws Exception { | ||
// TODO: use io_uring for this too... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as ditto before: better to have an issue, unless closed in this pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again... same as we have in the incubator version. We can create an issue once this is in.
transport-classes-io_uring/src/main/java/io/netty/channel/uring/IOUringIoHandler.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now just minor things, really.
After fixing wht @chrisvest asked for, I'm +100 to get this in, and well done @normanmaurer !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good for this PR.
Thanks a lot for everyone involved! |
Motivation:
We should include our io_uring transport as part of 4.2
Modifications:
Add io_uring transport based on our incubator version and main version
Result:
Fixes #14010