User Tools

Site Tools


notes:programming:golang_filesize_optimization

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
notes:programming:golang_filesize_optimization [2022/10/06 20:20] – created asienotes:programming:golang_filesize_optimization [2022/10/06 20:32] (current) asie
Line 1: Line 1:
 ====== Go filesize optimization tricks ====== ====== Go filesize optimization tricks ======
  
-Let's assume that you want to use TinyGo, but can't. What tricks can you employ to make your Go file smaller?+Let's assume that you want to use TinyGo, but can'- in my case, it was high GC pauses due to it using a simple mark/sweep GC designed for 64KB heaps, not multi-megabyte ones... What tricks can you employ to make your Go file smaller?
  
 Developed as part of WebAssembly ZZT port research - [[https://github.com/OpenZoo/openzoo-go|OpenZoo/openzoo-go]]. Developed as part of WebAssembly ZZT port research - [[https://github.com/OpenZoo/openzoo-go|OpenZoo/openzoo-go]].
Line 11: Line 11:
 ===== Compilation ===== ===== Compilation =====
  
-  * Add `-trimpath -ldflags="-s -w"at the end of the `go buildcomamnd to remove/reduce debugging information. +  * Add ''-trimpath -ldflags="-s -w"'' at the end of the ''go build'' comamnd to remove/reduce debugging information. 
-  * Replace `go buildwith `garble -tiny buildto remove debugging information/stack traces even further. (Install instructions for garble [here](https://github.com/burrowers/garble).) +  * Replace ''go build'' with ''garble -tiny build'' to remove debugging information/stack traces even further. (Install instructions for garble [here](https://github.com/burrowers/garble).) 
-  * For WebAssembly, use `wasm-opt -Oz -o out/openzoo-go-optimized.wasm out/openzoo-go.wasmto run a separate optimization pass on the WASM binary. +  * For WebAssembly, use ''wasm-opt -Oz -o out/openzoo-go-optimized.wasm out/openzoo-go.wasm'' to run a separate optimization pass on the WASM binary. 
-  * Use `-gcflags=all="-B"to disable bounds checking.+  * Use ''-gcflags=all="-B"'' to disable bounds checking.
notes/programming/golang_filesize_optimization.1665087618.txt.gz · Last modified: 2022/10/06 20:20 by asie