Go binary size SVG treemap
Make treemap breakdown of Go executable binary
$ go install github.com/nikolaydubina/[email protected] $ go tool nm -size
| go-binsize-treemap > binsize.svg
Should you be worried about executable binary size? In 2022, few seconds of cat videos or even a single image is tens of MBs. Transferring them over network is not a big deal either. So, probably, you should not worry too much about it. However, this tool can still be useful in couple of cases.
- You are studying compiler.
- You are investigating what 3rd party dependencies are getting included in binary.
- You are checking much data is getting embedded.
- You are estimating how much code is getting included by packages.
- You are researching which symbols included.
- You are doing
- You are doing treemap visualizations.
I build this in my spare time as another usecase for Go treemap tooling that I built before. Enjoy! Submit issues or PRs!
62MB, this famous example of large Go project
71MB, this famous db is building with C++
6.5MB, this project has CGO and builds with lots of graphviz code in C
This is interface related code. Refer to this article by Russ Cox.
runtime.pclntab? And why it is so big?
Known Issues and TODOs
- Size slightly mismatches actual binary size. Including unknown does not help.
- identify go:embed
- color by type + increasing luminance (sys; user; c++; go:embed; etc.)
- color by symbol type
- heat by ????
- https://github.com/jondot/goweight — looks like it was working in the beginning, but as of 2022-01-22 it does not work anymore for me and there were reports dating back to 2020-01-23 for it to be not accurate.
Appendix A: Strange Output / C++ / CGO
You many need to demungle symtab file first. Install
c++flit. Then process symtab first. Note, c++ support is work in progress.
$ go tool nm -size
| c++filt | go-binsize-treemap > binsize.svg
Appendix B: Large dimensions and lots of details
If you set dimensions very large you can see lots of details and navigate map.
4096x4096 is recommended
Appendix C: Small dimensions and informative preview
You can generate small preview of project that fits for embedding in README for example.
1024x256 is recommended