aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/encode_test.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-09-06 13:59:35 -0700
committerKeith Randall <khr@golang.org>2023-10-06 15:44:08 +0000
commit39263f34a307814a74823b280a313829dad374e5 (patch)
tree00b7319dae03b08bbab8b8fbf3d15b583f49a72f /src/encoding/json/encode_test.go
parent28f4ea16a240af6c5a417e20be77745329f817f1 (diff)
downloadgo-39263f34a307814a74823b280a313829dad374e5.tar.xz
cmd/compile: add a cache to interface type switches
That way we don't need to call into the runtime when the type being switched on has been seen many times before. The cache is just a hash table of a sample of all the concrete types that have been switched on at that source location. We record the matching case number and the resulting itab for each concrete input type. The caches seldom get large. The only two in a run of all.bash that get more than 100 entries, even with the sampling rate set to 1, are test/fixedbugs/issue29264.go, with 101 test/fixedbugs/issue29312.go, with 254 Both happen at the type switch in fmt.(*pp).handleMethods, perhaps unsurprisingly. name old time/op new time/op delta SwitchInterfaceTypePredictable-24 25.8ns ± 2% 2.5ns ± 3% -90.43% (p=0.000 n=10+10) SwitchInterfaceTypeUnpredictable-24 37.5ns ± 2% 11.2ns ± 1% -70.02% (p=0.000 n=10+10) Change-Id: I4961ac9547b7f15b03be6f55cdcb972d176955eb Reviewed-on: https://go-review.googlesource.com/c/go/+/526658 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/encoding/json/encode_test.go')
0 files changed, 0 insertions, 0 deletions