tower-rs / tower

async fn(Request) -> Result<Response, Error>
https://docs.rs/tower
MIT License
3.56k stars 281 forks source link

use a simpler random 2-sampler #716

Closed conradludgate closed 1 year ago

conradludgate commented 1 year ago

While this only saves 40ns (70ns down to 30ns - probably more if there are other threads causing allocator contention) per sample, I still think it makes sense to not allocate here.

This was the only use of sample_inplace in this codebase. I also have an impl that scales to higher amounts, but it uses const generics which won't fit in the current MSRV