-
Notifications
You must be signed in to change notification settings - Fork 322
Avoid memory copy in MessagePacker.writePayload #87
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
Conversation
| // Use the source ByteBuffet directly to avoid memory copy | ||
|
|
||
| // First, flush the current buffer contents | ||
| out.flush(buffer, 0, position); |
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.
You can call MessagePacker.flush.
|
I don't have good idea for the threshold. We need to measure the performance. |
|
|
||
| public MessagePacker writePayload(ByteBuffer src) throws IOException { | ||
| if(src.remaining() >= FLUSH_THRESHOLD) { | ||
| // Use the source ByteBuffet directly to avoid memory copy |
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.
(trivial) ByteBuffet -> ByteBuffer
|
👍 |
|
OK. Check the appropriate buffer size later. I filed this issue in #89. |
Avoid memory copy in MessagePacker.writePayload
Improvement based on the discussion #82 (diff).
Currently it uses 512 bytes as threshold for using the input source ByteBuffer/array directly in writePayload. I'm not sure this value is appropriate or not. Any idea on this?