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: dedup gclocals at compile time #14983

Closed
skohanim opened this issue Mar 27, 2016 · 5 comments
Closed

cmd/compile: dedup gclocals at compile time #14983

skohanim opened this issue Mar 27, 2016 · 5 comments
Milestone

Comments

@skohanim
Copy link
Contributor

Version:

go version devel +4ffa5eb Sun Mar 27 05:31:54 2016 +0000 linux/amd64

Env:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/shaharko/gopath"
GORACE=""
GOROOT="/home/shaharko/src/go_master"
GOTOOLDIR="/home/shaharko/src/go_master/pkg/tool/linux_amd64"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build742740600=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"

$ go tool nm pkg/linux_amd64/io.a | grep gclocals | awk '{ print $3 }' |  wc -l
142 # total gclocals
$ go tool nm pkg/linux_amd64/io.a | grep gclocals | awk '{ print $3 }' | uniq | wc -l
38  # unique gclocals

The symbol duplication factor is ~3.5x.

@minux
Copy link
Member

minux commented Mar 27, 2016 via email

@skohanim
Copy link
Contributor Author

Yes the linker will deduplicate but this should be done by the compiler ahead of time.
It would reduce the object file size and make the linker faster. Possibly also reducing the compiler memory usage.

@minux minux changed the title gclocals have duplicate symbols in the object file cmd/compile: dedup gclocals at compile time Mar 27, 2016
@minux minux added this to the Go1.7 milestone Mar 27, 2016
@mwhudson
Copy link
Contributor

Oh wow, I had no idea each .o file contained multiple copies of the gclocals symbols.

@gopherbot
Copy link

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

@skohanim
Copy link
Contributor Author

Nice! Thanks.

@golang golang locked and limited conversation to collaborators Apr 28, 2017
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