1
0
mirror of https://github.com/golang/go synced 2024-11-19 09:44:46 -07:00
go/src
Iskander Sharipov f864d89ef7 runtime: remove TODO notes suggesting jump tables
For memmove/memclr using jump tables only reduces overall
function performance for both amd64 and 386.

Benchmarks for 32-bit memclr:

	name            old time/op    new time/op    delta
	Memclr/5-8        8.01ns ± 0%    8.94ns ± 2%  +11.59%  (p=0.000 n=9+9)
	Memclr/16-8       9.05ns ± 0%    9.49ns ± 0%   +4.81%  (p=0.000 n=8+8)
	Memclr/64-8       9.15ns ± 0%    9.49ns ± 0%   +3.76%  (p=0.000 n=9+10)
	Memclr/256-8      16.6ns ± 0%    16.6ns ± 0%     ~     (p=1.140 n=10+9)
	Memclr/4096-8      179ns ± 0%     166ns ± 0%   -7.26%  (p=0.000 n=9+8)
	Memclr/65536-8    3.36µs ± 1%    3.31µs ± 1%   -1.48%  (p=0.000 n=10+9)
	Memclr/1M-8       59.5µs ± 3%    60.5µs ± 2%   +1.67%  (p=0.009 n=10+10)
	Memclr/4M-8        239µs ± 3%     245µs ± 0%   +2.49%  (p=0.004 n=10+8)
	Memclr/8M-8        618µs ± 2%     614µs ± 1%     ~     (p=0.315 n=10+8)
	Memclr/16M-8      1.49ms ± 2%    1.47ms ± 1%   -1.11%  (p=0.029 n=10+10)
	Memclr/64M-8      7.06ms ± 1%    7.05ms ± 0%     ~     (p=0.573 n=10+8)
	[Geo mean]        3.36µs         3.39µs        +1.14%

For less predictable data, like loop iteration dependant sizes,
branch table still shows 2-5% worse results.
It also makes code slightly more complicated.

This CL removes TODO note that directly suggest trying this
optimization out. That encourages people to spend their time
in a quite hopeless endeavour.

The code used to implement branch table used a 32/64-entry table
with pointers to TEXT blocks that implemented every associated
label work. Most last entries point to "loop" code that is
a fallthrough for all other sizes that do not map into specialized
routines. The only inefficiency is extra MOVL/MOVQ required
to fetch table pointer itself as MOVL $sym<>(SB)(AX*4) is not valid
in Go asm (it works in other assemblers):

	TEXT ·memclrNew(SB), NOSPLIT, $0-8
        	MOVL    ptr+0(FP), DI
        	MOVL    n+4(FP), BX
        	// Handle 0 separately.
        	TESTL   BX, BX
        	JEQ     _0
        	LEAL    -1(BX), CX // n-1
        	BSRL    CX, CX
		// AX or X0 zeroed inside every text block.
       		MOVL    $memclrTable<>(SB), AX
        	JMP     (AX)(CX*4)
	_0:
        	RET

Change-Id: I4f706931b8127f85a8439b95834d5c2485a5d1bf
Reviewed-on: https://go-review.googlesource.com/115678
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2018-06-11 22:09:04 +00:00
..
archive all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
bufio
builtin
bytes bytes: re-slice buffer to its previous length after call to grow() 2018-05-29 19:46:33 +00:00
cmd cmd/nm: fix TestGoExec on Plan 9 2018-06-11 20:58:09 +00:00
compress all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
container
context context: add benchmarks for context cancellation 2018-05-29 21:57:30 +00:00
crypto crypto, internal/cpu: fix s390x AES feature detection and update SHA implementations 2018-06-11 11:41:31 +00:00
database/sql database/sql: update doc related to per-connection state 2018-06-06 18:18:20 +00:00
debug debug/pe: add IMAGE_FILE_MACHINE_ARM64 2018-06-07 16:17:04 +00:00
encoding encoding/asn1: gofmt 2018-06-07 15:01:06 +00:00
errors
expvar all: use strings.Builder instead of bytes.Buffer where appropriate 2018-03-26 23:05:53 +00:00
flag flag: removed the colon after "Usage" in the documentation 2018-06-07 07:00:46 +00:00
fmt
go go/types: extend cycle detection past simple type cycles 2018-06-07 22:04:21 +00:00
hash all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
html all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
image all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
index/suffixarray index/suffixarray: fix a typo mistake in comments 2018-05-29 12:16:51 +00:00
internal crypto, internal/cpu: fix s390x AES feature detection and update SHA implementations 2018-06-11 11:41:31 +00:00
io io: calculate buffer size only when needed 2018-05-06 15:52:31 +00:00
log log/syslog: skip tests that depend on daemon on builders 2018-05-22 18:26:03 +00:00
math all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
mime all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
net net: skip TestSendfileParts on dragonfly and solaris 2018-06-11 08:16:18 +00:00
os os: check setStickyBit error in mkdir 2018-06-05 14:53:18 +00:00
path os: add js/wasm architecture 2018-06-01 05:18:38 +00:00
plugin plugin: make stub lookup signature match dlopen version 2018-05-08 17:09:05 +00:00
reflect reflect: add StructOf test case that gccgo used to fail 2018-06-06 14:08:42 +00:00
regexp all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
runtime runtime: remove TODO notes suggesting jump tables 2018-06-11 22:09:04 +00:00
sort all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
strconv strconv: add missing period to godoc comment 2018-06-09 01:26:25 +00:00
strings all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
sync sync: deflake TestWaitGroupMisuse2 2018-05-14 04:42:45 +00:00
syscall syscall: update TOKEN_ALL_ACCESS according to WinNT.h 2018-06-11 00:45:20 +00:00
testing Revert "testing: only compute b.N once when passed -count > 1" 2018-05-31 14:22:44 +00:00
text text/tabwriter: fix BenchmarkPyramid and BenchmarkRagged again 2018-06-04 17:32:17 +00:00
time runtime: don't crash holding locks on racy timer access 2018-06-04 18:33:41 +00:00
unicode all: update comment URLs from HTTP to HTTPS, where possible 2018-06-01 21:52:00 +00:00
unsafe
vendor/golang_org/x net/http: vendor x/net/http/httpproxy, use it in net/http 2018-05-29 21:54:57 +00:00
all.bash Revert "build: fail nicely if somebody runs all.bash from a binary tarball package" 2017-04-28 21:19:32 +00:00
all.bat
all.rc build: do not set GOBIN on Plan 9 2013-02-26 09:25:46 -08:00
androidtest.bash
bootstrap.bash
buildall.bash src/*.bash: use tabs consistently 2017-03-09 21:30:31 +00:00
clean.bash
clean.bat
clean.rc build: fix clean scripts 2015-06-18 16:13:13 +00:00
cmp.bash all: make copyright headers consistent with one space after period 2016-11-04 20:46:25 +00:00
iostest.bash
make.bash src/*.bash: remove some trailing whitespace 2018-05-04 14:47:49 +00:00
make.bat
Make.dist
make.rc
naclmake.bash
nacltest.bash nacl*.bash: pass flags to make.bash 2018-02-14 17:09:31 +00:00
race.bash runtime/race: implement race detector for ppc64le 2018-06-11 17:45:36 +00:00
race.bat
run.bash
run.bat
run.rc