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 #6328 - avoid binding WebSocket MethodHandles #12181

Merged
merged 5 commits into from
Aug 26, 2024

Conversation

lachlan-roberts
Copy link
Contributor

Use a new MethodHolder interface so that implementations can be used which avoid binding the MethodHandles for each WebSocket connection. This will avoid the multiple spikes seen on the flamegraph from #6328.

*/
public interface MethodHolder
{
String METHOD_HOLDER_BINDING_PROPERTY = "jetty.websocket.methodholder.binding";
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than system property configuration, could this be done as a LOG.isDebugEnabled instead? The primary motivation for using this mode is to make flame graphs look better, so it is a kind of logging? @sbordet thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its hard to define a logger in the interface because it will need to be public and then I think we need to export it with JPMS.

@@ -51,9 +51,9 @@ public abstract class DispatchedMessageSink extends AbstractMessageSink
private volatile CompletableFuture<Void> dispatchComplete;
private MessageSink typeSink;

public DispatchedMessageSink(CoreSession session, MethodHandle methodHandle, boolean autoDemand)
public DispatchedMessageSink(CoreSession session, MethodHolder methodHolder, boolean autoDemand)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to provide all the old APIs deprecated?

Suggested change
public DispatchedMessageSink(CoreSession session, MethodHolder methodHolder, boolean autoDemand)
@Deprecated
public DispatchedMessageSink(CoreSession session, MethodHandle methodHandle, boolean autoDemand)
{
this(session, MethodHolder.from(methodHandle), autoDemand);
}
public DispatchedMessageSink(CoreSession session, MethodHolder methodHolder, boolean autoDemand)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so, this is websocket-core, and this is really not supposed to be used by the application more of an implementation class.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah but it is public and not internal.... @sbordet thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this probably should be internal.

Its to reduce having code duplication from having this in our jakarta and jetty websocket implementations. But making it internal makes things difficult with JPMS.

But there is no API to actually use a MessageSink directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, leave out and we can add back deprecated if anybody complains.... although it is against our new deprecated policy :)

@lachlan-roberts lachlan-roberts force-pushed the jetty-12.1.x-websocketMethodHolder branch from ba97660 to e923380 Compare August 22, 2024 03:06
@lachlan-roberts lachlan-roberts requested a review from gregw August 22, 2024 06:36
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

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

Let's get this merged and review configuration later!

@lachlan-roberts lachlan-roberts merged commit c0d5adf into jetty-12.1.x Aug 26, 2024
4 of 9 checks passed
@lachlan-roberts lachlan-roberts deleted the jetty-12.1.x-websocketMethodHolder branch August 26, 2024 01:04
@olamy olamy mentioned this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants