Skip to content
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

Draft - io_uring - GSoC 2020 #10356

Closed
wants to merge 106 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
07e2e23
Draft - Add native io_uring transport
1Jo1 Jun 18, 2020
187ec6d
Cleanup
1Jo1 Jun 26, 2020
962a343
Added io_uring JNI
1Jo1 Jun 26, 2020
692238f
Move ring buffer logic to Java
1Jo1 Jul 7, 2020
8a56cd1
Read Event test and documentation
1Jo1 Jul 10, 2020
247e14a
Add channel configs
1Jo1 Jul 15, 2020
339d5f1
Added native unix common module
1Jo1 Jul 16, 2020
8c9b874
First running prototype :tada:
1Jo1 Jul 20, 2020
eb1c8e4
Cleanup
1Jo1 Jul 22, 2020
97b4537
Use socket non-blocking instead of blocking
1Jo1 Jul 27, 2020
df84759
fix bind address exception
1Jo1 Jul 28, 2020
a29b8c5
write all messages
1Jo1 Jul 28, 2020
d3c2814
Cleanup PR
1Jo1 Jul 28, 2020
bc9ada4
Add wakeup and timeout
1Jo1 Aug 4, 2020
71c33ea
Add Poll before the accept/read operation
1Jo1 Aug 10, 2020
bf6a14e
Removed poll before the read event
1Jo1 Aug 18, 2020
1117c6f
io_uring availability check
1Jo1 Aug 20, 2020
8d464d5
Include LinuxSocket TCP options
1Jo1 Aug 24, 2020
96e0e5c
Release timeout memory for scheduled tasks
1Jo1 Aug 24, 2020
0160284
Add abstract stream channel
1Jo1 Aug 24, 2020
d3a0395
Add polling RdHup
1Jo1 Aug 24, 2020
b10b4ca
Add polling POLLOUT
1Jo1 Aug 24, 2020
d9b3f29
Add read exception handling to shutdown channels
1Jo1 Aug 24, 2020
8435c0c
Reproduce error: it hangs itself up in echo test
1Jo1 Aug 24, 2020
b62668d
Fix bug in IOUringEventLoop which may caused eventfd_write to not unb…
normanmaurer Aug 25, 2020
1653099
Correctly calculate timeout for io_uring
normanmaurer Aug 25, 2020
191f0de
Make logging less noisy
normanmaurer Aug 25, 2020
e13cc92
Correctly handle eventfd in io_uring
normanmaurer Aug 25, 2020
9576c93
Remove debugging cruft
normanmaurer Aug 25, 2020
3229d7e
Make use of MPSC queue to reduce overhead
normanmaurer Aug 25, 2020
49449b3
Reduce GC by remove creation of objects related to completion queue a…
normanmaurer Aug 26, 2020
63c4904
Merge pull request #1 from normanmaurer/io-uring-gc
1Jo1 Aug 26, 2020
6ab424f
Fix checkstyle errors
1Jo1 Aug 26, 2020
56ace42
Fix server socket address already in use error even if close is called
1Jo1 Aug 26, 2020
65e8540
Add missing break statement and cleanup
normanmaurer Aug 27, 2020
3cdb1d6
Merge pull request #2 from normanmaurer/io_uring_break
1Jo1 Aug 27, 2020
11e169e
Correctly close ring buffer in tests so we dont leak memory
normanmaurer Aug 27, 2020
9fcd292
Merge pull request #3 from normanmaurer/native_test_close
1Jo1 Aug 27, 2020
8096b2c
Add connect
1Jo1 Aug 27, 2020
15e7f91
Add README
1Jo1 Aug 28, 2020
b863aac
Correctly handle polling
normanmaurer Aug 27, 2020
946dc39
Merge pull request #5 from normanmaurer/polling
1Jo1 Aug 28, 2020
356ce5f
Update README.md
1Jo1 Aug 29, 2020
9a5449a
Poll & tests cleanups
1Jo1 Aug 29, 2020
37944cc
Add writev operation
1Jo1 Aug 29, 2020
f6e6f54
Only need to do syscall if something was submitted
normanmaurer Aug 30, 2020
43fc06e
Merge pull request #6 from normanmaurer/submit
1Jo1 Aug 30, 2020
a358549
Correctly handle POLL*, handle errors, cleanup
normanmaurer Aug 28, 2020
f77aa54
Merge pull request #7 from normanmaurer/iouring_error
1Jo1 Aug 30, 2020
076c35f
Fallback to simple write when we can not allocate iovec array and cor…
normanmaurer Aug 30, 2020
05289a3
Merge pull request #8 from normanmaurer/poll_mask
1Jo1 Aug 31, 2020
2428908
Fixed segmentation fault error in IovecArrayPool
1Jo1 Aug 31, 2020
2820edc
Fixed SubmissionQueue full issue
1Jo1 Aug 31, 2020
e41c68b
Only register for POLLRDHUP when the channel is active and include IU…
normanmaurer Aug 31, 2020
9ddf998
Merge pull request #9 from normanmaurer/io_uring_rdhup
1Jo1 Aug 31, 2020
186b9eb
Correctly release memory for remote address and some code cleanup
normanmaurer Aug 31, 2020
74c0d3d
Merge pull request #10 from normanmaurer/release_memory
1Jo1 Aug 31, 2020
28db67c
Correctly stop reading when AUTO_READ is set to off and also ensure w…
normanmaurer Aug 31, 2020
e1a582d
Merge pull request #11 from normanmaurer/auto_read
1Jo1 Aug 31, 2020
8e5b540
Correctly build up entry for POLL_REMOVE so we find the right operation
normanmaurer Aug 31, 2020
57884e2
Merge pull request #12 from normanmaurer/poll_remove_fix
1Jo1 Aug 31, 2020
663c44c
Correctly respect RecvByteBufAllocator.Handle when reading
normanmaurer Sep 1, 2020
70682b2
Merge pull request #13 from normanmaurer/allochandle_read
1Jo1 Sep 1, 2020
05d8897
Correctly handle POLLRDHUP registration in all cases
normanmaurer Sep 1, 2020
51e20ec
Merge pull request #14 from normanmaurer/rdhup_right_queue
1Jo1 Sep 1, 2020
614323e
Fix failure during accept(...)
normanmaurer Sep 1, 2020
c2a10ef
Merge pull request #15 from normanmaurer/accept_active
1Jo1 Sep 1, 2020
5d7d529
Correctly handle CompositeByteBuf when using IOURING
normanmaurer Sep 1, 2020
bfc51bf
Merge pull request #16 from normanmaurer/composite_fix
1Jo1 Sep 1, 2020
9e6a3d6
Add more tests from the testsuite for io_uring
normanmaurer Sep 1, 2020
75459d7
Merge pull request #17 from normanmaurer/io_uring_tests
1Jo1 Sep 1, 2020
3e8e2cc
Use bitmasking to reduce the number of boolean variables and so save …
normanmaurer Sep 2, 2020
c7f6ba0
Merge pull request #18 from normanmaurer/bitmask
1Jo1 Sep 2, 2020
5423eb9
Fix bug that would case an IllegalStateException when closeForcibly()…
normanmaurer Sep 2, 2020
77a1333
Merge pull request #19 from normanmaurer/close_forcibly
1Jo1 Sep 2, 2020
0a0cc8a
Correctly implement IOUringSubmissionQueue.addTimeout(...) and ensure…
normanmaurer Sep 2, 2020
b4e7f04
Merge pull request #20 from normanmaurer/timeout_fix
1Jo1 Sep 2, 2020
c0ddac2
Correctly obtain localAddress after connect was complete
normanmaurer Sep 2, 2020
44f2cba
Merge pull request #21 from normanmaurer/localaddress_fix
1Jo1 Sep 2, 2020
74fd0c1
Obtain static fields via JNI and not duplicate their values
normanmaurer Sep 2, 2020
47f1996
Remove @Ignore from test
normanmaurer Sep 2, 2020
bcc37d0
Merge pull request #23 from normanmaurer/ignore_removal
1Jo1 Sep 2, 2020
823eaaf
Merge pull request #22 from normanmaurer/static_native
1Jo1 Sep 2, 2020
c0dc26a
Add last missing tests
normanmaurer Sep 2, 2020
66ff2a2
Merge pull request #24 from normanmaurer/missing_tests
1Jo1 Sep 2, 2020
59f77c2
Move initAddress to LinuxSocket JNI
1Jo1 Sep 3, 2020
5691fe8
Fix addTimeout when sqe is full
1Jo1 Sep 3, 2020
f57fcd6
Do support SO_BACKLOG in io_uring
normanmaurer Sep 3, 2020
e1c6f11
Call IOUringEventLoopGroup.shutdownGracefully() after test is done.
normanmaurer Sep 3, 2020
865512d
Merge pull request #26 from normanmaurer/server_config
1Jo1 Sep 3, 2020
a55313e
Merge pull request #27 from normanmaurer/close_group
1Jo1 Sep 3, 2020
1440b4f
Add more missing tests
normanmaurer Sep 3, 2020
3b35976
Fix bug related to reset the RecvByteBufAllocator.Handle on each read
normanmaurer Sep 3, 2020
0631824
Call handle.readComplete() before fireChannlReadComplete() and also c…
normanmaurer Sep 3, 2020
4c29490
Merge pull request #29 from normanmaurer/handle_reset
1Jo1 Sep 3, 2020
9e13c5c
Merge pull request #30 from normanmaurer/handle_complete_cleanup
1Jo1 Sep 4, 2020
6545d80
Submit IO in batches to reduce overhead
normanmaurer Sep 4, 2020
fa7f077
Update SocketGatheringWriteTest.java
normanmaurer Sep 4, 2020
61b8eaf
Update SocketGatheringWriteTest.java
normanmaurer Sep 4, 2020
55460ee
Merge pull request #32 from normanmaurer/submit_batching
1Jo1 Sep 4, 2020
1c42a37
Use IOSQE_ASYNC flag when submitting
normanmaurer Sep 4, 2020
c6db51b
Merge pull request #34 from normanmaurer/iosqe_async
1Jo1 Sep 4, 2020
dfca811
Lookup constants via JNI
normanmaurer Sep 5, 2020
ccd5a6e
Add workaround for current kernel bug related to WRITEV and IOSEQ_ASYNC
normanmaurer Sep 5, 2020
89a2513
Merge pull request #36 from normanmaurer/writev_workaround
1Jo1 Sep 5, 2020
8c465e2
Merge pull request #35 from normanmaurer/jni_constants
1Jo1 Sep 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions common/src/main/java/io/netty/util/internal/PlatformDependent.java
Expand Up @@ -471,6 +471,18 @@ public static <K, V> ConcurrentMap<K, V> newConcurrentHashMap(Map<? extends K, ?
return new ConcurrentHashMap<K, V>(map);
}

