-
Notifications
You must be signed in to change notification settings - Fork 802
chore(accounts-db): switch to rand=0.9.2 and rand_chacha=0.9 (dev dependency) #9020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9020 +/- ##
=======================================
Coverage 81.9% 81.9%
=======================================
Files 862 862
Lines 326917 326916 -1
=======================================
+ Hits 267789 267852 +63
+ Misses 59128 59064 -64 🚀 New features to boost your workflow:
|
brooksprumo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me. Thanks for doing this!
accounts-db/benches/accounts.rs
Outdated
|
|
||
| use rand::prelude::*; | ||
| let mut rng = rand_chacha::ChaCha8Rng::seed_from_u64(1234); | ||
| let mut rng = StdRng::seed_from_u64(1234); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.rs/rand/latest/rand/rngs/struct.StdRng.html indicates that StdRng is non-portable1 and suggests using rand_chacha instead.
Footnotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, meaning it could generate different values for the same seed between platforms and minor releases. Do you think it could spoil the long-term comparisons on the test / benchmark results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it could spoil the long-term comparisons on the test / benchmark results?
For the benchmarks, yeah. For the test, probably not, but may depend on the test.
I think this PR should be more narrowly focused on just upgrading rand to 0.9, and thus leaving the chacha parts as-is (since there's potential behavior changes when removing chacha).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There wee some version conflicts, so it might require updating rand_chacha or other crates versions thus actually expanding the scope of the PR, let me check again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, since rand and rand_chacha come from the same repo and are coupled closerly (depend on rand_core), just moving that one to 0.9.0 version solved the issue and the diff is cleaner now.
HaoranYi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
4085cb2 to
c71bb7e
Compare
brooksprumo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Use SmallRng as it's faster than the default ChaCha and we don't | ||
| // need a crypto rng here. | ||
| let mut rng = SmallRng::from_entropy(); | ||
| let mut rng = SmallRng::from_os_rng(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
From https://rust-random.github.io/book/update-0.9.html:
fn from_entropy was renamed to from_os_rng along with a new fallible variant, fn try_from_os_rng
Problem
randcrate with version >=0.9 fixes problem withgenfunction name colliding with keyword reserved in Rust 2024 edition (it doesn't strictly block Upgrade rust edition to 2024 #6203, but seems like a better way to hit two birds with one stone)randDue to the last point we might be better off with updating rand incrementally (compare with previous attempt of upgrading in #4721).
Summary of Changes
rand0.9.2rand_chachato 0.9.0 (closely coupled withrand, they both rely on same version ofrand_core)Performance
randis mostly used in tests, comparison of their runtime: