• Stars
    star
    444
  • Rank 98,300 (Top 2 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 3 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ” Go binary size SVG treemap

๐Ÿ” Go binary size SVG treemap

Make treemap breakdown of Go executable binary

Go Reference codecov Go Report Card go-recipes

$ 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

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

More Repositories

1

go-recipes

๐Ÿฆฉ Tools for Go projects
Go
4,036
star
2

go-cover-treemap

๐ŸŽ„ Go code coverage to SVG treemap
Go
484
star
3

calendarheatmap

๐Ÿ“… Calendar heatmap inspired by GitHub contribution activity
Go
393
star
4

llama2.go

LLaMA-2 in native Go
Go
187
star
5

go-instrument

โšก๏ธ Automatically add Trace Spans to Go methods and functions
Go
163
star
6

treemap

๐Ÿฌ Pretty Treemaps
Go
149
star
7

go-featureprocessing

๐Ÿ”ฅ Fast, simple sklearn-like feature processing for Go
Go
116
star
8

go-hackers-delight

"Hacker's Delight" in Go
Go
85
star
9

go-graph-layout

๐Ÿ”ฎ Graph Layout Algorithms in Go
Go
85
star
10

go-cover-treemap-web

Go
78
star
11

jsonl-graph

๐Ÿ JSONL Graph Tools
Go
72
star
12

import-graph

Collect data about your dependencies
Go
40
star
13

twitter-remover

Remove twitter likes, posts, retweets, replies, followers
38
star
14

watchhttp

๐ŸŒบ Run command periodically and expose latest STDOUT as HTTP endpoint
Go
32
star
15

go-ml-benchmarks

โฑ Benchmarks of machine learning inference for Go
Go
30
star
16

fpdecimal

๐Ÿ›ซ Fixed-Point Decimals
Go
29
star
17

fpmoney

๐Ÿงง Fixed-Point Decimal Money
Go
25
star
18

validate

๐Ÿฅฌ validate. simply.
Go
19
star
19

hq

๐Ÿ happy little queue
Go
16
star
20

smrcptr

detect mixing pointer and value method receivers
Go
13
star
21

neuroscience-landscape

๐ŸŒŒ Resources on Neuroscience
12
star
22

vertfn

Go linter for Vertical Function Ordering
Go
12
star
23

go-enum-encoding

Generate Go enum encoding
Go
12
star
24

go-enum-example

Go Enum: benchmarks, examples, analysis
Go
8
star
25

htmljson

๐Ÿซ Rich rendering of JSON as HTML in Go
Go
7
star
26

multiline-jsonl

Read and write multiline JSONL in Go
Go
6
star
27

openapi-inline-examples

๐ŸŒ Inline OpenAPI JSON examples from filenames
Go
6
star
28

htmlyaml

๐Ÿน render YAML as HTML in Go
Go
4
star
29

go-commentage

How far Go comments drifting behind?
Go
4
star
30

rchan

Go channel through Redis List
Go
4
star
31

mini-awesome-cv

๐Ÿ“ LaTeX Awesome-CV under 200LOC
TeX
4
star
32

go-instrument-example

Go
3
star
33

svgpan

Pan and Zoom of SVG in your Go front-end app in browser.
Go
3
star
34

go-bench-errors

Benchmarking Go errors
Go
3
star
35

mdpage

one-pager Markdown list from YAML
Go
3
star
36

consistentimports

Detect inconsistent import aliases
Go
2
star
37

go-callsite-stats

analyse function callsites
Go
2
star
38

read-seek-peeker

Go Reader that can Seek() and Peek()
Go
2
star
39

go-bench-stream

๐ŸŒŠ Go Benchmarks for Stream Processing
Go
2
star
40

go-bitset-example

Go Bitset: benchmarks, examples, analysis
Go
1
star
41

aws-s3-reader

Efficient Go Reader for large AWS S3 Objects
Go
1
star
42

go-bench-receiver

Which is more efficient value or pointer method receivers in Go?
Go
1
star
43

totp

TOTP (RFC-6238) and HOTP (RFC-4226)
Go
1
star
44

dotfiles

macOS, Linux
Vim Script
1
star
45

presentations

1
star
46

PINTOS

C
1
star
47

ARIA

C++
1
star
48

mini-blog

JavaScript
1
star
49

graph-tools-gallery

Inspiration gallery of graph tools
1
star