-
Notifications
You must be signed in to change notification settings - Fork 582
Switch to NIO #195
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
Switch to NIO #195
Conversation
WIP Fixes #11
The current limit may be arbitrary right now (depends on the hardware and the scenario). Write as much as possible in the ByteBuffer before clearing it. Fixes #11
Fixes #11
Fixes #11
Limit also written frames to the (snapshot) size when iteration starts (instead of unqueuing during writing). Fixes #11
Use NIO by default (except in SSLTests). Fixes #11
And set number of NIO threads a parameter. Fixes #11
Allows to properly handle the first send header request. Fixes #11
Conflicts: src/main/java/com/rabbitmq/client/impl/ForgivingExceptionHandler.java src/main/java/com/rabbitmq/client/impl/SocketFrameHandler.java
First draft. Fixes #11
Conflicts: src/main/java/com/rabbitmq/client/impl/recovery/AutorecoveringConnection.java
Using ByteBuffer-based streams, to avoid duplicating the frame parsing/write logic. Fixes #11
Fixes #11
Clean some unused code, handle connection and TLS handshake failure, add configuration hook for SocketChannel, create 'use*' methods to activate NIO or blocking IO. Fixes #11
Fixes #11
Fixes #11
This fails CI and no longer merges cleanly. |
Conflicts: src/test/java/com/rabbitmq/examples/PerfTest.java
Fixes #11
This test was initially created to reproduce a transient error during the TLS handshake. It looks like this issue was related to Erlang, introduced in 19.x and fixed in 19.1.1 (http://erlang.org/download/OTP-19.1.1.README). Fixes #11
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.
With this PR I have CPU load hovering around 600% when running mvn verify
. At the end tests begin to fail with java.lang.OutOfMemoryError: unable to create new native thread
. So my guess is that there is a thread instance leak.
The ExecutorService wasn't closed properly in the base test class, there were thus many threads in park state when running the test suite. This could lead to resource exhaustion, especially on MacOS. Fixes #11
On MacOS, SocketChannel.read() can return EOF when the SocketChannel is closed. On Linux, it would throw an exception. This could lead to spinning threads on MacOS, because the NIO loop was never closed. Fixes #11
The default is to use blocking IO. Fixes #11
With the recent EOF handling fix, the CPU/Heap/Threads charts in Visual VM over the course of a test suite run now look nearly identical with the default profile vs. use-nio. This is looking good for inclusion as an opt-in feature for |
static int read(ReadableByteChannel channel, ByteBuffer buffer) throws IOException { | ||
int read = channel.read(buffer); | ||
if(read < 0) { | ||
throw new IOException("Channel has reached EOF"); |
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.
This is confusing. The users will think it has to do with RabbitMQ channels. Please use "Connection has reached EOF" or simply "I/O thread: reached EOF".
public class NioParams { | ||
|
||
/** size of the byte buffer used for inbound data */ | ||
private int readByteBufferSize = 8192; |
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'd bump this and the write buffer here to 32K, it sounds quite reasonable (default TCP buffer size on Linux and OS X is around 100K, for instance).
I observe a couple of test failures in TLS with NIO enabled:
(on OS X) |
And change EOF message, to make it clearer. Fixes #11
The TLS handshake failures are likely to happen with Erlang 19.x. It's been fixed in 19.1.1. These failures are transient, with blocking IO and NIO. |
Yes, that was it. The suite passes with flying colors on 19.1.1. |
Fixes #11