aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/cache.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2019-05-09 11:31:04 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2019-05-10 00:14:40 +0000
commit4ae31dc8c5d5f7dc62a1fe74270588bb62354050 (patch)
treee9639dcc26134b1b14706eb85c4e9b9456d677b7 /src/cmd/compile/internal/ssa/cache.go
parent40657c282d49d807d2bd76165fe013317855a653 (diff)
downloadgo-4ae31dc8c5d5f7dc62a1fe74270588bb62354050.tar.gz
go-4ae31dc8c5d5f7dc62a1fe74270588bb62354050.zip
cmd/compile: re-use regalloc's []valState
Updates #27739: reduces package ssa's allocated space by 3.77%. maxrss is harder to measure, but using best-of-three-runs as reported by /usr/bin/time -l, I see ~2% reduction in maxrss. We still have a long way to go, though; the new maxrss is still 1.1gb. name old alloc/op new alloc/op delta Template 38.8MB ± 0% 37.7MB ± 0% -2.77% (p=0.008 n=5+5) Unicode 28.2MB ± 0% 28.1MB ± 0% -0.20% (p=0.008 n=5+5) GoTypes 131MB ± 0% 127MB ± 0% -2.94% (p=0.008 n=5+5) Compiler 606MB ± 0% 587MB ± 0% -3.21% (p=0.008 n=5+5) SSA 2.14GB ± 0% 2.06GB ± 0% -3.77% (p=0.008 n=5+5) Flate 24.0MB ± 0% 23.3MB ± 0% -3.00% (p=0.008 n=5+5) GoParser 28.8MB ± 0% 28.1MB ± 0% -2.61% (p=0.008 n=5+5) Reflect 83.8MB ± 0% 81.5MB ± 0% -2.71% (p=0.008 n=5+5) Tar 36.4MB ± 0% 35.4MB ± 0% -2.73% (p=0.008 n=5+5) XML 47.9MB ± 0% 46.7MB ± 0% -2.49% (p=0.008 n=5+5) [Geo mean] 84.6MB 82.4MB -2.65% name old allocs/op new allocs/op delta Template 379k ± 0% 379k ± 0% -0.05% (p=0.008 n=5+5) Unicode 340k ± 0% 340k ± 0% ~ (p=0.151 n=5+5) GoTypes 1.36M ± 0% 1.36M ± 0% -0.06% (p=0.008 n=5+5) Compiler 5.49M ± 0% 5.48M ± 0% -0.03% (p=0.008 n=5+5) SSA 17.5M ± 0% 17.5M ± 0% -0.03% (p=0.008 n=5+5) Flate 235k ± 0% 235k ± 0% -0.04% (p=0.008 n=5+5) GoParser 302k ± 0% 302k ± 0% -0.04% (p=0.008 n=5+5) Reflect 976k ± 0% 975k ± 0% -0.10% (p=0.008 n=5+5) Tar 352k ± 0% 352k ± 0% -0.06% (p=0.008 n=5+5) XML 436k ± 0% 436k ± 0% -0.03% (p=0.008 n=5+5) [Geo mean] 842k 841k -0.04% Change-Id: I0ab6631b5a0bb6303c291dcb0367b586a4e584fb Reviewed-on: https://go-review.googlesource.com/c/go/+/176221 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/cache.go')
-rw-r--r--src/cmd/compile/internal/ssa/cache.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/cache.go b/src/cmd/compile/internal/ssa/cache.go
index 6c8cc50e1e..dbec2e139c 100644
--- a/src/cmd/compile/internal/ssa/cache.go
+++ b/src/cmd/compile/internal/ssa/cache.go
@@ -32,6 +32,8 @@ type Cache struct {
live []bool
q []*Value
}
+ // Reusable regalloc state.
+ regallocValues []valState
ValueToProgAfter []*obj.Prog
debugState debugState
@@ -56,6 +58,12 @@ func (c *Cache) Reset() {
xl[i] = nil
}
+ // regalloc sets the length of c.regallocValues to whatever it may use,
+ // so clear according to length.
+ for i := range c.regallocValues {
+ c.regallocValues[i] = valState{}
+ }
+
// liveOrderStmts gets used multiple times during compilation of a function.
// We don't know where the high water mark was, so reslice to cap and search.
c.deadcode.liveOrderStmts = c.deadcode.liveOrderStmts[:cap(c.deadcode.liveOrderStmts)]