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

Comments

Projects
None yet
3 participants
@davecheney
Copy link
Contributor

commented Sep 20, 2018

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

This comment has been minimized.

Copy link
Contributor Author

commented Sep 20, 2018

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

This comment has been minimized.

Copy link
Contributor Author

commented Sep 20, 2018

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

This comment has been minimized.

Copy link
Member

commented Sep 21, 2018

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

This comment has been minimized.

Copy link
Contributor Author

commented Sep 22, 2018

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

@bcmills

This comment has been minimized.

Copy link
Member

commented Oct 24, 2018

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

@agnivade

This comment has been minimized.

Copy link
Member

commented Oct 25, 2018

Really closing now :)

@agnivade agnivade closed this Oct 25, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.