microsoft / microsoft/STL

`<random>` Pick a different backing random number engine for `default_random_engine`

Open
#4,257 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

vNext
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

Currently it is alias for mt19937. mt19937 is not a bad generator on its own, but it is not a good default. The reason is that MTs are excessively large, so sizeof(default_random_engine) == 5000 right now. This is much larger than the user would reasonably expect, for comparison, xoshiro fits into 16-32 bytes, PCG usually fits into 8-16, common LCGs will be 8. WELLs can be as large as MTs, but there are also reasonably sized variants at 32 bytes.

The choice of default_random_engine also has knock-on effects beyond just the direct users, e.g. the simple random utilities wanted to use a thread-local instance of default_random_engine, but that means shoving 5k objects into the TLS. As I understand it, there is nothing really blocking that, but it is not great.

Contributor guide

Open the contributing guide

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

The issue names default_random_engine, mt19937, and the simple random utilities, but no source file or test. Start by locating the default_random_engine definition and its uses, then review the available backing-engine choices and their object sizes. Done means selecting and implementing a smaller default engine while accounting for the thread-local use described in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.