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

WebSocket MessageInputStream.read() spends a lot of time in ByteBuffer.compact() #6166

Closed
lachlan-roberts opened this issue Apr 13, 2021 · 1 comment
Assignees

Comments

@lachlan-roberts
Copy link
Contributor

Jetty version
10.0.2

Description
Originally reported by @dcitron in issue #6127.

I did notice that org.eclipse.jetty.websocket.core.internal.messages.MessageInputStream.read() is taking a larger percentage of time in Jetty 10 than Jetty 9. In Jetty 9 it kicked around in java.nio.Buffer.hasRemaining() a bit, but in Jetty 10 it's taking quite a bit of time in the following call stack:

MessageInputStream.read() 
    -> org.eclipse.jetty.util.BufferUtil.append() 
         -> org.eclipse.jetty.util.BufferUtil.flipToFill() 
              -> java.nio.HeapByteBuffer.compact()

In a simple test that I ran, processing 1,000 messages, it actually seemed to spend 24% of its time in HeapByteBuffer.compact() so maybe that's something you might want to look into further, or maybe it's just a memory-vs-CPU tradeoff.

@lachlan-roberts
Copy link
Contributor Author

This is fixed by #6170.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant