mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.ssa] cmd/compile: reducing alloc footprint of dominator calc
Converted working slices of pointer into slices of pointer index. Half the size (on 64-bit machine) and no pointers to trace if GC occurs while they're live. TODO - could expose slice mapping ID->*Block; some dom clients also construct these. Minor optimization in regalloc that cuts allocation count. Minor optimization in compile.go that cuts calls to Sprintf. Change-Id: I28f0bfed422b7344af333dc52ea272441e28e463 Reviewed-on: https://go-review.googlesource.com/19104 Run-TryBot: Todd Neal <todd@tneal.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Todd Neal <todd@tneal.org>
This commit is contained in:
parent
25abe96214
commit
c87a62f32b
3 changed files with 74 additions and 63 deletions
|
|
@ -57,25 +57,24 @@ func Compile(f *Func) {
|
|||
|
||||
tStart := time.Now()
|
||||
p.fn(f)
|
||||
tEnd := time.Now()
|
||||
|
||||
time := tEnd.Sub(tStart).Nanoseconds()
|
||||
var stats string
|
||||
if logMemStats {
|
||||
var mEnd runtime.MemStats
|
||||
runtime.ReadMemStats(&mEnd)
|
||||
nBytes := mEnd.TotalAlloc - mStart.TotalAlloc
|
||||
nAllocs := mEnd.Mallocs - mStart.Mallocs
|
||||
stats = fmt.Sprintf("[%d ns %d allocs %d bytes]", time, nAllocs, nBytes)
|
||||
} else {
|
||||
stats = fmt.Sprintf("[%d ns]", time)
|
||||
}
|
||||
if f.Log() || f.Config.HTML != nil {
|
||||
tEnd := time.Now()
|
||||
|
||||
time := tEnd.Sub(tStart).Nanoseconds()
|
||||
var stats string
|
||||
if logMemStats {
|
||||
var mEnd runtime.MemStats
|
||||
runtime.ReadMemStats(&mEnd)
|
||||
nBytes := mEnd.TotalAlloc - mStart.TotalAlloc
|
||||
nAllocs := mEnd.Mallocs - mStart.Mallocs
|
||||
stats = fmt.Sprintf("[%d ns %d allocs %d bytes]", time, nAllocs, nBytes)
|
||||
} else {
|
||||
stats = fmt.Sprintf("[%d ns]", time)
|
||||
}
|
||||
|
||||
if f.Log() {
|
||||
f.Logf(" pass %s end %s\n", p.name, stats)
|
||||
}
|
||||
printFunc(f)
|
||||
if f.Config.HTML != nil {
|
||||
printFunc(f)
|
||||
f.Config.HTML.WriteFunc(fmt.Sprintf("after %s <span class=\"stats\">%s</span>", phaseName, stats), f)
|
||||
}
|
||||
checkFunc(f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue