Use task local random when initializing LinearMap#4687
Use task local random when initializing LinearMap#4687catamorphism merged 1 commit intorust-lang:incomingfrom
Conversation
Use task local random when initializing LinearMap
|
Thanks! |
|
A note on this: the TLS ISAAC we keep is, itself, a security risk. It does not currently reseed ever after it's constructed. So it's strictly worse than That said, ISAAC is supposedly "as strong" a CPRNG as any other we're likely getting access to via Please be sure to subject all pull requests concerning randomness to extremely detailed review (preferably with multiple reviewers who are solidly familiar with CPRNGs). This sort of thing is very easy to get wrong: most randomness "looks the same". |
|
When I timed Rust's
|
|
Not sure. Reopening. |
Automatic Rustup
I have a project for rust which makes extensive use of hash maps. I recently changed everything over to
LinearMap, and was then profiling some very slow portions of the program.I ended up finding that an absurd amount of time was spent in the
readsyscall, all from invocations of the functionrng::Rng. I found that each time a hash map was created, a new random object was created. To get around this, this change just uses the task local random instead of creating a new one every time.I'm not super familiar with how the hashing algorithm works using these random numbers, so I'm not sure if this would affect the quality of hashing or anything like that. If this does mess up something with that, I imagine that there should still be a faster way of creating a new map?
Regardless, my one test I was running went from a runtime of 1 minute to 12 seconds, to it was a pretty big win in that respect!