public static void loadFence() {
franz1981 marked this conversation as resolved.
Show resolved Hide resolved
PlatformDependent0.loadFence();
}

public static void storeFence() {
PlatformDependent0.storeFence();
}

public static void fullFence() {
PlatformDependent0.fullFence();
}

/**
* Try to deallocate the specified direct {@link ByteBuffer}. Please note this method does nothing if
* the current platform does not support this operation or the specified buffer is not a direct buffer.
Expand Down
Expand Up @@ -597,6 +597,18 @@ static void putObject(Object o, long offset, Object x) {
UNSAFE.putObject(o, offset, x);
}

static void loadFence() {
Copy link

@pveentjer pveentjer Jul 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the Unsafe naming isn't very explanatory. I would either name it

  • loadLoadFence; so you get [LoadLoad]
  • loadAcquireFence, so get [LoadLoad][LoadStore]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah good point, probably we dont need that anymore, currently we use getIntVolatile and putIntOrdered instead,
I could add this as a comment so it's easier to understand 👍

UNSAFE.loadFence();
}

static void storeFence() {
UNSAFE.storeFence();
}

static void fullFence() {
UNSAFE.fullFence();
}
chrisvest marked this conversation as resolved.
Show resolved Hide resolved

static void copyMemory(long srcAddr, long dstAddr, long length) {
// Manual safe-point polling is only needed prior Java9:
// See https://bugs.openjdk.java.net/browse/JDK-8149596
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Expand Up @@ -419,6 +419,7 @@
<module>transport-blockhound-tests</module>
<module>microbench</module>
<module>bom</module>
<module>transport-native-io_uring</module>
1Jo1 marked this conversation as resolved.
Show resolved Hide resolved
</modules>

<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion transport-native-epoll/src/main/c/netty_epoll_native.c
Expand Up @@ -565,7 +565,7 @@ static JNINativeMethod* createDynamicMethodsTable(const char* packagePrefix) {
}
memset(dynamicMethods, 0, size);
memcpy(dynamicMethods, fixed_method_table, sizeof(fixed_method_table));

1Jo1 marked this conversation as resolved.
Show resolved Hide resolved
JNINativeMethod* dynamicMethod = &dynamicMethods[fixed_method_table_size];
NETTY_PREPEND(packagePrefix, "io/netty/channel/epoll/NativeDatagramPacketArray$NativeDatagramPacket;II)I", dynamicTypeName, error);
NETTY_PREPEND("(IZ[L", dynamicTypeName, dynamicMethod->signature, error);
Expand Down