go-binsize-treemap

🔍 Go binary size SVG treemap

https://github.com/nikolaydubina/go-binsize-treemap

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.6%) to scientific vocabulary

Keywords

binary binary-analysis compiler data-visualization go golang svg symtab treemap

Keywords from Contributors

mesh benchmarking interactive
Last synced: 4 months ago · JSON representation ·

Repository

🔍 Go binary size SVG treemap

Basic Info
  • Host: GitHub
  • Owner: nikolaydubina
  • License: mit
  • Language: Go
  • Default Branch: main
  • Homepage:
  • Size: 31.3 MB
Statistics
  • Stars: 451
  • Watchers: 7
  • Forks: 15
  • Open Issues: 4
  • Releases: 5
Topics
binary binary-analysis compiler data-visualization go golang svg symtab treemap
Created almost 4 years ago · Last pushed over 1 year ago
Metadata Files
Readme Funding License Citation Codeowners Security

README.md

🔍 Go binary size SVG treemap

Make treemap breakdown of Go executable binary

Go Reference codecov Go Report Card go-recipes Hits OpenSSF Scorecard

$ go install github.com/nikolaydubina/go-binsize-treemap@latest $ go tool nm -size <binary finename> | go-binsize-treemap > binsize.svg

Disclaimer

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 cgo. - 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!

Examples

github.com/gohugoio/hugo

62MB, this famous example of large Go project

github.com/cockroachdb/cockroach

71MB, this famous db is building with C++

github.com/goccy/go-graphviz

6.5MB, this project has CGO and builds with lots of graphviz code in C

github.com/zalando/skipper

36MB, is a large Go project, some builds can include C

Knowledge Base

What is go.itab?

This is interface related code. Refer to this article by Russ Cox.

What is runtime.pclntab? And why it is so big?

As investigated Cockroach team, it is Go runtime structure for traces (reference). Past discussions in GitHub thread on why it is big and what to do about it (well, nothing).

Known Issues and TODOs

  • [ ] Size slightly mismatches actual binary size. Including unknown does not help.
  • [ ] Better symbol names parsing for C++
  • [ ] identify go:embed
  • [ ] color by type + increasing luminance (sys; user; c++; go:embed; etc.)
  • [ ] color by symbol type
  • [ ] heat by ????

Related Work

  • https://github.com/knz/go-binsize-viz — this was an inspiration for current tool. However, instead of Python and D3 and Javascript, this tool is using single stack purely in Go and has test coverage. Arguably, the downside it is not interactive.
  • 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.

Reference

  • https://github.com/knz/go-binsize-viz
  • https://github.com/jondot/goweight
  • https://github.com/nikolaydubina/treemap
  • https://github.com/nikolaydubina/go-cover-treemap
  • https://github.com/golang/go/blob/master/src/cmd/nm/doc.go
  • https://linux.die.net/man/1/c++filt
  • https://github.com/goccy/go-graphviz
  • https://research.swtch.com/interfaces

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 <binary finename> | 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

... but you can go much higher

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

Docs

bash $ cat testdata/go-graphviz.symtab | ./go-binsize-treemap -csv > docs/go-graphviz.csv $ cat testdata/go-graphviz.symtab | ./go-binsize-treemap > docs/go-graphviz.svg $ cat testdata/go-graphviz.symtab | ./go-binsize-treemap -w 4096 -h 4096 > docs/go-graphviz-4096x4096.svg $ cat testdata/cockroach.symtab | ./go-binsize-treemap -csv > docs/cockroach.csv $ cat testdata/cockroach.symtab | ./go-binsize-treemap > docs/cockroach.svg $ cat testdata/cockroach.symtab | ./go-binsize-treemap -w 4096 -h 4096 > docs/cockroach-4096x4096.svg $ cat testdata/skipper.symtab | ./go-binsize-treemap > docs/skipper.svg $ cat testdata/hugo.symtab | ./go-binsize-treemap -csv > docs/hugo.csv $ cat testdata/hugo.symtab | ./go-binsize-treemap > docs/hugo.svg $ cat testdata/hugo.symtab | ./go-binsize-treemap -w 1024 -h 128 > docs/hugo-1024x128.svg $ cat testdata/hugo.symtab | ./go-binsize-treemap -w 1024 -h 256 > docs/hugo-1024x256.svg $ cat testdata/hugo.symtab | ./go-binsize-treemap -w 1024 -h 512 > docs/hugo-1024x512.svg $ cat testdata/hugo.symtab | ./go-binsize-treemap -w 4096 -h 4096 > docs/hugo-4096x4096.svg $ cat testdata/hugo.symtab | ./go-binsize-treemap -w 16384 -h 16384 > docs/hugo-16384x16384.svg

Owner

  • Name: Nikolay Dubina
  • Login: nikolaydubina
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
message: If you reference this tool in publication, please cite it as below.
title: Go Binsize Treemap
abstract: Treemap of Go binary based on 
authors:
- family-names: Dubina
  given-names: Nikolay
version: 2.1
date-released: 2022-03-28
license: MIT
repository-code: https://github.com/nikolaydubina/go-binsize-treemap
url: https://github.com/nikolaydubina/go-binsize-treemap

GitHub Events

Total
  • Watch event: 81
  • Issue comment event: 2
Last Year
  • Watch event: 81
  • Issue comment event: 2

Committers

Last synced: 7 months ago

All Time
  • Total Commits: 46
  • Total Committers: 2
  • Avg Commits per committer: 23.0
  • Development Distribution Score (DDS): 0.043
Past Year
  • Commits: 2
  • Committers: 1
  • Avg Commits per committer: 2.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Nikolay Dubina n****b@g****m 44
dependabot[bot] 4****] 2

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 5
  • Total pull requests: 4
  • Average time to close issues: about 1 month
  • Average time to close pull requests: about 3 hours
  • Total issue authors: 2
  • Total pull request authors: 2
  • Average comments per issue: 2.0
  • Average comments per pull request: 1.0
  • Merged pull requests: 4
  • Bot issues: 0
  • Bot pull requests: 2
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • nikolaydubina (4)
  • mrbardia72 (1)
Pull Request Authors
  • dependabot[bot] (4)
  • nikolaydubina (3)
Top Labels
Issue Labels
bug (2) enhancement (1)
Pull Request Labels
dependencies (4)

Packages

  • Total packages: 2
  • Total downloads: unknown
  • Total dependent packages: 1
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 10
proxy.golang.org: github.com/nikolaydubina/go-binsize-treemap
  • Versions: 5
  • Dependent Packages: 1
  • Dependent Repositories: 0
Rankings
Stargazers count: 1.7%
Forks count: 3.5%
Average: 5.4%
Dependent packages count: 7.0%
Dependent repos count: 9.3%
Last synced: 4 months ago
proxy.golang.org: github.com/Nikolaydubina/go-binsize-treemap
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 5.8%
Average: 6.0%
Dependent repos count: 6.2%
Last synced: 4 months ago

Dependencies

go.mod go
  • github.com/lucasb-eyer/go-colorful v1.2.0
  • github.com/nikolaydubina/treemap v1.2.0
go.sum go
  • github.com/lucasb-eyer/go-colorful v1.2.0
  • github.com/nikolaydubina/treemap v1.1.0
  • github.com/nikolaydubina/treemap v1.2.0
.github/workflows/scorecard.yml actions
  • actions/checkout v3.1.0 composite
  • actions/upload-artifact v3.1.0 composite
  • github/codeql-action/upload-sarif v2.2.4 composite
  • ossf/scorecard-action v2.3.1 composite
.github/workflows/tests.yml actions
  • actions/checkout v2 composite
  • actions/setup-go v2 composite
  • codecov/codecov-action v1.0.10 composite