thruster-rs / Thruster

A fast, middleware based, web framework written in Rust
MIT License
1.06k stars 47 forks source link

bug: Remove extra Vec -> Slice -> Vec step #119

Closed trezm closed 5 years ago

trezm commented 5 years ago

Issue: Responses with large amounts of data are pretty slow compared to Actix + Hyper.

Solution: There are a few factors in this, but most of them rely in how we're storing data to send as a response. This PR addresses a single concern where, in BasicContext, we were converting from Vec<u8> to &[u8] to Vec<u8> and back to &[u8]. This should remove the middle two steps.

Future Work: I'd like to be able to have BasicContext modify the response buffer on the fly rather than just when the response is collected. This should minimize the moving of bytes around, which takes about 18% of the computation right now according to the flame graph.

Should help #118.