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

Issue #6566 - add executor to WebSocketComponents & use for Dispatched Messages #6585

Merged
merged 5 commits into from
Aug 5, 2021

Conversation

lachlan-roberts
Copy link
Contributor

Issue #6566

Use an executor to dispatch new threads for InputStream or Reader type messages.

This doesn't fix #6566 as that issue was also reproduced using the onMessage(ByteBuffer) style methods. But this should still offer some improvement for dispatched messages.

gregw
gregw previously approved these changes Aug 4, 2021
@lachlan-roberts lachlan-roberts requested a review from gregw August 5, 2021 01:02
Comment on lines +61 to +70
if (executor == null)
{
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("WebSocket@" + hashCode());
_executor = threadPool;
}
else
{
_executor = executor;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are breaking out like this, then you may as well do:

Suggested change
if (executor == null)
{
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("WebSocket@" + hashCode());
_executor = threadPool;
}
else
{
_executor = executor;
}
if (executor == null)
{
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setName("WebSocket@" + hashCode());
_executor = threadPool;
addBean(_executor, true);
}
else
{
_executor = executor;
addBean(_executor, false);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm but then all the other beans are managed differently..... I still don't like how the management decision is made external to this class... but I'll live with it in this PR. But do think about fixing it sometime.

@lachlan-roberts lachlan-roberts merged commit 8de7d55 into jetty-10.0.x Aug 5, 2021
@lachlan-roberts lachlan-roberts deleted the jetty-10.0.x-6566-WebSocketExecutor branch August 5, 2021 05:38
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

Successfully merging this pull request may close these issues.

High CPU use due to new thread created on every websocket message in DispatchedMessageSink
2 participants