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

rt: add rng_seed option to runtime::Builder #4910

Merged
merged 33 commits into from Sep 16, 2022
Merged

Commits on Aug 12, 2022

  1. 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.
    hds committed Aug 12, 2022
    Configuration menu
    Copy the full SHA
    01725f9 View commit details
    Browse the repository at this point in the history

Commits on Aug 17, 2022

  1. 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.
    hds committed Aug 17, 2022
    Configuration menu
    Copy the full SHA
    f95a0ee View commit details
    Browse the repository at this point in the history

Commits on Aug 18, 2022

  1. 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.
    hds committed Aug 18, 2022
    Configuration menu
    Copy the full SHA
    dc53f3b View commit details
    Browse the repository at this point in the history

Commits on Aug 24, 2022

  1. extended to seed worker RNG

    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.
    hds committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    471f870 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3fdff28 View commit details
    Browse the repository at this point in the history
  3. fix dead code warnings

    hds committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    ea633c6 View commit details
    Browse the repository at this point in the history
  4. fix code fmt

    hds committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    f78c7cc View commit details
    Browse the repository at this point in the history
  5. fix visibility of rand module

    hds committed Aug 24, 2022
    Configuration menu
    Copy the full SHA
    dbdba4f View commit details
    Browse the repository at this point in the history

Commits on Aug 25, 2022

  1. Configuration menu
    Copy the full SHA
    3cd5146 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    5bf557f View commit details
    Browse the repository at this point in the history

Commits on Sep 1, 2022

  1. Configuration menu
    Copy the full SHA
    690e067 View commit details
    Browse the repository at this point in the history

Commits on Sep 2, 2022

  1. Configuration menu
    Copy the full SHA
    046c7ba View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    379dadb View commit details
    Browse the repository at this point in the history

Commits on Sep 6, 2022

  1. Configuration menu
    Copy the full SHA
    4600701 View commit details
    Browse the repository at this point in the history

Commits on Sep 7, 2022

  1. Configuration menu
    Copy the full SHA
    cf50fb2 View commit details
    Browse the repository at this point in the history
  2. make Builder::rng_seed and RngSeed unstable

    In order to test out the new API before fixing on it, make it unstable
    first.
    hds committed Sep 7, 2022
    Configuration menu
    Copy the full SHA
    1ee9c80 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a2b633c View commit details
    Browse the repository at this point in the history

Commits on Sep 8, 2022

  1. Configuration menu
    Copy the full SHA
    3f75e30 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e2c97cc View commit details
    Browse the repository at this point in the history
  3. make RngSeed not public in builder mod

    It shouldn't have been in the first place.
    hds committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    03bbd6b View commit details
    Browse the repository at this point in the history
  4. publish RngSeed from crate::util

    hds committed Sep 8, 2022
    Configuration menu
    Copy the full SHA
    8981f72 View commit details
    Browse the repository at this point in the history

Commits on Sep 15, 2022

  1. Configuration menu
    Copy the full SHA
    370d9e6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3bdbec7 View commit details
    Browse the repository at this point in the history
  3. only allow unreachable_pub when tokio_unstable isn't set

    Co-authored-by: Carl Lerche <me@carllerche.com>
    hds and carllerche committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    18ba0b6 View commit details
    Browse the repository at this point in the history
  4. fix comment formatting inside macro

    Co-authored-by: Carl Lerche <me@carllerche.com>
    hds and carllerche committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    3482562 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    c1111fc View commit details
    Browse the repository at this point in the history
  6. Merge branch 'hds/runtime-builder-rng-seed' of github.com:tokio-rs/to…

    …kio into hds/runtime-builder-rng-seed
    hds committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    68fa544 View commit details
    Browse the repository at this point in the history
  7. fix visibility issues

    Now that the runtime module is present even without the rt feature.
    hds committed Sep 15, 2022
    Configuration menu
    Copy the full SHA
    04e2fb4 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e0c944d View commit details
    Browse the repository at this point in the history

Commits on Sep 16, 2022

  1. next offering to visibility

    hds committed Sep 16, 2022
    Configuration menu
    Copy the full SHA
    c18463c View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7471dc2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d85e129 View commit details
    Browse the repository at this point in the history
  4. describe conditions for determinism in rng_seed docs

    Also fixed a couple of internal comments.
    hds committed Sep 16, 2022
    Configuration menu
    Copy the full SHA
    a04044e View commit details
    Browse the repository at this point in the history