Closed stormshield-gt closed 8 months ago
This won't help in our particular case as our underlying streams don't provide an implementation of vectored writes - this is caused by some known issues such as us relying solely on tungstenite-rs
which was written under an assumption that streams implement Read + Write
, instead of providing a sans-io implementation. But once we update the API surface of the tungstenite-rs
, this would certainly be possible!
This is also one of the reasons why alternatives such as fastwebsockets
are more performant.
This could indeed be implemented with future versions of Rust. One needs something like https://rust-lang.github.io/rfcs/1210-impl-specialization.html in order to switch between implementations for different streams. With that, one could implement a simple I/O for generic streams and scatter-gather I/O for less generic ones. With the current version of Rust it is however impossible to use the vectored feature of some advanced streams without losing the possibility to work with any stream that has Read+Write
.
With new write-through API functionality of rustls 0.23 (https://github.com/rustls/rustls/pull/1640), this library can implement
poll_write_vectored
on stream and gain a significant performance boost.Basically, this is the same issue as in tokio-rustls https://github.com/rustls/tokio-rustls/issues/26, which has a current PR to solve it https://github.com/rustls/tokio-rustls/pull/45