-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-2578: [Plasma] Use mersenne twister to generate random number #2039
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
@@ Coverage Diff @@
## master #2039 +/- ##
==========================================
+ Coverage 86.28% 87.48% +1.19%
==========================================
Files 11 178 +167
Lines 773 28595 +27822
==========================================
+ Hits 667 25015 +24348
- Misses 106 3580 +3474
Continue to review full report at Codecov.
|
cpp/src/plasma/common.cc
Outdated
| #include <limits> | ||
| #include <mutex> | ||
| #include <random> | ||
| #include <thread> |
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.
Is this still needed?
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.
fixed
cpp/src/plasma/common.cc
Outdated
| static std::mutex mutex; | ||
| std::lock_guard<std::mutex> lock(mutex); | ||
| static std::mt19937 generator; | ||
| std::uniform_int_distribution<uint32_t> d(0, std::numeric_limits<uint8_t>::max()); |
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.
minor, but I'm not a huge fan of the variable name d
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.
fixed
|
+1 merging this now to remove the valgrind testing error |
|
This PR is constructing a generator with a fixed seed, so now distinct processes will trivially collide when generate random ids: |
|
I just saw this and opened a JIRA here: https://issues.apache.org/jira/browse/ARROW-3018 |
This gets rid of the std::random_device, which is slow and causes errors in valgrind. Instead we use the std::mt19937 Mersenne Twister.