Go-binsize-treemap - Go binary size SVG treemap

Overview

🔍 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

   

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

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.
  • 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 
   
     | 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

Issues
  • issue with input for some go nm

    issue with input for some go nm

    from reddit: https://old.reddit.com/r/golang/comments/scexuw/visualise_treemap_of_your_go_executable_binary/

    That's a nice tool. I think my nm is a little different from yours. I get errors like 2022/01/25 12:39:22 error parasing symtab file at line num(0): wrong size field: strconv.Atoi: parsing "409a80": invalid syntax: line: 409a80 0 t the line (line 1; the line numbering in errors is off by one) from go tool nm is one of about 30 which appear at the top of the output when I nm non-trivial programs. (go 1.17.6 on linux/amd64)

    bug 
    opened by nikolaydubina 5
Releases(v0.2.0)
  • v0.2.0(Mar 9, 2022)

    • Fixed wrong CLI param
    • Added parsing C symbol names (non Go strings)
    • Added summing all unknown symbols into "unknown" node

    Unresolved issues

    • Total size still mismatches
    • U symbols have very large, same size (from tens of MBs to GBs) which is wrong. More research needed to fix.
    Source code(tar.gz)
    Source code(zip)
  • v0.1.0(Jan 25, 2022)

Owner
Nikolay Dubina
Nikolay Dubina
2D rendering for different output (raster, pdf, svg)

draw2d Package draw2d is a go 2D vector graphics library with support for multiple outputs such as images (draw2d), pdf documents (draw2dpdf), opengl

llgcode 928 Aug 9, 2022
Rasterx is an SVG 2.0 path compliant rasterizer that can use either the golang vector or a derivative of the freetype anti-aliaser.

rasterx Rasterx is a golang rasterizer that implements path stroking functions capable of SVG 2.0 compliant 'arc' joins and explicit loop closing. Pat

Steven R Wiley 101 Jul 28, 2022
Go Language Library for SVG generation

