summaryrefslogtreecommitdiffhomepage
path: root/util/rands
AgeCommit message (Collapse)AuthorFilesLines
2024-06-05wgengine/magicsock: use math/rands/v2Maisem Ali1-0/+8
Updates #11058 Co-authored-by: James Tucker <james@tailscale.com> Signed-off-by: Maisem Ali <maisem@tailscale.com>
2024-02-09util/rands: add Shuffle and Perm functions with on-stack RNG stateJames Tucker2-0/+178
The new math/rand/v2 package includes an m-local global random number generator that can not be reseeded by the user, which is suitable for most uses without the RNG pools we have in a number of areas of the code base. The new API still does not have an allocation-free way of performing a seeded operations, due to the long term compiler bug around interface parameter escapes, and the Source interface. This change introduces the two APIs that math/rand/v2 can not yet replace efficiently: seeded Perm() and Shuffle() operations. This implementation chooses to use the PCG random source from math/rand/v2, as with sufficient compiler optimization, this source should boil down to only two on-stack registers for random state under ideal conditions. Updates #17243 Signed-off-by: James Tucker <james@tailscale.com>
2023-09-05util/rands: add package with HexString funcBrad Fitzpatrick2-0/+40
We use it a number of places in different repos. Might as well make one. Another use is coming. Updates #cleanup Change-Id: Ib7ce38de0db35af998171edee81ca875102349a4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>