rust-random / rust-random/rand

Add SmallThreadRng

Open
#1,781 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.1k
Forks
512
Avg merge
3d 9h
Merged PRs (30d)
7

Description

Background

What is your motivation?
Same use case as ThreadRng serves today, but something that is faster than ThreadRng while sacrificing crystallographic security.

What type of application is this? (E.g. cryptography, game, numerical simulation)
Simple stuff like a randomized log sampler. Using rand::small_random() is much easier than

thread_local! {
    static RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_rng(&mut rand::rng()));
}

fn should_emit() -> {
   RNG.with_borrow_mut(|rng| rng.random_ratio(1, 1000)
}

Feature request

Create a type called SmallThreadRng that internally uses same rng as SmallRng.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing ThreadRng and SmallRng implementations and the rand::small_random() API. Trace how ThreadRng exposes its thread-local generator, then determine how SmallThreadRng should provide the same usage pattern while using SmallRng internally. Done means the new type is available and behaves as the requested faster, non-cryptographic thread-local generator.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.