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: xdcl_list / testdclstack slow when there are lots of decls #14781

Closed
josharian opened this issue Mar 11, 2016 · 3 comments
Closed
Milestone

Comments

@josharian
Copy link
Contributor

$ go get github.com/davecheney/genpkg
$ genpkg -n 50000 > x.go
$ go tool compile -cpuprofile=cpu.prof -d=ssa/check/off x.go  # slow!
$ go tool pprof -pdf `go tool -n compile` cpu.prof > cpu.pdf

testdclstack shows up as ~20% of the cpu time, with xdcl_list one frame up.

I quick look suggests that there may be an O(n^2) interaction between xdcl_list and testdclstack--it looks like xdcl_list adds decls one at a time and calls testdclstack for the entire stack each time. (Could testdclstack be called after the loop instead?)

I think that @mdempsky or @griesemer may be looking into this (and I am not); just filing an issue so we don't forget about it.

cc @davecheney -- thanks for the test case :)

@josharian josharian added this to the Go1.7 milestone Mar 11, 2016
@griesemer
Copy link
Contributor

testdclstack is a consistency check only - fine to disable (and only run in a special debug mode in the compiler)

In the long run we should replace this sequential list and use a proper block structure. I've started working on this yesterday but hit some roadblocks.

@mdempsky
Copy link
Member

I'm curious if the problem is that declare is adding PFUNC declarations (i.e., global function declarations) to dclstack, rather than adding them to externdecl like it already does for PEXTERN declarations (i.e., global variable, const, type declarations). There shouldn't be any need for us to track package scoped symbols in dclstack.

@gopherbot
Copy link

CL https://golang.org/cl/35113 mentions this issue.

gopherbot pushed a commit that referenced this issue Jan 11, 2017
This reduces compilation time for the program
in #18602 from 7 hours to 30 min.

Updates #14781
Updates #18602

Change-Id: I3c4af878a08920e6373d3b3b0c4453ee002e32eb
Reviewed-on: https://go-review.googlesource.com/35113
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
@golang golang locked and limited conversation to collaborators Jan 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants