-
-
Notifications
You must be signed in to change notification settings - Fork 463
Optimize fill_bytes_via_*
and prepare rand_core 0.1
#397
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
Please ignore for now, I messed things up this morning. |
rand_core/src/impls.rs
Outdated
}; | ||
left.copy_from_slice(&chunk[..n]); | ||
if remainder > 0 { | ||
left.copy_from_slice(&chunk[..remainder]); |
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.
In this case chunk
gets used twice (unless len == 0
).
You also have three conditional jumps, so I'm not sure your code reduction attempt really pays off here?
d436684
to
498778b
Compare
So I had multiple attempts to improve the performance of Got the real one, which is less spectacular but still ~2,5x faster (on both x86 and x86_64).
|
498778b
to
5e4b590
Compare
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.
Okay, this version looks sensible!
I'm not quite sure about the rand-core release; either we just make a 0.1.0-pre.1 for now or we wait a few more days (preferably with separate PR).
rand_core/src/impls.rs
Outdated
l.copy_from_slice(&chunk); | ||
} | ||
let n = left.len(); | ||
if n >= 4 { |
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.
n > 4
?
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.
This is not my day...
8273840
to
19e5187
Compare
I am a bit inpatient for a release to be honest. But I suppose it is also my fault as I keep making changes to I am not really a fan of a second pre-release, but will leave things to you. Should I separate out the version bump from this PR? |
I seem to remember you were not a fan of the 0.5 pre-release either, yet we learned quite a bit since then... Yes, separate the PR then we can merge the first bit and sit on the potential release a couple of days (maybe do that Monday). |
19e5187
to
2bba6f3
Compare
Ok, I reset the version to |
rand_core/README.md
Outdated
@@ -50,6 +50,9 @@ Due to [rust-lang/cargo#1596](https://github.com/rust-lang/cargo/issues/1596), | |||
unioned across the whole dependency tree, any crate using `rand` with its | |||
default features will also enable `std` support in `rand_core`. | |||
|
|||
The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG | |||
implementations that use the `BockRng` or `BlockRng64` wrappers. |
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.
"Bock"!
CHANGELOG.md
Outdated
- Revise the `SeedableRng` trait. (#233) | ||
- Remove default implementations for `RngCore::next_u64` and `RngCore::fill_bytes`. (#288) | ||
- Add `RngCore::try_fill_bytes`. (#225) | ||
- Add `RngCore::bytes_per_round` optimization hint. (#396) |
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.
Not merged yet (and I'm still not convinced about it)
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.
Only reasonable. I've removed this line from both changelogs, lets keep the for that just in #396.
2bba6f3
to
86493ca
Compare
Benchmark before:
After:
I updated the version number, changelog and readme of
rand_core
for a 0.1.0 release. I hope #383 and #396 can me merged first. The date in the changelog is set to 2018-04-15, this Sunday. @dhardy Do you think that is realistic?