Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: stack allocation phase in large functions slows down SSA compiler #14775

Closed
dr2chase opened this issue Mar 11, 2016 · 5 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. ToolSpeed
Milestone

Comments

@dr2chase
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
    devel for 1.7
  2. What operating system and processor architecture are you using (go env)?
    amd64
  3. What did you do?
    Downloaded Dave Cheney's genpkg to explore performance problems.
mkdir x
go run gen.go -n 3000  -noinitfn > x/types.go
time go build  -gcflags='-d=ssa/check/off -memprofile=x.mprof' ./x
go tool pprof -alloc_space ${GOROOT}/pkg/tool/darwin_amd64/compile x/x.mprof

with results

Showing top 30 nodes out of 40 (cum >= 1810.24MB)
      flat  flat%   sum%        cum   cum%
 1819.24MB 20.43% 20.43%  1819.24MB 20.43%  cmd/compile/internal/ssa.(*Func).newValue
  947.75MB 10.64% 31.08%  2753.49MB 30.93%  cmd/compile/internal/gc.(*state).lookupVarOutgoing
  947.44MB 10.64% 41.72%   947.44MB 10.64%  cmd/compile/internal/ssa.(*stackAllocState).buildInterferenceGraph
  638.83MB  7.18% 48.89%   642.34MB  7.21%  cmd/compile/internal/ssa.(*stackAllocState).stackalloc
  625.34MB  7.02% 55.92%  1041.10MB 11.69%  cmd/compile/internal/ssa.(*regAllocState).init
  581.15MB  6.53% 62.45%   649.08MB  7.29%  cmd/compile/internal/gc.genssa
  525.89MB  5.91% 68.35%   526.62MB  5.91%  cmd/compile/internal/ssa.cse
  482.10MB  5.41% 73.77%   482.10MB  5.41%  cmd/compile/internal/ssa.schedule
  460.90MB  5.18% 78.94%  2667.34MB 29.96%  cmd/compile/internal/ssa.(*regAllocState).regalloc
  416.07MB  4.67% 83.62%  1476.37MB 16.58%  cmd/compile/internal/ssa.(*stackAllocState).init
  415.25MB  4.66% 88.28%   415.77MB  4.67%  cmd/compile/internal/ssa.(*regAllocState).computeLive
  312.07MB  3.51% 91.79%   312.07MB  3.51%  cmd/compile/internal/ssa.(*Func).newSparseSet
  169.05MB  1.90% 93.68%   169.05MB  1.90%  cmd/compile/internal/ssa.tighten
  111.31MB  1.25% 94.93%   112.86MB  1.27%  cmd/compile/internal/ssa.(*stackAllocState).computeLive
  1. What did you expect to see?
    Not that much slowdown and memory consumption.
  2. What did you see instead?
    Much slowdown and memory consumption.

Note that two similar bugs are filed, one against the ssa.go variable lookup code, the other against regalloc/stackalloc, since the fixes are independent.

@dr2chase dr2chase self-assigned this Mar 11, 2016
@ianlancetaylor ianlancetaylor changed the title Stack allocation phase in large functions slows down SSA compiler cmd/compile: stack allocation phase in large functions slows down SSA compiler Mar 11, 2016
@bradfitz bradfitz added this to the Go1.7 milestone Apr 9, 2016
@dr2chase
Copy link
Contributor Author

I'd like to push this off to 1.8; it's a hard problem, and we've made other progress for the pathological functions that trigger this:

and we have two more CLs queued up for 1.8 ( or possibly 1.7 if sufficiently horrible inputs appear) that will help some more:

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label May 26, 2016
@quentinmit
Copy link
Contributor

@randall77 @dr2chase Please change the milestone to Go1.8 if you're satisfied with what's already in 1.7.

@bradfitz
Copy link
Contributor

@dr2chase, what's the status of this? It's marked "Go1.8Early".

@dr2chase
Copy link
Contributor Author

Very little work on the stack allocation code, and instead we beat on the more tractable problem of SSA phi-function placement -- one of the 1.8early changes went into 1.7late because of a horrifying compilation problem there: https://go-review.googlesource.com/c/23136/

I took at stab at this once and didn't get it right. I'd guess that it's a least a week's work if I'm lucky, probably two.

@randall77
Copy link
Contributor

Tip is now faster than 1.6 (3.5 sec for 1.6, 3.2 sec for tip). Closing.

@golang golang locked and limited conversation to collaborators Oct 5, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. ToolSpeed
Projects
None yet
Development

No branches or pull requests

5 participants