Datadog engineers reduced their Agent's Go binary size by 77% (from 1.22 GiB back toward a much smaller footprint) over six months without removing any features. The main culprits were hidden transitive dependencies, reflection usage that disables linker dead-code elimination, and Go plugin imports that force dynamic linking. Their solutions included using build tags and package isolation to exclude optional code, auditing imports with tools like `go list`, `goda`, and `go-size-analyzer`, eliminating dynamic reflection (including upstream PRs to projects like kubernetes/kubernetes and uber-go/dig), and avoiding the `plugin` package. Each technique yielded significant reductions, with reflection and plugin changes alone contributing ~20% each.

3m read timeFrom infoq.com
Post cover image

Sort: