You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go/callgraph/vta: save some heap allocations in the trie implementation
The mkLeaf and mkBranch functions use hash consing to dedup values, by
constructing the leaf or branch value, and inserting it into a hash map
if the value is not already there.
This change uses two variables, one as the key for the map lookup, and a
second for the map value. This leads the compiler to place the first on
the stack and the second on the heap, so that a heap allocation is only
done if there is a cache miss.
This can be a significant saving for large VTA type graphs.
name old time/op new time/op delta
TrieStandard-16 2.35µs ± 6% 2.03µs ± 5% -13.48% (p=0.008 n=5+5)
TrieSmallWide-16 1.70µs ± 8% 1.41µs ± 5% -16.76% (p=0.008 n=5+5)
name old alloc/op new alloc/op delta
TrieStandard-16 1.20kB ± 9% 0.89kB ± 5% -26.33% (p=0.008 n=5+5)
TrieSmallWide-16 812B ±12% 480B ± 5% -40.94% (p=0.008 n=5+5)
name old allocs/op new allocs/op delta
TrieStandard-16 6.00 ± 0% 3.00 ± 0% -50.00% (p=0.008 n=5+5)
TrieSmallWide-16 8.00 ± 0% 1.00 ± 0% -87.50% (p=0.008 n=5+5)
Change-Id: I7faeb5458320972f9a267ff7ead04b4e5c31dfb8
Reviewed-on: https://go-review.googlesource.com/c/tools/+/588217
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Zvonimir Pavlinovic <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Tim King <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
Run-TryBot: Zvonimir Pavlinovic <[email protected]>
0 commit comments