forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
removes offset > 0 branches from WeightedShuffle implementation
Changing the offset definition to: let offset = (index - 1) & BIT_MASK will avoid all the if offset > 0 { /* ... */ } branches and massively simplifies the implementation. It also improves performance in the benchmarks: On master: test bench_weighted_shuffle_collect ... bench: 150,789.57 ns/iter (+/- 2,123.07) test bench_weighted_shuffle_new ... bench: 33,039.23 ns/iter (+/- 1,696.02) test bench_weighted_shuffle_shuffle ... bench: 140,193.88 ns/iter (+/- 2,739.95) On the branch: test bench_weighted_shuffle_collect ... bench: 145,451.45 ns/iter (+/- 1,307.71) test bench_weighted_shuffle_new ... bench: 30,309.99 ns/iter (+/- 3,577.51) test bench_weighted_shuffle_shuffle ... bench: 136,634.04 ns/iter (+/- 3,124.60)
- Loading branch information
1 parent
47ad9a1
commit b25948f
Showing
1 changed file
with
21 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters