tailscale/util
Joe Tsai 3fc8683585
util/deephash: expand fast-path capabilities (#5404)
Add support for maps and interfaces to the fast path.
Add cycle-detection to the pointer handling logic.
This logic is mostly copied from the slow path.

A future commit will delete the slow path once
the fast path never falls back to the slow path.

Performance:

	name                 old time/op    new time/op    delta
	Hash-24                18.5µs ± 1%    14.9µs ± 2%  -19.52%  (p=0.000 n=10+10)
	HashPacketFilter-24    2.54µs ± 1%    2.60µs ± 1%   +2.19%  (p=0.000 n=10+10)
	HashMapAcyclic-24      31.6µs ± 1%    30.5µs ± 1%   -3.42%  (p=0.000 n=9+8)
	TailcfgNode-24         1.44µs ± 2%    1.43µs ± 1%     ~     (p=0.171 n=10+10)
	HashArray-24            324ns ± 1%     324ns ± 2%     ~     (p=0.425 n=9+9)

The additional cycle detection logic doesn't incur much slow down
since it only activates if a type is recursive, which does not apply
for any of the types that we care about.

There is a notable performance boost since we switch from the fath path
to the slow path less often. Most notably, a struct with a field that
could not be handled by the fast path would previously cause
the entire struct to go through the slow path.

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2022-08-24 01:31:01 -07:00
..
cibuild all: use cibuild.On 2022-03-18 15:19:26 -07:00
clientmetric all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
cloudenv all: use syncs.AtomicValue 2022-08-04 11:52:16 -07:00
cmpver util/cmpver: move into OSS from corp repo. 2021-04-23 20:55:45 -07:00
codegen all: convert more code to use net/netip directly 2022-07-25 21:53:49 -07:00
deephash util/deephash: expand fast-path capabilities (#5404) 2022-08-24 01:31:01 -07:00
dnsname all: use Go 1.18's strings.Cut 2022-03-16 14:53:59 -07:00
endian all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
groupmember util/groupmember: remove redundant code (#4298) 2022-03-26 21:45:06 -07:00
hashx util/hashx: move from sha256x (#5388) 2022-08-16 13:15:33 -07:00
jsonutil all: use any instead of interface{} 2022-03-17 11:35:09 -07:00
lineread util/lineread: add docs to Reader 2020-11-19 12:14:58 -08:00
mak util/mak: move tailssh's mapSet into a new package for reuse elsewhere 2022-04-21 21:20:10 -07:00
multierr all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
must util/must: rename Do->Get, add Do 2022-08-06 09:30:10 -07:00
osshare all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
pidowner all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
precompress cmd/tsconnect,util/precompress: move precompression to its own package 2022-08-03 17:44:57 -07:00
racebuild all: gofmt with Go 1.17 2021-08-05 15:54:00 -07:00
singleflight all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
strs util/strs: add new package for string utility funcs 2022-08-05 15:06:08 -07:00
systemd all: gofmt for Go 1.19 2022-08-02 10:08:05 -07:00
uniq all: use any instead of interface{} 2022-03-17 11:35:09 -07:00
winutil util/winutil: consolidate interface specific registry keys 2022-08-14 22:34:59 -07:00