
"After the Datadog Agent grew from 428 MiB to 1.22 GiB over a period of 5 years, Datadog engineers set out to reduce its binary size. They discovered that most Go binary bloat comes from hidden dependencies, disabled linker optimizations, and subtle behaviors in the Go compiler and linker."
"Datadog engineers devised two practical ways to remove unnecessary dependencies: using build tags (//go:build feature_x) to exclude optional code, and moving code into separate packages so that non-optional packages remain as small as possible. Both techniques required systematically auditing imports to identify which files or packages could be excluded from a given build."
"The Go ecosystem provides three useful tools to help: go list, which lists all packages used in a build; goda, which visualizes dependency graphs and import chains to help understand why a given dependency is required; and go-size-analyzer, which shows how much space each dependency contributes to a binary."
The Datadog Agent binary grew from 428 MiB to 1.22 GiB over five years, increasing network costs and resource usage while worsening user perception. The growth resulted from new features, additional integrations, and large third-party dependencies like Kubernetes SDKs. Go's transitive dependency model compounds this issue, where small changes pull in hundreds of packages. Datadog engineers addressed this through systematic dependency auditing using build tags to exclude optional code and reorganizing code into separate packages. Tools like go list, goda, and go-size-analyzer helped identify and visualize unnecessary dependencies. Moving single functions into separate packages removed approximately 570 packages and 36 MB from binaries not using them.
Read at InfoQ
Unable to calculate read time
Collection
[
|
...
]