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/go: Go 1.11 stripped binaries 12% larger that Go 1.10 #27784

Closed
davecheney opened this issue Sep 20, 2018 · 6 comments
Closed

cmd/go: Go 1.11 stripped binaries 12% larger that Go 1.10 #27784

davecheney opened this issue Sep 20, 2018 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@davecheney
Copy link
Contributor

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go/1.10 & go/1.11

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

darwin/amd64

What did you do?

go get -d github.com/heptio/contour
cd $GOPATH/src/github.com/heptio/contour
dep ensure -vendor-only

What did you expect to see?

% go1.10 build  -o contour1.10 ./cmd/contour && go1.11 build -o contour1.11 ./cmd/contour
% ls -al ./contour*
-rwxr-xr-x  1 dfc  staff  47355140 21 Sep 08:02 ./contour1.10
-rwxr-xr-x  1 dfc  staff  42406532 21 Sep 08:02 ./contour1.11

Unstripped the Go 1.11 binary is 10.45% smaller, however

% go1.10 build -ldflags='-s -w' -o contour1.10 ./cmd/contour && go1.11 build -ldflags='-s -w' -o contour1.11 ./cmd/contour
% ls -al ./contour*
-rwxr-xr-x  1 dfc  staff  32359684 21 Sep 08:06 ./contour1.10
-rwxr-xr-x  1 dfc  staff  36328068 21 Sep 08:07 ./contour1.11

The stripped and DWARF less binary is 12% larger.

@davecheney
Copy link
Contributor Author

bloaty suggests the extra size is coming from __gopclntab

% bloaty contour1.10
     VM SIZE                              FILE SIZE
 --------------                        --------------
  43.5%  13.5Mi __TEXT,__text           13.5Mi  43.7%
  26.0%  8.06Mi __TEXT,__gopclntab      8.06Mi  26.1%
  14.3%  4.43Mi __TEXT,__rodata         4.43Mi  14.3%
  11.9%  3.70Mi String Table            3.70Mi  12.0%
   2.4%   760Ki Symbol Table             760Ki   2.4%
   1.0%   314Ki __DATA,__noptrdata       314Ki   1.0%
   0.5%   142Ki __DATA,__bss                 0   0.0%
   0.3%  79.8Ki __DATA,__data           79.8Ki   0.3%
   0.1%  43.8Ki __TEXT,__typelink       43.8Ki   0.1%
   0.1%  18.9Ki __TEXT,__itablink       18.9Ki   0.1%
   0.0%  12.7Ki __DATA,__noptrbss            0   0.0%
   0.0%  2.89Ki [__TEXT]                2.78Ki   0.0%
   0.0%  1.73Ki [Mach-O Headers]        1.83Ki   0.0%
   0.0%       0 [Unmapped]                 800   0.0%
   0.0%     464 __DATA,__nl_symbol_ptr     464   0.0%
   0.0%     452 Indirect Symbol Table      452   0.0%
   0.0%     330 __TEXT,__symbol_stub1      330   0.0%
   0.0%      87 [__DATA]                    63   0.0%
 100.0%  31.0Mi TOTAL                   30.9Mi 100.0%
% bloaty contour1.11
     VM SIZE                              FILE SIZE
 --------------                        --------------
  39.2%  13.6Mi __TEXT,__text           13.6Mi  39.4%
  32.6%  11.3Mi __TEXT,__gopclntab      11.3Mi  32.8%
  13.6%  4.74Mi __TEXT,__rodata         4.74Mi  13.7%
  10.7%  3.71Mi String Table            3.71Mi  10.7%
   2.2%   768Ki Symbol Table             768Ki   2.2%
   0.9%   315Ki __DATA,__noptrdata       315Ki   0.9%
   0.4%   143Ki __DATA,__bss                 0   0.0%
   0.2%  79.3Ki __DATA,__data           79.3Ki   0.2%
   0.1%  42.4Ki __TEXT,__typelink       42.4Ki   0.1%
   0.1%  18.9Ki __TEXT,__itablink       18.9Ki   0.1%
   0.0%  13.4Ki __DATA,__noptrbss            0   0.0%
   0.0%  3.80Ki [__TEXT]                3.70Ki   0.0%
   0.0%  1.73Ki [Mach-O Headers]        1.83Ki   0.0%
   0.0%       0 [Unmapped]                 960   0.0%
   0.0%     688 __DATA,__nl_symbol_ptr     688   0.0%
   0.0%     676 Indirect Symbol Table      676   0.0%
   0.0%     498 __TEXT,__symbol_stub1      498   0.0%
   0.0%      79 [__DATA]                    63   0.0%
 100.0%  34.8Mi TOTAL                   34.6Mi 100.0%

@davecheney
Copy link
Contributor Author

For reference, tip is similar to go 1.11

% go build -ldflags='-s -w' -o contour.tip ./cmd/contour
% bloaty contour.tip
     VM SIZE                              FILE SIZE
 --------------                        --------------
  39.2%  13.7Mi __TEXT,__text           13.7Mi  39.4%
  32.6%  11.3Mi __TEXT,__gopclntab      11.3Mi  32.7%
  13.6%  4.74Mi __TEXT,__rodata         4.74Mi  13.7%
  10.7%  3.72Mi String Table            3.72Mi  10.7%
   2.2%   769Ki Symbol Table             769Ki   2.2%
   0.9%   315Ki __DATA,__noptrdata       315Ki   0.9%
   0.4%   143Ki __DATA,__bss                 0   0.0%
   0.2%  79.3Ki __DATA,__data           79.3Ki   0.2%
   0.1%  42.4Ki __TEXT,__typelink       42.4Ki   0.1%
   0.1%  19.0Ki __TEXT,__itablink       19.0Ki   0.1%
   0.0%  13.4Ki __DATA,__noptrbss            0   0.0%
   0.0%  4.45Ki [__TEXT]                4.35Ki   0.0%
   0.0%  1.73Ki [Mach-O Headers]        1.83Ki   0.0%
   0.0%       0 [Unmapped]                 704   0.0%
   0.0%     688 __DATA,__nl_symbol_ptr     688   0.0%
   0.0%     676 Indirect Symbol Table      676   0.0%
   0.0%     498 __TEXT,__symbol_stub1      498   0.0%
   0.0%      79 [__DATA]                    63   0.0%
 100.0%  34.8Mi TOTAL                   34.7Mi 100.0%
% go version
go version devel +023dbb188d Tue Sep 11 20:28:15 2018 +0000 darwin/amd64

@agnivade
Copy link
Contributor

The general issue for 1.11 size increase is #27266. Maybe close this and add your findings to that ? That issue already has some good context.

@davecheney
Copy link
Contributor Author

I’d prefer to keep this issue open as it identifies that the increase comes directly from the gopclintab segment.

@bcmills bcmills added Performance NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 22, 2018
@bcmills bcmills added this to the Go1.12 milestone Sep 22, 2018
@bcmills
Copy link
Contributor

bcmills commented Oct 24, 2018

Closing as a duplicate of #27266. (The attribution to gopclntab is already mentioned there too.)

@agnivade
Copy link
Contributor

Really closing now :)

@golang golang locked and limited conversation to collaborators Oct 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

4 participants