]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile: use jump tables for large type switches
authorKeith Randall <khr@golang.org>
Thu, 17 Aug 2023 21:20:21 +0000 (14:20 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 23 Aug 2023 00:30:54 +0000 (00:30 +0000)
commit47112996619da0683eb15e611a1e2df85416feee
treefaba836b45c89df8eb42a3269acda1f92ffb447c
parent556e9c5f3e28d0398001384508a3c51143adcff8
cmd/compile: use jump tables for large type switches

For large interface -> concrete type switches, we can use a jump
table on some bits of the type hash instead of a binary search on
the type hash.

name                        old time/op  new time/op  delta
SwitchTypePredictable-24    1.99ns ± 2%  1.78ns ± 5%  -10.87%  (p=0.000 n=10+10)
SwitchTypeUnpredictable-24  11.0ns ± 1%   9.1ns ± 2%  -17.55%  (p=0.000 n=7+9)

Change-Id: Ida4768e5d62c3ce1c2701288b72664aaa9e64259
Reviewed-on: https://go-review.googlesource.com/c/go/+/521497
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
src/cmd/compile/internal/test/switch_test.go
src/cmd/compile/internal/walk/switch.go
test/codegen/switch.go