Skip to Content
marmot

There are two modes, because fast rebuilds and deep optimization pull in opposite directions.

ModeCommandUse it for
dev (default)marmot buildDay to day work. Each package is compiled on its own and cached.
releasemarmot build -releaseShipping. The whole program is optimized together. Builds take longer.
releasedevpackageobject, cachedpackageobject, cachedlinkpackagewhole programpackagelink

Dev builds

Each package is compiled separately and cached, so an edit recompiles little. Three things make dev builds fast:

  • A fast code generator. Dev builds write machine code directly, without LLVM. Its code is not optimized. MARMOT_TIER0=0 uses LLVM instead: slower builds, faster code.
  • Background optimization. After a dev build returns, the packages it compiled are compiled again with LLVM at -O2 on idle cores, and later builds link those optimized objects. MARMOT_TIER1=0 turns this off.
  • An incremental front end. Rebuilds type check and compile only the changed packages and the packages that import them. MARMOT_INCREMENTAL=0 turns it off.

Release builds

The optimizer sees the whole program, which allows inlining across packages and removal of code that nothing uses. Release builds use -O3 and every specialization. MARMOT_RELEASE=1 makes -release the default.

FlagEffect
-O zOptimize for size: the smallest binary.
-O sOptimize for size, less aggressively.
-sLeave out file and line tables. Smaller, but panics show no source lines.
-pgo-gen, -pgo fileProfile guided optimization.

The smallest possible binary:

marmot build -release -O z -s -o app ./cmd/app

Numbers

devreleasego
hello world with println148 KB1.68 MB
hello world with fmt.Println665 KB2.4 MB
run time, 43 programs1.4x faster with MARMOT_TIER0=01.6x faster1.0x

See Benchmarks for the method.

Environment variables

VariableMeaning
MARMOT_RELEASE=1Make -release the default.
MARMOT_TIER0=0Dev builds use LLVM instead of the fast code generator.
MARMOT_TIER1=0Turn off background optimization of dev builds.
MARMOT_INCREMENTAL=0Turn off the incremental front end.
MARMOT_CACHE_MAX_MBSize cap of the build cache in megabytes (default 4096).
GOMAXPROCS, GOGCAs in Go.

On this page

Was this page helpful?

Report an issueOpen issues