Faster implementation of InputBuffer#214
Conversation
We're also deprecating the usage of `input_buffer` crate, see: snapview/input_buffer#6 (comment)
|
Is there any size limit now? Is it possible to DoS by memory overfull? |
Do you mean those points that I mentioned in (1)? If so, then I think there is no problem with it since the previous limit that we had on the In other words, the new drop-in replacement is probably not perfect (since there is a way to get the panic), but it is at least not worse than the previous implementation. Please correct me if I'm wrong or missed something. However while replying to your comment and checking the unit tests (trying to extend them) I noticed another thing: the new implementation had an issue that it did not clean up the data that is read by the cursor (which normally is not required anymore), so I pushed a new commit that implements a behavior similar to the previous With that step implemented the new |
Faster implementation of `InputBuffer`
Fixes #210.
Please check the discussion and decision if you don't know the context as well as the latest PR in
input_buffer.It seems like the new simplified implementation has only significant difference on x86_64 architecture while the changes on Armv8.4-A A64 (Apple M1) are not that significant as both versions perform really well. On ARM the new version even behaves a bit slower (but not significantly slower), however the difference on Intel (x86_64) architecture is quite significant.
So it seems like migrating to the newer
ReadBuffermakes sense as the 'average performance gain' is quite significant (and I believe most users are still using x86_64).tungstenite-rs. These were removed as they could only occur if the incoming message does not fit into the hardcodedu32::max_value(). Currently we havemax_frame_sizeandmax_message_size, but we don't use them to cap the size of the input/read buffer (instead we compare the values once we read something). This in theory is not a problem when usingtungstenite-rswith non-blocking sockets (like in case oftokio-tungstenite), though it could pose the issue for those ones who use blocking sockets. In other words, the previous reading withu32::max_value()did not really add any sort of "additional protection", so I removed them all together to not complicate theReadBufferimplementation.criterionbenchmarks with our CI. That's fine ascriterionis not meant to be used like this and may give many false positives and false negatives when used like this. In order to automate benchmarking with CI we have to use a tool like lai that was written to be used for such purposes (it works differently thancriterion), but I think it's better to make it as part of a separate PR.P.S.: Thanks @qiujiangkun for bringing this topic and performance testing of
tungstenite-rs👍