`<random>` Pick a different backing random number engine for `default_random_engine`
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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