You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/util
Joe Tsai 1f7479466e
util/deephash: use sha256x (#5339)
Switch deephash to use sha256x.Hash.

We add sha256x.HashString to efficiently hash a string.
It uses unsafe under the hood to convert a string to a []byte.
We also modify sha256x.Hash to export the underlying hash.Hash
for testing purposes so that we can intercept all hash.Hash calls.

Performance:

	name                 old time/op    new time/op    delta
	Hash-24                19.8µs ± 1%    19.2µs ± 1%  -3.01%  (p=0.000 n=10+10)
	HashPacketFilter-24    2.61µs ± 0%    2.53µs ± 1%  -3.01%  (p=0.000 n=8+10)
	HashMapAcyclic-24      31.3µs ± 1%    29.8µs ± 0%  -4.80%  (p=0.000 n=10+9)
	TailcfgNode-24         1.83µs ± 1%    1.82µs ± 2%    ~     (p=0.305 n=10+10)
	HashArray-24            344ns ± 2%     323ns ± 1%  -6.02%  (p=0.000 n=9+10)

The performance gains is not as dramatic as sha256x over sha256 due to:
1. most of the hashing already occurring through the direct memory hashing logic, and
2. what does not go through direct memory hashing is slowed down by reflect.

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2 years ago
..
cibuild all: use cibuild.On 2 years ago
clientmetric all: gofmt for Go 1.19 2 years ago
cloudenv all: use syncs.AtomicValue 2 years ago
cmpver util/cmpver: move into OSS from corp repo. 3 years ago
codegen all: convert more code to use net/netip directly 2 years ago
deephash util/deephash: use sha256x (#5339) 2 years ago
dnsname all: use Go 1.18's strings.Cut 2 years ago
endian all: gofmt with Go 1.17 3 years ago
groupmember util/groupmember: remove redundant code (#4298) 2 years ago
jsonutil all: use any instead of interface{} 2 years ago
lineread util/lineread: add docs to Reader 4 years ago
mak util/mak: move tailssh's mapSet into a new package for reuse elsewhere 2 years ago
multierr all: gofmt for Go 1.19 2 years ago
must util/must: rename Do->Get, add Do 2 years ago
osshare all: gofmt with Go 1.17 3 years ago
pidowner all: gofmt with Go 1.17 3 years ago
precompress cmd/tsconnect,util/precompress: move precompression to its own package 2 years ago
racebuild all: gofmt with Go 1.17 3 years ago
sha256x util/deephash: use sha256x (#5339) 2 years ago
singleflight all: gofmt for Go 1.19 2 years ago
strs util/strs: add new package for string utility funcs 2 years ago
systemd all: gofmt for Go 1.19 2 years ago
uniq all: use any instead of interface{} 2 years ago
winutil net/dns, paths, util/winutil: change net/dns/windowsManager NRPT management to support more than 50 domains. 2 years ago