Conversation
As discussed in #26, the changes in go1.21 will remove rand contention when the (now deprecated) rand.Seed() is not called. In order to check if this brings performance parity, start to benchmark both Pick and PickSource functions in parallel, and no longer rand.Seed in test init.
Owner
Author
|
Benchmarks using above commit, showing On go1.21, the difference mostly negligible (some minor noise in the tests here due to running on laptop): Direct comparison of go1.20 to go1.21: |
Owner
Author
|
A search of the dependents for this module reveal that many who use There is still a potential valid use case for wanting to provide a custom randomness source, but would rather get it out of the API for now, and revisit if it can be done a more elegant way with the proposed |
results on my Apple M2 Pro laptop:
$ make analysis
benchstat -filter=".name:Multiple" -col="/lib" -row="/size" -table="/concurrency" results.txt
/concurrency: single
│ randutil │ weightedrand │
│ sec/op │ sec/op vs base │
1e1 455.70n ± 0% 19.16n ± 2% -95.80% (p=0.000 n=10)
1e2 438.20n ± 0% 32.81n ± 0% -92.51% (p=0.000 n=10)
1e3 1179.00n ± 0% 46.00n ± 0% -96.10% (p=0.000 n=10)
1e4 6591.00n ± 1% 60.34n ± 0% -99.08% (p=0.000 n=10)
1e5 61188.00n ± 0% 84.83n ± 0% -99.86% (p=0.000 n=10)
1e6 631928.5n ± 1% 112.6n ± 2% -99.98% (p=0.000 n=10)
1e7 6402254.0n ± 1% 240.7n ± 0% -100.00% (p=0.000 n=10)
geomean 16.84µ 63.16n -99.62%
/concurrency: parallel
│ randutil │ weightedrand │
│ sec/op │ sec/op vs base │
1e1 589.300n ± 0% 2.026n ± 1% -99.66% (p=0.000 n=10)
1e2 490.000n ± 0% 3.337n ± 1% -99.32% (p=0.000 n=10)
1e3 766.500n ± 0% 4.518n ± 1% -99.41% (p=0.000 n=10)
1e4 808.700n ± 0% 5.951n ± 2% -99.26% (p=0.000 n=10)
1e5 6438.500n ± 1% 8.184n ± 1% -99.87% (p=0.000 n=10)
1e6 108285.50n ± 1% 12.00n ± 1% -99.99% (p=0.000 n=10)
1e7 2011263.00n ± 2% 28.95n ± 1% -100.00% (p=0.000 n=10)
geomean 5.907µ 6.548n -99.89%
key-value format is nicer for later filtering in benchstat
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Work in progress
Fixes #26