SVGo: A Go library for SVG generation The library generates SVG as defined by the Scalable Vector Graphics 1.1 Specification (http://www.w3.org/TR/SVG

Anthony Starks 1.9k Aug 8, 2022
Cairo in Go: vector to SVG, PDF, EPS, raster, HTML Canvas, etc.

Canvas is a common vector drawing target that can output SVG, PDF, EPS, raster images (PNG, JPG, GIF, ...), HTML Canvas through WASM, and OpenGL. It h

Taco de Wolff 1k Aug 16, 2022
gensvg generates SVG to an io.Writer

gensvg: A Go library for SVG generation The library generates SVG as defined by the Scalable Vector Graphics 1.1 Specification

Anthony Starks 17 Jan 10, 2022
A simple API written in Go that creates badges in SVG format, based on the requested route.

A simple API written in Go that creates badges in SVG format, based on the requested route. Those graphics can be used to style README.md files, or to add tags to webpages.

Toby 3 Jul 2, 2021
Very simple SVG to PNG converter library using the Inkscape.

svg2png Description Very simple SVG to PNG converter library using the Inkscape.

null 0 Jan 11, 2022
Snippit - Creates syntax-highlighted code snippets in png or svg format

snippit creates syntax-highlighted code snippets in png or svg format. Installat

Julius Hinze 6 Jun 29, 2022
Generate image plots of processes' memory usage very quickly, within a single binary.

memplot A small utility written in golang to quickly plot memory usage of processes. memplot constantly samples memory usage of a process, for a given

Alessandro 173 Apr 17, 2021
🎄 Go code coverage to SVG treemap

?? Go cover to Treemap Useful when you have large project with lots of files and packages $ go install github.com/nikolaydubina/[email protected]

Nikolay Dubina 104 Aug 17, 2022
A tool to analyze and troubleshoot a Go binary size.

goweight A tool to analyze and troubleshoot a Go binary size. For more, see this blog post ✅ Get a breakdown of all modules inside a binary ✅ Supports

Dotan J. Nahum 1.5k Aug 17, 2022
A lightweight replacement for the standard fmt package, reduces binary size by roughly 400kb in a hello world

console This is a lightweight replacement for the fmt package, reduces the binary size by roughly 400kb in a hello world program. Please note: This pa

null 1 Nov 7, 2021
searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

searchHIBP is a golang tool that implements binary search over a hash ordered binary file.

fblz 0 Nov 9, 2021
Shotizam analyzes the size of Go binaries

Shotizam Shotizam analyzes the size of Go binaries and outputs SQL with size info for analysis in SQLite3. $ shotizam --sqlite /some/go.binary SQLite

Brad Fitzpatrick 571 Jul 29, 2022
Shotizam analyzes the size of Go binaries

Shotizam Shotizam analyzes the size of Go binaries and outputs SQL with size info for analysis in SQLite3. $ shotizam --sqlite /some/go.binary SQLite

Brad Fitzpatrick 571 Jul 29, 2022
Shotizam analyzes the size of Go binaries

Shotizam Shotizam analyzes the size of Go binaries and outputs SQL with size info for analysis in SQLite3. $ shotizam --sqlite /some/go.binary SQLite

Brad Fitzpatrick 571 Jul 29, 2022
A simple thread-safe, fixed size LRU written in Go. Based on dominictarr's Hashlru Algorithm. 🔃

go-hashlru A simple thread-safe, fixed size LRU written in Go. Based on dominictarr's Hashlru Algorithm. ?? Uses map[interface{}]interface{} to allow

Saurabh Pujari 70 Jul 3, 2022
A tool to filter URLs by parameter count or size

GoFilter A tool to filter URLs by parameter count or size. This tool requires unique sorted URL list. For example: cat hosts.txt | sort -u > sorted &&

Ayberk ESER 7 Sep 10, 2021
A Connected Graph Generator tool that construct graphs of some given size

graph graph is a Connected Graph Generator tool that construct graphs of some given size. Notice that it generates all possible connected, undirected

Nicolas A Perez 0 Nov 5, 2021
Converts a number to its English counterpart. Uses arbitrary precision; so a number of any size can be converted.

Converts a number to its English counterpart. Uses arbitrary precision; so a number of any size can be converted.

null 0 Dec 14, 2021
Removes unnecessarily saved git objects to optimize the size of the .git directory.

Git Repo Cleaner Optimizes the size of the .git directory by removing all of the files that are unnecessarily-still-saved as part of the git history.

Omar Yasser 2 Mar 24, 2022
This provides the lru package which implements a fixed-size thread safe LRU cache

golang-lru This provides the lru package which implements a fixed-size thread sa

byx 0 Dec 22, 2021
Image size analyzer for jpg/png/gif/webp

imgsz Image size analyzer for jpg/png/gif/webp Usage // DecodeSize decodes the dimensions of an image that has // been encoded in a registered format.

源文雨 0 Jan 8, 2022
YouTube'da altyazısı olan veya otomatik olarak oluşturulmuş altyazılı videolarda istediğiniz kelimenin hangi saat, dakika ve saniye de geçtiğini size gösterip aradığınız şeyi hızlıca bulmanızı sağlar.

YouTube Subtitles YouTube'da altyazısı olan veya otomatik olarak oluşturulmuş altyazılı videolarda istediğiniz kelimenin hangi saat, dakika ve saniye

İbrahim Can Mercan 2 Mar 4, 2022
2D rendering for different output (raster, pdf, svg)

draw2d Package draw2d is a go 2D vector graphics library with support for multiple outputs such as images (draw2d), pdf documents (draw2dpdf), opengl

llgcode 928 Aug 9, 2022
Rasterx is an SVG 2.0 path compliant rasterizer that can use either the golang vector or a derivative of the freetype anti-aliaser.

rasterx Rasterx is a golang rasterizer that implements path stroking functions capable of SVG 2.0 compliant 'arc' joins and explicit loop closing. Pat

Steven R Wiley 101 Jul 28, 2022
Go Language Library for SVG generation

SVGo: A Go library for SVG generation The library generates SVG as defined by the Scalable Vector Graphics 1.1 Specification (http://www.w3.org/TR/SVG

Anthony Starks 1.9k Aug 8, 2022
Cairo in Go: vector to SVG, PDF, EPS, raster, HTML Canvas, etc.

Canvas is a common vector drawing target that can output SVG, PDF, EPS, raster images (PNG, JPG, GIF, ...), HTML Canvas through WASM, and OpenGL. It h

Taco de Wolff 1k Aug 16, 2022