-
-
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
maxBytesPerRead channel configuration #3885
Conversation
@trustin - Would you mind reviewing this one? |
1bd0235
to
e818942
Compare
} else if (option == MAX_BYTES_PER_READ_PAIR) { | ||
@SuppressWarnings("unchecked") | ||
Entry<Integer, Integer> pair = (Entry<Integer, Integer>) value; | ||
setMaxBytesPerReadPair(pair.getKey(), pair.getValue()); |
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 something similar can be done to resolve #3806.
e818942
to
f18f70a
Compare
* A DNS client that queries a server and checks if query information and | ||
* responses are valid to ensure codec is correct. | ||
*/ | ||
package io.netty.handler.codec.dns; |
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.
???
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.
Maybe doesn't belong in this PR, but this is a duplicate of the package-info.java
in the main
directory tree. Was (and has been) causing an issue in eclipse IDE for quite some time now...resolved to make "real" errors I introduced during interface updates easier to see.
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.
Ah, nevermind, then.
@Scottmitch Sorry for a delay. Will review some time this week. |
@netkins build |
@trustin - Bump. |
Do the new configuration properties work only when the |
a22a712
to
c184d89
Compare
Yes. Currently |
@trustin - Another thing to consider is moving these configuration options from RecvByteBufAllocator recvAlloc = channel.config().getRecvByteBufAllocator();
if (recvAlloc instanceof MaxBytesRecvByteBufAllocator) {
MaxBytesRecvByteBufAllocator maxRecvAlloc = (MaxBytesRecvByteBufAllocator) recvAlloc;
maxRecvAlloc.setMaxMessagesPerRead(...);
maxRecvAlloc.setMaxBytesPerIndividualRead(...);
} else if (recvAlloc instanceof ...) {
} At least you can be sure what your are setting will actually be respected though... |
Sounds good to me!
Yeah, how about using the type parameter for the return type for loose typing to lessen the burden? interface ChannelConfig {
<T extends RecvByteBufAllocator> T getRecvByteBufAllocator();
}
MaxBytesRecvByteBufAllocator alloc = ch.config().getRecvByteBufAllocator();
... This won't work when a user is not sure about the type of the current |
@trustin - Thanks for the feedback. I will move forward with these updates and ping you when ready. |
6b8da06
to
ebcdd88
Compare
@@ -184,8 +185,8 @@ protected int doReadMessages(List<Object> msgs) throws Exception { | |||
|
|||
Set<SelectionKey> reableKeys = readSelector.selectedKeys(); | |||
try { | |||
for (SelectionKey ignored : reableKeys) { | |||
RecvByteBufAllocator.Handle allocHandle = unsafe().recvBufAllocHandle(); | |||
for (@SuppressWarnings("unused") SelectionKey ignored : reableKeys) { |
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.
Not sure why this loop is necessary...see #3884
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'm not sure, either. Could you explain, @jestan ?
ebcdd88
to
84b48da
Compare
@trustin @normanmaurer - PTAL. |
84b48da
to
ac6ae58
Compare
@Scottmitch LGTM. @normanmaurer, any comments? |
@@ -58,11 +58,6 @@ | |||
|
|||
return true; | |||
} | |||
@Override | |||
public EpollDomainSocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead) { |
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'm right that we only want this for 4.1 and master ?
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. #3885 (comment).
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'm still not 100 % convinced that we can do this change in 4.1 in terms of API breakage. @trustin WDYT ?
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.
@normanmaurer Yeah, we can't just remove it. How about deprecating it and delegate to Max*Allocator
if the current recv allocator is of compatible type, or throw an exception if it's incompatible?
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.
@trustin @normanmaurer - Done.
@Scottmitch a few more comments and questions. Good work! |
ac6ae58
to
763639f
Compare
@trustin - I would like to merge this but there are just a few followup discussion items above. Would you mind weighing in? |
a4576f8
to
cbdc931
Compare
@trustin @normanmaurer - PTAL. |
cbdc931
to
d97560e
Compare
if (metadata == null) { | ||
throw new NullPointerException("metadata"); | ||
} | ||
MaxMessagesRecvByteBufAllocator maxMsgAllocator = (MaxMessagesRecvByteBufAllocator) allocator; |
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.
@trustin - This is how I am preserving the 16 max messages for ServerSockets
/NioByteStream
and 1 max message otherwise. WDYT?
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.
LGTM. Thank you for your patience.
d97560e
to
749f614
Compare
@trustin - Nvm...forgot about changes to |
Motiviation: The current read loops don't fascilitate reading a maximum amount of bytes. This capability is useful to have more fine grain control over how much data is injested. Modifications: - Add a setMaxBytesPerRead(int) and getMaxBytesPerRead() to ChannelConfig - Add a setMaxBytesPerIndividualRead(int) and getMaxBytesPerIndividualRead to ChannelConfig - Add methods to RecvByteBufAllocator so that a pluggable scheme can be used to control the behavior of the read loop. - Modify read loop for all transport types to respect the new RecvByteBufAllocator API Result: The ability to control how many bytes are read for each read operation/loop, and a more extensible read loop.
749f614
to
f473dcb
Compare
Ran some quick perf tests on the before and after for this PR just to make sure there was no regression, and things look good (using NIO): before
this PR
|
👍 |
Motiviation:
The current read loops don't fascilitate reading a maximum amount of bytes. This capability is useful to have more fine grain control over how much data is injested.
Modifications:
Result:
The ability to control how many bytes are read for each read operation/loop, and a more extensible read loop.