Skip to content
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

Document determinism guidelines #19

Open
mcches opened this issue Sep 6, 2022 · 3 comments
Open

Document determinism guidelines #19

mcches opened this issue Sep 6, 2022 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@mcches
Copy link
Contributor

mcches commented Sep 6, 2022

Turmoil is built on the concept of deterministic execution. Using structures such as HashMap initialize with non-deterministic RandomState. Both the internals of turmoil and applications using it need to buy in.

e.g. HashMap, HashSet, tokio::select!, etc.

Document the guidelines.

@mcches
Copy link
Contributor Author

mcches commented Sep 6, 2022

Related: #16

@mcches mcches added the documentation Improvements or additions to documentation label Jan 12, 2023
@dtwitty
Copy link

dtwitty commented Sep 10, 2024

Here are some I ran into in my own testing:

  • Make sure your servers are each using their own RNG seed. Otherwise, they will behave identically and often fail to make progress, elect a leader, etc.
  • Be wary of libraries that might include randomness. For example, many client libraries contain "exponential backoff with random jitter". You'll need to make sure those RNGs are properly seeded.
  • Be wary of hashmaps. Initialize hashmaps with a deterministic hasher, or use ones with deterministic iteration order (indexmap)
    • This one may be hard to accomplish because hashmaps are ubiquitous in library code.

@shikhar
Copy link

shikhar commented Sep 10, 2024

Our experience jives with @dtwitty points. Ultimately overriding certain randomness & time-related libc fns proved necessary to ensure perfect determinism (shared some thoughts here https://x.com/shikhrr/status/1818476801657598128)

To be specific, we override: clock_gettime, getrandom, and getentropy (just uses getrandom). Simply having those symbols defined in DST mode is sufficient to override libc, as noted by the author of madsim here madsim-rs/madsim#159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants