crossbario / autobahn-java

WebSocket & WAMP in Java for Android and Java 8
https://crossbar.io/autobahn
MIT License
1.52k stars 426 forks source link

WebSocket: reuse message byte array instead of recreating #507

Closed om26er closed 4 years ago

om26er commented 4 years ago

This reduces the GC pressure substantially, instead of creating a new byte array for each WebSocket frame, we just reuse the existing one.

This improves performance of websocket tests that send payload in small fragments.

om26er commented 4 years ago

we now only have two failing tests and that now only miss by 10 seconds or so clients.tar.gz

oberstet commented 4 years ago

Great idea to re-run our websocket testsuite!! in an ideal world, we had that as part of the CI of course, but anyways, good! now 9.3.1 and 9.4.1 "fail" because they miss the expected run-time window by 10s? that is "ok". I think the time-windows are hard-coded in the testsuite somewhere - not sure. we could run the websocket compression tests as well - if we wanted to track down issues there ..

oberstet commented 4 years ago

sidenote: such optimizations ("just reuse the existing one") IMO should be extensively documented in the code (maybe even just comment the original one ..) because such stuff can be tricky to understand/notice-at-all later on ..

om26er commented 4 years ago

I added a comment where it was required. The other place that I made the change, is only called once, during the WebSocket handshake.

om26er commented 4 years ago

we could run the websocket compression tests as well - if we wanted to track down issues there ..

Our WebSocket implementation (android) does not support compression, so that won't really help.