1
0
mirror of https://github.com/golang/go synced 2024-11-14 09:00:21 -07:00
go/src/cmd
Josh Bleecher Snyder 794d29a46f cmd/compile: use a map to track liveness variable indices
It is not safe to modify Node.Opt in the backend.
Instead of using Node.Opt to store liveness variable indices, use a map.
This simplifies the code and makes it much more clearly race-free.
There are generally few such variables, so the maps are not a significant
source of allocations; this also remove some allocations from putting
int32s into interfaces.

Because map lookups are more expensive than interface value extraction,
reorder valueEffects to do the map lookup last.

The only remaining use of Node.Opt is now in esc.go.

Passes toolstash-check.

Fixes #20144

name        old alloc/op      new alloc/op      delta
Template         37.8MB ± 0%       37.9MB ± 0%    ~     (p=0.548 n=5+5)
Unicode          28.9MB ± 0%       28.9MB ± 0%    ~     (p=0.548 n=5+5)
GoTypes           110MB ± 0%        110MB ± 0%  +0.16%  (p=0.008 n=5+5)
Compiler          461MB ± 0%        462MB ± 0%  +0.08%  (p=0.008 n=5+5)
SSA              1.11GB ± 0%       1.11GB ± 0%  +0.11%  (p=0.008 n=5+5)
Flate            24.7MB ± 0%       24.7MB ± 0%    ~     (p=0.690 n=5+5)
GoParser         31.1MB ± 0%       31.1MB ± 0%    ~     (p=0.841 n=5+5)
Reflect          73.7MB ± 0%       73.8MB ± 0%  +0.23%  (p=0.008 n=5+5)
Tar              25.8MB ± 0%       25.7MB ± 0%    ~     (p=0.690 n=5+5)
XML              41.2MB ± 0%       41.2MB ± 0%    ~     (p=0.841 n=5+5)
[Geo mean]       71.9MB            71.9MB       +0.06%

name        old allocs/op     new allocs/op     delta
Template           385k ± 0%         384k ± 0%    ~     (p=0.548 n=5+5)
Unicode            344k ± 0%         343k ± 1%    ~     (p=0.421 n=5+5)
GoTypes           1.16M ± 0%        1.16M ± 0%    ~     (p=0.690 n=5+5)
Compiler          4.43M ± 0%        4.42M ± 0%    ~     (p=0.095 n=5+5)
SSA               9.86M ± 0%        9.84M ± 0%  -0.19%  (p=0.008 n=5+5)
Flate              238k ± 0%         238k ± 0%    ~     (p=1.000 n=5+5)
GoParser           321k ± 0%         320k ± 0%    ~     (p=0.310 n=5+5)
Reflect            956k ± 0%         956k ± 0%    ~     (p=1.000 n=5+5)
Tar                252k ± 0%         251k ± 0%    ~     (p=0.056 n=5+5)
XML                402k ± 1%         400k ± 1%  -0.57%  (p=0.032 n=5+5)
[Geo mean]         740k              739k       -0.19%

Change-Id: Id5916c9def76add272e89c59fe10968f0a6bb01d
Reviewed-on: https://go-review.googlesource.com/42135
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-28 19:50:53 +00:00
..
addr2line cmd/go: build test binaries with -s in addition to -w 2017-03-29 17:18:16 +00:00
api api: promote next.txt to go1.8.txt, update go tool 2016-12-01 02:54:21 +00:00
asm cmd/internal/obj/arm64: fix encoding of condition 2017-04-27 13:35:59 +00:00
cgo cmd/cgo: avoid C++ style comments 2017-04-22 00:53:51 +00:00
compile cmd/compile: use a map to track liveness variable indices 2017-04-28 19:50:53 +00:00
cover cmd/cover: fix spelling mistake 2016-12-20 04:45:25 +00:00
dist cmd/dist: disable internal linking tests on Alpine 2017-04-25 23:34:37 +00:00
doc cmd/doc: implement "go doc struct.field" 2017-03-22 05:37:50 +00:00
fix cmd/fix,cmd/gofmt: flush to disk before diffing 2017-03-30 18:19:57 +00:00
go cmd/go: error on space-separated list with comma 2017-04-28 19:08:35 +00:00
gofmt cmd/fix,cmd/gofmt: flush to disk before diffing 2017-03-30 18:19:57 +00:00
internal cmd/internal/objabi, cmd/link: move linker-only symkind values into linker 2017-04-27 21:56:12 +00:00
link cmd/internal/objabi, cmd/link: move linker-only symkind values into linker 2017-04-27 21:56:12 +00:00
nm all: fix some printf format strings 2017-02-14 02:09:30 +00:00
objdump cmd/objdump: remove two unused types 2017-04-23 00:18:40 +00:00
pack all: use testing.GoToolPath instead of "go" 2016-08-30 22:49:11 +00:00
pprof cmd/pprof: update README to explain relationship with github.com/google/pprof 2017-04-10 19:51:01 +00:00
trace cmd/trace: document that trace viewer is only tested on chromium 2017-04-20 16:44:55 +00:00
vendor cmd/vendor/arch/x86: pull new version from x repo 2017-04-20 22:39:48 +00:00
vet cmd/compile: rework handling of udiv on ARM 2017-04-20 16:27:38 +00:00