-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add random number generation to Runtime
#943
Comments
👋 Thanks for opening this issue! Get help or engage by:
|
|
No, it's not about performance. It's about the ability to run malfunction and correctness tests of the code. You don't have to do anything here, I'll take care of it. Just a heads-up. Maybe I'll do a work-around in our code by instantiating the thread generator manually in the test framework. BTW, shouldn't it use a newly-generated random number for each election? |
OK I see.
I'm not sure if it is necessary. At my POV, a random timeout for each node instead of for each round is good enough. |
Completed by #995 |
Currently,
openraft
is usingrand
crate to generate random numbers and more concretely, thethread_rng()
.Unfortunately, this allocates at suboptimal times, which prevents us from hardening
openraft
in our project.The thread-local random number generator query (and its type) should be added to the runtime interface and implemented by default using
rand
crate.Alternatively, the random number generator should be created in the local state and not in TLS, which would work as well.
Background: TLS with destructors allocate an entry for running the destructor at thread exit in a vector. This allocation cannot be properly masked in our accounting and we get random extra allocation and/or deallocation accounted making memory leak tests fail.
The text was updated successfully, but these errors were encountered: