tailscale/util
James Tucker 24bac27632 util/rands: add Shuffle and Perm functions with on-stack RNG state
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>
2024-02-09 15:19:27 -08:00
..
cache util/cache: add package for general-purpose caching 2023-12-07 18:19:38 -05:00
cibuild all: update copyright and license headers 2023-01-27 15:36:29 -08:00
clientmetric util/clientmetric: allow client metric values to be provided by a function 2023-04-05 17:21:16 -07:00
cloudenv all: update copyright and license headers 2023-01-27 15:36:29 -08:00
cmpver util/cmpver: only consider ascii numerals (#9741) 2023-10-11 13:42:32 +01:00
codegen util/codegen: support embedded fields 2023-05-09 15:40:17 -07:00
cstruct all: update copyright and license headers 2023-01-27 15:36:29 -08:00
ctxkey all: use reflect.TypeFor now available in Go 1.22 (#11078) 2024-02-08 17:34:22 -08:00
deephash all: use reflect.TypeFor now available in Go 1.22 (#11078) 2024-02-08 17:34:22 -08:00
dirwalk all: use tstest.Replace more 2023-03-04 12:24:55 -08:00
dnsname cmd/tailscale: extend hostname validation (#7678) 2023-03-27 18:21:58 +01:00
execqueue control/controlclient,util/execqueue: extract execqueue into a package 2024-01-18 12:08:13 -08:00
expvarx util/expvarx: add a time and concurrency limiting expvar.Func wrapper 2024-01-24 17:47:16 -08:00
goroutines util/goroutines: let ScrubbedGoroutineDump get only current stack 2023-06-23 12:50:45 -07:00
groupmember util/groupmember: fail earlier if group doesn't exist, use slices.Contains 2023-11-01 19:23:16 -07:00
hashx all: update copyright and license headers 2023-01-27 15:36:29 -08:00
httphdr util/httphdr: add new package for parsing HTTP headers (#9797) 2023-10-13 15:38:22 -07:00
httpm util/httpm: don't run test if .git doesn't exist 2023-11-22 12:09:59 -05:00
jsonutil all: update copyright and license headers 2023-01-27 15:36:29 -08:00
limiter util/lru, util/limiter: add debug helper to dump state as HTML 2023-09-08 14:47:03 -07:00
lineread all: update copyright and license headers 2023-01-27 15:36:29 -08:00
linuxfw util/cmpx: delete now that we're using Go 1.22 2024-02-07 18:10:15 -08:00
lru util/lru: update c.head when deleting the most recently used entry 2023-09-19 12:17:50 -07:00
mak various: add golangci-lint, fix issues (#7905) 2023-04-17 18:38:24 -04:00
multierr all: use Go 1.21 slices, maps instead of x/exp/{slices,maps} 2023-08-17 08:42:35 -07:00
must all: update copyright and license headers 2023-01-27 15:36:29 -08:00
nocasemaps util/nocasemaps: add AppendSliceElem method to nocasemaps (#10871) 2024-01-19 15:30:12 -08:00
osdiag util/osdiag, util/winutil: expose Windows policy key 2023-11-15 15:01:25 -05:00
osshare all: update copyright and license headers 2023-01-27 15:36:29 -08:00
osuser ssh/tailssh,util: extract new osuser package from ssh code (#10170) 2023-11-09 09:49:06 -08:00
pidowner all: update copyright and license headers 2023-01-27 15:36:29 -08:00
precompress all: update copyright and license headers 2023-01-27 15:36:29 -08:00
quarantine all: update copyright and license headers 2023-01-27 15:36:29 -08:00
race util/race: add test to confirm we don't leak goroutines 2023-10-03 18:44:22 -04:00
racebuild all: update copyright and license headers 2023-01-27 15:36:29 -08:00
rands util/rands: add Shuffle and Perm functions with on-stack RNG state 2024-02-09 15:19:27 -08:00
ringbuffer util/ringbuffer: move generic ringbuffer from corp repo 2023-02-21 19:11:08 +00:00
set util/set: implement json.Marshaler/Unmarshaler (#10308) 2023-11-20 08:00:31 -08:00
singleflight all: update copyright and license headers 2023-01-27 15:36:29 -08:00
slicesx util/slicesx: add Filter function 2024-01-19 11:17:05 -05:00
syspolicy all: cleanup unused code, part 1 (#10661) 2023-12-20 14:50:30 -08:00
sysresources util/sysresources, magicsock: scale DERP buffer based on system memory 2023-04-03 17:14:14 -04:00
systemd all: update copyright and license headers 2023-01-27 15:36:29 -08:00
testenv util/testenv: add new package to hold InTest 2023-08-08 19:51:44 -06:00
truncate util: add truncate package (#7490) 2023-03-07 11:51:36 -08:00
uniq all: update copyright and license headers 2023-01-27 15:36:29 -08:00
vizerror util/vizerror: add As function to get wrapped Error 2023-02-01 14:39:13 -08:00
winutil util/winutil: add some missing docs to restartmgr errors 2024-01-05 10:12:08 -08:00