8000
Skip to content

use a simpler random 2-sampler - #716

Merged
LucioFranco merged 2 commits into
tower-rs:masterfrom
conradludgate:simpler-random-sample
Jan 10, 2023
Merged

use a simpler random 2-sampler#716
LucioFranco merged 2 commits into
tower-rs:masterfrom
conradludgate:simpler-random-sample

Conversation

@conradludgate
@conradludgate conradludgate commented Jan 10, 2023
Copy link
Copy Markdown
Contributor

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

Comment thread tower/src/util/rng.rs
@LucioFranco LucioFranco left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@LucioFranco
LucioFranco merged commit b01bb12 into tower-rs:master Jan 10, 2023
@conradludgate
conradludgate deleted the simpler-random-sample branch January 10, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0