-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Save recursive locks on websocket writeFrame #5348
Conversation
are we trying to optimize WebSocket handhsake here ? or fix bug ? |
none of the two; or better, as shown in the jmh benchmarking linked in the description, the vertx pattern to acquire synchronized locks on a field, doesn't really work as expected, after biased locking is gone - and it could be improved by not having nested synchronized blocks |
maybe that is a smell and we should not have a reject method for a WebSocket, i.e any WebSocket processed should be already accepted |
still not clear what it changes , can you clearly describe what is changed and what is the motivation (like in netty) without referring to a quarkus comment ? |
So my understanding of the new I'm not so sure about the
Well, maybe but you can't just remove
I believe that the motivation is to speedup writing messages to a server WebSocket from a non-event loop thread (e.g. from a worker thread) because as stated in the javadoc of |
Yep; for the same purpose of the
Here: https://psy-lob-saw.blogspot.com/2012/12/atomiclazyset-is-performance-win-for.html
Yep, that's the main purpose: the @vietj PTAL |
Vertx is using a nested series of synchronized over the connection field which costs keep on piling-up; this cost is particularly evident while executing writeFrame outside of I/O threads.
https://github.com/franz1981/java-puzzles/blob/583d468a58a6ecaa5e7c7c300895392638f688dd/src/main/java/red/hat/puzzles/concurrent/LockCoarsening.java#L76-L85
contains some microbenchmarks results which show how bad the performance is even in the uncontended case, and it can just become worse under contention.
This is addressing quarkusio/quarkus#39148 (comment)
by removing the nested serie of synchronized over connection, reducing them to the bare minimum i.e. just 2 in the best case scenario