tinygo compiler pains: memory use and slowness
Author: soypatCreated Sep 7, 2026Updated Sep 8, 2026
I'm using TinyGo to compile a webassembly client which weighs in at ~8MB once compiled with TinyGo. See repo here: https://github.com/soypat/netbird/pull/3 (build instructions under client/wasm/README.md)
This is my first time compiling WASM programs with TinyGo.
- So the first thing I noticed is that TinyGo will not check if it has all the tools it needs to succesfully compile, which has more often that not led to me and others trying to compile the project which fails after 20 minutes with errors like "wasm-opt not found".
- The next thing I noticed is how slow it is at compiling compared with Go. The project takes 20 minutes on my laptop. Now I understand getting the amazing optimizations of LLVM requires we put in the compute- but at times I really dont give a rat's bum about the output size, I just want to develop the TinyGo target and would be totally fine with a binary larger than the native Go compiler outputs in mere seconds.
- Next thing I started to notice is the memory usage of the TinyGo compiler.
tinygo build: The first process reaches ~4GB and stays there for a good whiletinygo wasm-ld: The second process tinygo spawns starts at 1.5GB and steadily creeps- After the first process switch the first process still consumes 4GB but uses absolutely no CPU usage. Instead wasm-ld uses 100% of single CPU.
(Compile is now about to use all my memory, will post this as is and close chrome to see if I can prevent a OOM)
Was not able to prevent an OOM. After 50 minutes of compiling wasm-ld started to slurp up all my remaining memory with great eagerness. This is a screenshot I took a minute before linux terminated the process.
A question for readers: Does the following make sense?
- Building WASM application with native Go takes milliseconds, uses virtually no memory. Result: 60MB binary
- Building WASM application with tinygo uses >10GB and takes >50 minutes. Result 8MB binary (before it started OOMing)
Source: tinygo-org/tinygo