10003 Commits

Author SHA1 Message Date
Josef Grieb
d990b99a6b
Added error handling for io_uring creation failure (#10561)
Motivation:

we should throw a jvm runtime exception for io_uring creation failure to avoid a NullPointerException

Modifications:

-error handling for creation ring fd and mmap io_uring ring buffer
-some cleanups

Result:

better error handling
2020-09-10 16:25:17 +02:00
Nick Hill
90674b4fce
Simplify SQE handling (#10544)
Motivation

SQE handling can be simplified in terms of code and operations
performed

Modifications

- Zero SQE array up front - no need to set never-used fields each time
- Fill SQ array up front with corresponding indicies - no need to set
each time since they are 1-1 with SQE array entries
- Keep local head and tail vars and don't track separate sqe array
head/tail
- Allocate memory for timespec directly (no need for ByteBuffer)
- Avoid some unnecessary casts / type conversions (no need to convert
uints to longs)

Result

Fewer operations, less code
2020-09-10 13:25:34 +02:00
Nick Hill
2316c2ce45
Exploit blocking FAST_POLL for eventfd reads (#10543)
Motivation

If we make eventfd blocking then read can take the place of poll+read

Modification

Make eventfd blocking, use READ instead of POLLIN, allocating a static
64bit buffer to read into

Result

Fewer kernel roundtrips for event loop wakeups
2020-09-10 07:37:39 +02:00
Norman Maurer
d933a9dd56
Move IovArray handling code in an extra class to better seperate it and (#10559)
easier to test.

Motivation:

We should move the IovArray related code to an extra class so its easier
to test

Modifications:

- Move into extra class
- Add dedicated test

Result:

Cleanup
2020-09-09 20:30:48 +02:00
Norman Maurer
dd63d1c8d0
Allow to specify a callback that is executed once submit was called and (#10555)
use it for clearing the IovArrays

Motivation:

IOUringSubmissionQueue may call submit() internally when there is no
space left in the buffer. Once this is done we can reuse for example
IovArrays etc. Because of this its useful to be able to specify a
callback that is executed after submission

Modifications:

- Allow to specify a Runnable that is called once submission was
complete
- Use this callback to clear the IovArrays

Result:

IovArrays are automatically cleared on each submit call.
2020-09-09 17:18:47 +02:00
Norman Maurer
044ec159b9
Only schedule another read if the FD is still open (#10551)
Motivation:

We should only keep on reading if the fd is still open, otherwise we
will produce a confusing exception

Modifications:

check if fd is still open before schedule the read.

Result:

Dont produce a confusing excepion when the fd was closed during a read
loop.
2020-09-09 11:43:46 +02:00
Norman Maurer
8ef5dbc24b
Only execute the close once the already added write operations completes (#10538)
Motivation:

We need to be careful that we only execute the close(...) once the write
operation completes as otherwise we may close the underlying socket too
fast and also the writes

Modifications:

Keep track of if we need to delay the close or not and if so execute it
once the write completes

Result:

No more test failures
2020-09-09 11:42:37 +02:00
Norman Maurer
5ee1f2c7ec
Handle when io_uring_enter(...) fails with EINTR (#10540)
Motivation:

It is possible that io_uring_enter(...) fails with EINTR. In this case
we should just retry the operation

Modifications:

Retry when EINTR was detected

Result:

More correct use of io_uring_enter(...)
2020-09-09 10:05:14 +02:00
Norman Maurer
5bd6611c0e
Explicit need to specify -Piouring-native to compile the native bits … (#10546)
Motivation:

At the moment our CI can not build and run the native bits for the iouring transport so we should just not compile this at the moment. The java classes itself should still be compiled tho

Modifications:

Add explicit profile to compile native bits of iouring

Result:

CI passes with iouring transport
2020-09-09 09:50:36 +02:00
Norman Maurer
7a34f1e6c5
Fix AssertionError caused by incorrect for loop (#10554)
Motivation:

incorrect for loop we could end up with an AssertionError (this is
sometimes triggered during testsuite run)

Modifications:

Fix for loop that calls IovArray.clear()

Result:

No more AssertionError
2020-09-09 09:18:29 +02:00
Norman Maurer
f6474e66de
Use multiple IovArray for writev when using io_uring based transport (#10549)
Motivation:

How we did manage the memory of writev was quite wasteful and could
produce a lot of memory overhead. We can just keep it simple by using
an array of IovArrays. Once these are full we can just submit and clear these as at this
point the kernel did take over a copy and its safe to reuse

Modifications:

Use an array of IovArrays and submit once it is full.

Result:

Less memory overhead and less code duplication
2020-09-08 21:23:38 +02:00
Norman Maurer
47bfcd2e80
Remove workaround for previous io_uring bug related to IOSQE_ASYNC and (#10547)
IOURING_OP_WRITEV

Motivation:

The bug related to IOSQE_ASYNC and IORING_OP_WRITEV was fixed so no need
to have the workaround

Modifications:

Remove workaround

Result:

Use IOSQE_ASYNC all the time
2020-09-08 10:50:41 +02:00
Norman Maurer
9da59c3894
Fix reentrancy bug in io_uring transport implementation related to (#10541)
writes

Motivation:

We need to carefully manage state in terms of writing to guard against
rentrancy problems that could lead to corrupt state in the
ChannelOutboundBuffer

Modifications:

Only reset the flag once removeBytes(...) was called

Result:

No more reentrancy bug related to writes.
2020-09-08 08:43:46 +02:00
Norman Maurer
9b296c8034
Update README to reflect kernel requirements for iouring transport (#10539)
Motivation:

kernel 5.9-rc4 was released that ships all fixes we need

Modifications:

Update readme

Result:

Make it clear what kernel is needed
2020-09-07 12:05:49 +02:00
Norman Maurer
ddb503f76d Fix checkstyle errors 2020-09-07 10:29:41 +02:00
Josef Grieb
8c465e2f1b
Merge pull request #35 from normanmaurer/jni_constants
Lookup constants via JNI
2020-09-05 11:10:08 +02:00
Josef Grieb
89a2513a38
Merge pull request #36 from normanmaurer/writev_workaround
Add workaround for current kernel bug related to WRITEV and IOSEQ_ASYNC
2020-09-05 11:02:54 +02:00
Norman Maurer
ccd5a6e411 Add workaround for current kernel bug related to WRITEV and IOSEQ_ASYNC
Motivation:

There is currently a bug in the kernel that let WRITEV sometimes fail
when IOSEQ_ASYNC is enabled

Modifications:

Don't use IOSEQ_ASYNC for WRITEV for now

Result:

Tests pass
2020-09-05 10:22:02 +02:00
Norman Maurer
dfca811648 Lookup constants via JNI
Motivation:

We should better use JNI to lookup constants so we are sure we not mess
things up

Modifications:

Use JNI calls to lookup constants once

Result:

Less error prone code
2020-09-05 09:40:02 +02:00
Josef Grieb
c6db51ba1f
Merge pull request #34 from normanmaurer/iosqe_async
Use IOSQE_ASYNC flag when submitting
2020-09-04 20:47:39 +02:00
Norman Maurer
1c42a37f67 Use IOSQE_ASYNC flag when submitting
Motivation:

At least in the throughput benchmarks it has shown that IOSQE_ASYNC
gives a lot of performance improvements. Lets enable it by default for
now and maybe make it configurable in the future

Modifications:

Use IOSEQ_ASYNC

Result:

Better performance
2020-09-04 20:22:28 +02:00
Josef Grieb
55460eea2e
Merge pull request #32 from normanmaurer/submit_batching
Submit IO in batches to reduce overhead
2020-09-04 19:10:25 +02:00
Norman Maurer
61b8eaf263
Update SocketGatheringWriteTest.java 2020-09-04 18:04:46 +02:00
Norman Maurer
fa7f07774f
Update SocketGatheringWriteTest.java 2020-09-04 18:04:33 +02:00
Norman Maurer
6545d80d23 Submit IO in batches to reduce overhead
Motivation:

We should submit multiple IO ops at once to reduce the syscall overhead.

Modifications:

- Submit multiple IO ops in batches
- Adjust default ringsize

Result:

Much better performance
2020-09-04 17:09:46 +02:00
Josef Grieb
9e13c5cfd9
Merge pull request #30 from normanmaurer/handle_complete_cleanup
Call handle.readComplete() before fireChannlReadComplete() and also c…
2020-09-04 06:43:20 +02:00
Josef Grieb
4c294908bf
Merge pull request #29 from normanmaurer/handle_reset
Fix bug related to reset the RecvByteBufAllocator.Handle on each read
2020-09-03 21:09:09 +02:00
Norman Maurer
0631824dcd Call handle.readComplete() before fireChannlReadComplete() and also cleanup some code 2020-09-03 18:40:44 +02:00
Norman Maurer
3b35976559 Fix bug related to reset the RecvByteBufAllocator.Handle on each read
Motivation:

We should only reset the RecvByteBufAllocator.Handle when a new "read
loop" starts. Otherwise the handle will not be able to correctly limit
reads.

Modifications:

- Move reset(...) call into pollIn(...)
- Remove all @Ignore

Result:

The whole testsuite passes
2020-09-03 16:14:24 +02:00
Norman Maurer
1440b4fa0c Add more missing tests 2020-09-03 14:51:54 +02:00
Josef Grieb
a55313ed75
Merge pull request #27 from normanmaurer/close_group
Call IOUringEventLoopGroup.shutdownGracefully() after test is done.
2020-09-03 10:15:12 +02:00
Josef Grieb
865512df49
Merge pull request #26 from normanmaurer/server_config
Do support SO_BACKLOG in io_uring
2020-09-03 10:14:35 +02:00
Norman Maurer
e1c6f111f5 Call IOUringEventLoopGroup.shutdownGracefully() after test is done. 2020-09-03 09:47:36 +02:00
Norman Maurer
f57fcd6c4a Do support SO_BACKLOG in io_uring
Motivation:

Due a bug SO_BACKLOG was not supported via ChannelOption when using io_uring. Be

Modification:

- Add SO_BACKLOG to the supported ChannelOptions.
- Merge IOUringServerChannelConfig into IOUringServerSocketChannelConfig

Result:

SO_BACKLOG is supported
2020-09-03 09:40:55 +02:00
Josef Grieb
5691fe8a44 Fix addTimeout when sqe is full
Motivation:

when sqe is full -> no timeout is added to the sqe

Modifications:

it is called submit() to flush the sqe entries to add timeout

Result:
2020-09-03 07:48:58 +02:00
Josef Grieb
59f77c24b9 Move initAddress to LinuxSocket JNI
Motivation:

we should move the initAddress to LinuxSocket JNI as it is only used there

Modifications:

- cleanup
- move initAddress to linux socket JNI

Result:

it's cleaner
2020-09-03 07:22:02 +02:00
Josef Grieb
66ff2a2e23
Merge pull request #24 from normanmaurer/missing_tests
Add last missing tests
2020-09-02 14:46:47 +02:00
Norman Maurer
c0dc26a2f6 Add last missing tests 2020-09-02 14:45:03 +02:00
Josef Grieb
823eaaffb3
Merge pull request #22 from normanmaurer/static_native
Obtain static fields via JNI and not duplicate their values
2020-09-02 14:32:53 +02:00
Josef Grieb
bcc37d078f
Merge pull request #23 from normanmaurer/ignore_removal
Remove @Ignore from test
2020-09-02 14:26:51 +02:00
Norman Maurer
47f199653f Remove @Ignore from test 2020-09-02 14:18:49 +02:00
Norman Maurer
74fd0c1375 Obtain static fields via JNI and not duplicate their values
Motivation:

To ensure we use the correct values when passing values from Java to C and the other way around it is better to use JNI to lookup the values.

Modifications:

Add NativeStaticallyRefererencedJniMethods and use it (just as we do in kqueue / epoll)

Results:

More robust code
2020-09-02 14:14:29 +02:00
Josef Grieb
44f2cba67a
Merge pull request #21 from normanmaurer/localaddress_fix
Correctly obtain localAddress after connect was complete
2020-09-02 10:28:31 +02:00
Norman Maurer
c0ddac2c83 Correctly obtain localAddress after connect was complete
Motivation:

We need to cache the localAddress after the connect was complete

Modifications:

- Call socket.localAddress() after the connect was complete
- Enable test again

Result:

Correctly set localAddress after connect was successful
2020-09-02 10:25:03 +02:00
Josef Grieb
b4e7f046d5
Merge pull request #20 from normanmaurer/timeout_fix
Correctly implement IOUringSubmissionQueue.addTimeout(...) and ensure…
2020-09-02 10:21:23 +02:00
Norman Maurer
0a0cc8a7c0 Correctly implement IOUringSubmissionQueue.addTimeout(...) and ensure we always call runAllTasks()
Motivation:

We did have a bug in how we calculated the values for the timespec which lead to incorrect wakeups. Beside this we also missed to always call runAllTasks() which is needed to fetch the ready to be executed scheduled tasks.

Modifications:

- Fix timespec setup
- Always call runAllTasks()
- Add extra testcase
- Remove @Ignore from previous failing test

Result:

Timeouts work as expected
2020-09-02 10:16:26 +02:00
Josef Grieb
77a133344f
Merge pull request #19 from normanmaurer/close_forcibly
Fix bug that would case an IllegalStateException when closeForcibly()…
2020-09-02 09:27:01 +02:00
Norman Maurer
5423eb9401 Fix bug that would case an IllegalStateException when closeForcibly() is called and the Channel is not registered yet. 2020-09-02 09:25:27 +02:00
Josef Grieb
c7f6ba0a55
Merge pull request #18 from normanmaurer/bitmask
Use bitmasking to reduce the number of boolean variables and so save …
2020-09-02 09:23:10 +02:00
Norman Maurer
3e8e2cc0eb Use bitmasking to reduce the number of boolean variables and so save some memory per instance 2020-09-02 09:16:26 +02:00