Open robpike opened 10 years ago
CL https://golang.org/cl/20334 mentions this issue.
CL https://golang.org/cl/20335 mentions this issue.
CL https://golang.org/cl/20483 mentions this issue.
CL https://golang.org/cl/20701 mentions this issue.
CL https://golang.org/cl/20709 mentions this issue.
Progress update.
David Crawshaw's and others work has been paying off...
$ for x in go1.4 go1.5 go1.6 go; do ls -l $x/pkg/tool/linux_amd64/objdump; done
-rwxr-xr-x 1 bradfitz bradfitz 4408008 Feb 18 2015 go1.4/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 4885536 Nov 20 19:33 go1.5/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 4988208 Feb 17 20:37 go1.6/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 3582128 Mar 16 20:01 go/pkg/tool/linux_amd64/objdump
$ for x in go1.4 go1.5 go1.6 go; do ls -l $x/pkg/tool/linux_amd64/cgo; done
-rwxr-xr-x 1 bradfitz bradfitz 4560376 Feb 18 2015 go1.4/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 5111632 Nov 20 19:32 go1.5/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 5275056 Feb 17 20:36 go1.6/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 4161520 Mar 16 20:00 go/pkg/tool/linux_amd64/cgo
$ for x in go1.4 go1.5 go1.6 go; do ls -l $x/bin/go; done
-rwxr-xr-x 1 bradfitz bradfitz 9571864 Feb 18 2015 go1.4/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 11195936 Nov 20 19:33 go1.5/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 12523312 Feb 17 20:37 go1.6/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 9972464 Mar 16 20:08 go/bin/go
$ cat fmt_hello.go
package main
import "fmt"
func main() {
fmt.Println("Hello, world.")
}
$ ls -l fmt_hello_*
-rwxr-xr-x 1 bradfitz bradfitz 1941352 Mar 17 20:08 fmt_hello_14
-rwxr-xr-x 1 bradfitz bradfitz 2367120 Mar 17 20:08 fmt_hello_15
-rwxr-xr-x 1 bradfitz bradfitz 2288392 Mar 17 20:08 fmt_hello_16
-rwxr-xr-x 1 bradfitz bradfitz 1620472 Mar 17 20:08 fmt_hello_tip
You really should test a single program. I believe all of those except maybe objdump have changed significantly during the interval. My test with a more guaranteed stable source is seeing about 6% reduction from 1.4, which is good but still far from where it should be. Go back and read the first message to see how much bloat has arrived.
But progress is happening, that's for sure.
CL https://golang.org/cl/20825 mentions this issue.
@robpike objdump is shrinking more than most programs because the new dead code elimination in the linker can detect statically that it does not call methods via reflect. This lets it remove far more methods. For details see the CL description of https://golang.org/cl/20483
If you have a particular program you'd like me to look at for my next binary size pass, please send it to me.
@robpike, the bottom of my comment contains the 1-line hello world program. It doesn't get much simpler than that.
@bradfitz indeed, although it's not clear whether it's a typical Go program. Perhaps it is.
Here's cmd/godoc at HEAD (fcde7743)
$ for x in go1.4 go1.5 go1.6 go; do $x/bin/go build -a -o ~/godoc_$x golang.org/x/tools/cmd/godoc; ls -l ~/godoc_$x; done
-rwxr-x--- 1 cbro eng 16267896 Mar 18 16:11 /usr/local/google/home/cbro/godoc_go1.4
-rwxr-x--- 1 cbro eng 17132840 Mar 18 16:11 /usr/local/google/home/cbro/godoc_go1.5
-rwxr-x--- 1 cbro eng 18468712 Mar 18 16:12 /usr/local/google/home/cbro/godoc_go1.6
-rwxr-x--- 1 cbro eng 15425920 Mar 18 16:12 /usr/local/google/home/cbro/godoc_go
CL https://golang.org/cl/20968 mentions this issue.
CL https://golang.org/cl/21033 mentions this issue.
CL https://golang.org/cl/21087 mentions this issue.
CL https://golang.org/cl/20902 mentions this issue.
CL https://golang.org/cl/21285 mentions this issue.
CL https://golang.org/cl/21284 mentions this issue.
CL https://golang.org/cl/21395 mentions this issue.
CL https://golang.org/cl/21396 mentions this issue.
CL https://golang.org/cl/21583 mentions this issue.
CL https://golang.org/cl/21777 mentions this issue.
CL https://golang.org/cl/21776 mentions this issue.
CL https://golang.org/cl/22371 mentions this issue.
CL https://golang.org/cl/22373 mentions this issue.
CL https://golang.org/cl/22395 mentions this issue.
Great progress this release cycle. Kicking open issue to next cycle because there's still a bit more to do. But at least the "and growing" has been reversed for one cycle.
@rsc It seems like we haven't done any work on this for 1.8. I don't think keeping an umbrella issue like this open is useful. Is there anything in particular you had in mind for this issue, or should we close it now?
I have some more typeOff work I was hoping to do in 1.8 (the continuation of the work linked here done in 1.7), though I am busy in other projects right now. Let's at least leave this open until the window closes in a few weeks.
We have very few umbrella issues, but this one is fine to keep. It's good to keep in mind and collect all the work toward this. The binaries are still much bigger than we hope they would be.
CL https://golang.org/cl/43090 mentions this issue.
CL https://golang.org/cl/43190 mentions this issue.
CL https://golang.org/cl/44007 mentions this issue.
No notable wins (maybe a slight loss) at tip (to-be Go 1.9) compared to Go 1.8:
bradfitz@gdev:~$ for x in go1.4 go1.5 go1.6 go1.7 go1.8 go; do ls -l $x/bin/go; done
-rwxr-xr-x 1 bradfitz bradfitz 9571864 Feb 18 2015 go1.4/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 11290832 Jan 13 2016 go1.5/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 12534640 Jul 18 2016 go1.6/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 9953979 Aug 15 2016 go1.7/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 10068917 Feb 16 19:28 go1.8/bin/go
-rwxr-xr-x 1 bradfitz bradfitz 10346229 Jun 6 00:03 go/bin/go
bradfitz@gdev:~$ for x in go1.4 go1.5 go1.6 go1.7 go1.8 go; do ls -l $x/pkg/tool/linux_amd64/cgo; done
-rwxr-xr-x 1 bradfitz bradfitz 4560376 Feb 18 2015 go1.4/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 5111280 Jan 13 2016 go1.5/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 5279368 Jul 18 2016 go1.6/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 4114079 Aug 15 2016 go1.7/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 3914818 Feb 16 19:28 go1.8/pkg/tool/linux_amd64/cgo
-rwxr-xr-x 1 bradfitz bradfitz 4015485 Jun 6 00:03 go/pkg/tool/linux_amd64/cgo
bradfitz@gdev:~$ for x in go1.4 go1.5 go1.6 go1.7 go1.8 go; do ls -l $x/pkg/tool/linux_amd64/objdump; done
-rwxr-xr-x 1 bradfitz bradfitz 4408008 Feb 18 2015 go1.4/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 4889240 Jan 13 2016 go1.5/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 4988648 Jul 18 2016 go1.6/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 3622669 Aug 15 2016 go1.7/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 3717826 Feb 16 19:28 go1.8/pkg/tool/linux_amd64/objdump
-rwxr-xr-x 1 bradfitz bradfitz 3836105 Jun 6 00:03 go/pkg/tool/linux_amd64/objdump
bradfitz@gdev:~$ for x in go1.4 go1.5 go1.6 go1.7 go1.8 go; do ls -l $x/bin/gofmt; done
-rwxr-xr-x 1 bradfitz bradfitz 3594744 May 11 2016 go1.4/bin/gofmt
-rwxr-xr-x 1 bradfitz bradfitz 3944064 Jan 13 2016 go1.5/bin/gofmt
-rwxr-xr-x 1 bradfitz bradfitz 3895320 Jul 18 2016 go1.6/bin/gofmt
-rwxr-xr-x 1 bradfitz bradfitz 3036195 Aug 15 2016 go1.7/bin/gofmt
-rwxr-xr-x 1 bradfitz bradfitz 3481554 Feb 16 19:28 go1.8/bin/gofmt
-rwxr-xr-x 1 bradfitz bradfitz 3257512 Jun 6 00:03 go/bin/gofmt
I'm going to move this ongoing tracking bug to Go 1.10, since I don't see anything more happening for Go 1.9.
Change https://golang.org/cl/57130 mentions this issue: cmd/compile/internal/ssa: combine consecutive loads and stores on amd64
This issue reports slight increases between 1.8 and 1.9: #21653
Change https://golang.org/cl/61190 mentions this issue: cmd/compile: specialize map creation for small hint sizes
Change https://golang.org/cl/88135 mentions this issue: cmd/compile: don't combine 64-bit loads/stores on amd64
-ldflags="-s -w"
. (#11799 is relevant to debug info size.)I'm seeing a significant regression in binaries sizes between go1.10.1 and the current tip on linux/amd64. A simple hello world is 26% bigger than it was on 1.10:
$ cat test.go
package main
import "fmt"
func main() {
fmt.Println("hi!")
}
$ go version
go version go1.10.1 linux/amd64
$ go build test.go
$ ls -l test
-rwxr-xr-x 1 alberto alberto 2011612 Apr 27 11:14 test
$ gotip version
go version devel +a3bafcf8cc Thu Apr 26 18:26:06 2018 +0000 linux/amd64
$ gotip build test.go
$ ls -l test
-rwxr-xr-x 1 alberto alberto 2543972 Apr 27 11:15 test
It's not just the hello world. The go
binary went from 11MB to 15MB. gofmt
from 3.4MB to 4.3MB.
Is this expected?
@ALTree have you tried the same tests with -ldflags="-w -s"
? There have been many changes to debugging info recently, so perhaps it's just that the binaries contain more debug info.
Generally speaking we do not recommend stripping debug info (it's useful, after all), so that's only useful for figuring out why they grew, not a justification for the growth.
@mvdan Yes, and stripped binaries are the same size as in 1.10, but that's not the default...
But yeah, if this is an expected effect of the recent work on debug info then... ok, I guess? I just wanted to make sure this was intentional.
I should have been explicit; I meant it only as a way to quickly figure out where the growth was coming from.
When I looked a few weeks ago, all of the increase (and some) was dwarf. I think the best fix is probably #11799.
Change https://golang.org/cl/118276 mentions this issue: cmd/link: compress DWARF sections in ELF binaries
Change https://golang.org/cl/127075 mentions this issue: html: lazily populate Unescape tables
related issue, specifically for wasm: #29478
Go 1.11 got bigger, and Go 1.12 got even bigger: https://github.com/golang/go/issues/27266
Change https://golang.org/cl/161337 mentions this issue: cmd/compile: reorganize init functions