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

-d compileunits on go binary shows suspiciously large size for sync/atomic #138

Closed
psanford opened this issue Aug 8, 2018 · 4 comments
Closed

Comments

@psanford
Copy link

psanford commented Aug 8, 2018

I ran bloaty on an internal go binary which reported sync/atomic using ~30% of the binary size. This seemed... unlikely. So I tried running bloatly on an etcd binary (linux amd64) compiled from master which shows something very similar:

$ /tmp/bloaty/bloaty -d compileunits etcd -n 5
     VM SIZE                              FILE SIZE
 --------------                        --------------
  49.0%  2.92Mi [142 Others]            4.27Mi  46.2%
  30.8%  1.83Mi sync/atomic             2.79Mi  30.2%
   9.1%   557Ki net/http                 824Ki   8.7%
   7.3%   444Ki runtime                  733Ki   7.8%
   3.8%   234Ki net                      345Ki   3.7%
   0.0%       0 [section .debug_frame]   329Ki   3.5%
 100.0%  5.96Mi TOTAL                   9.23Mi 100.0%

30% doesn't sound right to me as sync/atomic is a small amount of assembly code and not much else.

I'm hoping someone could shed some light onto what is going on here. Is this somehow related to inlining?

@haberman
Copy link
Member

haberman commented Aug 9, 2018

I'm not a Go user. How can I reproduce this?

@psanford
Copy link
Author

psanford commented Aug 9, 2018

The etcd binary I was examining is here: https://s3.amazonaws.com/www.sanford.io/etcd

To build the binary yourself (assuming you have the go tool installed):

git clone https://github.com/coreos/etcd
cd etcd
./build
ls bin/

@dominikh
Copy link

Possibly related to #176

@haberman
Copy link
Member

Sorry I was not able to debug this earlier.

I just tried your command and I am getting reasonable results (I did have to specify non-compressed dwarf per #204):

$ ../bloaty -d compileunits bin/etcd -n 30
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  36.3%  16.3Mi  31.9%  6.62Mi    [318 Others]
  12.3%  5.52Mi  26.6%  5.52Mi    [section .gopclntab]
   9.3%  4.17Mi   4.0%   848Ki    runtime
   4.9%  2.19Mi   3.7%   790Ki    go.etcd.io/etcd/api/v3/etcdserverpb
   3.5%  1.56Mi   3.3%   701Ki    net/http
   2.9%  1.31Mi   2.3%   483Ki    github.com/gogo/protobuf/proto
   2.5%  1.12Mi   4.8%  1.00Mi    vendor/golang.org/x/text/unicode/norm
   2.4%  1.09Mi   2.4%   511Ki    go.etcd.io/etcd/server/v3/etcdserver
   2.4%  1.08Mi   0.0%       0    [section .debug_frame]
   2.2%   988Ki   1.9%   401Ki    crypto/tls
   1.9%   881Ki   1.6%   345Ki    github.com/json-iterator/go
   1.8%   845Ki   1.5%   315Ki    github.com/golang/protobuf/proto
   1.5%   667Ki   1.3%   275Ki    net
   1.2%   569Ki   1.2%   248Ki    google.golang.org/grpc
   1.1%   505Ki   0.9%   196Ki    go.etcd.io/etcd/client/v3
   1.1%   500Ki   0.9%   194Ki    google.golang.org/grpc/internal/transport
   1.1%   489Ki   0.9%   183Ki    math/big
   1.0%   458Ki   0.6%   136Ki    github.com/spf13/pflag
   1.0%   438Ki   0.7%   156Ki    golang.org/x/net/http2
   0.9%   412Ki   0.8%   167Ki    github.com/gogo/protobuf/protoc-gen-gogo/descriptor
   0.9%   407Ki   0.9%   188Ki    go.etcd.io/etcd/server/v3/etcdserver/api/rafthttp
   0.9%   407Ki   0.9%   190Ki    go.etcd.io/etcd/api/v3/etcdserverpb/gw
   0.9%   394Ki   0.6%   133Ki    go.etcd.io/etcd/server/v3/etcdmain
   0.9%   392Ki   0.8%   170Ki    gopkg.in/yaml.v2
   0.8%   383Ki   0.7%   142Ki    reflect
   0.8%   349Ki   0.6%   123Ki    github.com/modern-go/reflect2
   0.8%   348Ki   0.4%  90.0Ki    github.com/prometheus/client_golang/prometheus/promhttp
   0.8%   348Ki   1.6%   348Ki    [section .rodata]
   0.7%   323Ki   0.6%   128Ki    internal/profile
   0.7%   317Ki   0.7%   149Ki    go.uber.org/zap/zapcore
   0.7%   309Ki   0.6%   137Ki    crypto/x509
 100.0%  44.8Mi 100.0%  20.7Mi    TOTAL

I'll close this now. If you have a case where Bloaty is still returning unreasonable results, please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants