tailscale/util/deephash
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
..
testtype util/deephash: fix unexported time.Time hashing 2022-07-27 09:28:23 -07:00
deephash_test.go control/controlclient,tailcfg: [capver 40] create KeySignature field in tailcfg.Node 2022-08-22 11:25:41 -07:00
deephash.go util/deephash: expand fast-path capabilities (#5404) 2022-08-24 01:31:01 -07:00
types_test.go util/deephash: move typeIsRecursive and canMemHash to types.go (#5386) 2022-08-16 09:31:19 -07:00
types.go util/deephash: specialize for netip.Addr and drop AppendTo support (#5402) 2022-08-18 22:54:56 -07:00