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
rt: add rng_seed option to runtime::Builder
#4910
Commits on Aug 12, 2022
-
rt: add rng_seed option to
runtime::Builder
The `tokio::select!` macro polls branches in a random order. While this is desirable in production, for testing purposes a more deterministic approach can be useul. This change adds an additional parameter to the runtime `Builder` to set the random number generator seed. This value is then used to reset the seed on all threads associated with the runtime being built. This guarantees that calls to the `tokio::select!` macro which are performed in the same order on the same thread will poll branches in the same order.
Configuration menu - View commit details
-
Copy full SHA for 01725f9 - Browse repository at this point
Copy the full SHA 01725f9View commit details
Commits on Aug 17, 2022
-
builder accepts RngSeed opaque struct
NOTE: This change doesn't correct the handling of the RngSeed on the thread the runtime is started from, so it's all likely to change. Just pushing for safety. Instead of exposing the width of the seed we're currently using, expose an opaque struct which can generate a seed from a byte slice. Additionally, each thread is given with a unique seed based on its `id` (`worker_thread_index`). This should enable more deterministic behavior, while ensuring that each thread does not begin with the same seed.
Configuration menu - View commit details
-
Copy full SHA for f95a0ee - Browse repository at this point
Copy the full SHA f95a0eeView commit details
Commits on Aug 18, 2022
-
replace thread local RNG on enter guard drop
In order to properly clean up after ourselves, we set a specific seed into the thread local RNG when entering into a runtime context. The previous seed (RNG state) is stored in the `EnterGuard` together with the previous context (runtime handle). Upon dropping the guard, the previously stored seed is returned to the thread local RNG. To achieve this in a deterministic, but fair way, we now store a seed generator in the runtime handle, and another in the blocking thread spawner. These seed generators are thread safe (as the one in the handle may be passed across thread boundries) and will produce a deterministic series of seeds when the initial seed provided to the seed generator is the same.
Configuration menu - View commit details
-
Copy full SHA for dc53f3b - Browse repository at this point
Copy the full SHA dc53f3bView commit details
Commits on Aug 24, 2022
-
Extended the implementation to also seed the random number generator used by workers to pick the initial peer to attempt to steal work from. This change was included in the builder function docs.
Configuration menu - View commit details
-
Copy full SHA for 471f870 - Browse repository at this point
Copy the full SHA 471f870View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3fdff28 - Browse repository at this point
Copy the full SHA 3fdff28View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea633c6 - Browse repository at this point
Copy the full SHA ea633c6View commit details -
Configuration menu - View commit details
-
Copy full SHA for f78c7cc - Browse repository at this point
Copy the full SHA f78c7ccView commit details -
Configuration menu - View commit details
-
Copy full SHA for dbdba4f - Browse repository at this point
Copy the full SHA dbdba4fView commit details
Commits on Aug 25, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 3cd5146 - Browse repository at this point
Copy the full SHA 3cd5146View commit details -
Configuration menu - View commit details
-
Copy full SHA for 5bf557f - Browse repository at this point
Copy the full SHA 5bf557fView commit details
Commits on Sep 1, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 690e067 - Browse repository at this point
Copy the full SHA 690e067View commit details
Commits on Sep 2, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 046c7ba - Browse repository at this point
Copy the full SHA 046c7baView commit details -
Configuration menu - View commit details
-
Copy full SHA for 379dadb - Browse repository at this point
Copy the full SHA 379dadbView commit details
Commits on Sep 6, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 4600701 - Browse repository at this point
Copy the full SHA 4600701View commit details
Commits on Sep 7, 2022
-
Configuration menu - View commit details
-
Copy full SHA for cf50fb2 - Browse repository at this point
Copy the full SHA cf50fb2View commit details -
make
Builder::rng_seed
andRngSeed
unstableIn order to test out the new API before fixing on it, make it unstable first.
Configuration menu - View commit details
-
Copy full SHA for 1ee9c80 - Browse repository at this point
Copy the full SHA 1ee9c80View commit details -
Configuration menu - View commit details
-
Copy full SHA for a2b633c - Browse repository at this point
Copy the full SHA a2b633cView commit details
Commits on Sep 8, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 3f75e30 - Browse repository at this point
Copy the full SHA 3f75e30View commit details -
Configuration menu - View commit details
-
Copy full SHA for e2c97cc - Browse repository at this point
Copy the full SHA e2c97ccView commit details -
make
RngSeed
not public inbuilder
modIt shouldn't have been in the first place.
Configuration menu - View commit details
-
Copy full SHA for 03bbd6b - Browse repository at this point
Copy the full SHA 03bbd6bView commit details -
Configuration menu - View commit details
-
Copy full SHA for 8981f72 - Browse repository at this point
Copy the full SHA 8981f72View commit details
Commits on Sep 15, 2022
-
Configuration menu - View commit details
-
Copy full SHA for 370d9e6 - Browse repository at this point
Copy the full SHA 370d9e6View commit details -
Configuration menu - View commit details
-
Copy full SHA for 3bdbec7 - Browse repository at this point
Copy the full SHA 3bdbec7View commit details -
only allow unreachable_pub when tokio_unstable isn't set
Co-authored-by: Carl Lerche <me@carllerche.com>
Configuration menu - View commit details
-
Copy full SHA for 18ba0b6 - Browse repository at this point
Copy the full SHA 18ba0b6View commit details -
fix comment formatting inside macro
Co-authored-by: Carl Lerche <me@carllerche.com>
Configuration menu - View commit details
-
Copy full SHA for 3482562 - Browse repository at this point
Copy the full SHA 3482562View commit details -
Configuration menu - View commit details
-
Copy full SHA for c1111fc - Browse repository at this point
Copy the full SHA c1111fcView commit details -
Merge branch 'hds/runtime-builder-rng-seed' of github.com:tokio-rs/to…
…kio into hds/runtime-builder-rng-seed
Configuration menu - View commit details
-
Copy full SHA for 68fa544 - Browse repository at this point
Copy the full SHA 68fa544View commit details -
Now that the runtime module is present even without the rt feature.
Configuration menu - View commit details
-
Copy full SHA for 04e2fb4 - Browse repository at this point
Copy the full SHA 04e2fb4View commit details -
Configuration menu - View commit details
-
Copy full SHA for e0c944d - Browse repository at this point
Copy the full SHA e0c944dView commit details
Commits on Sep 16, 2022
-
Configuration menu - View commit details
-
Copy full SHA for c18463c - Browse repository at this point
Copy the full SHA c18463cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7471dc2 - Browse repository at this point
Copy the full SHA 7471dc2View commit details -
Configuration menu - View commit details
-
Copy full SHA for d85e129 - Browse repository at this point
Copy the full SHA d85e129View commit details -
describe conditions for determinism in rng_seed docs
Also fixed a couple of internal comments.
Configuration menu - View commit details
-
Copy full SHA for a04044e - Browse repository at this point
Copy the full SHA a04044eView commit details