---
title: "How we reduced the size of our Agent Go binaries by up to 77%"
description: "Datadog cut its Agent's Go binary sizes by up to 77% between versions 7.60.0 and 7.68.0 without removing features."
url: "https://swe.quest/articles/how-we-reduced-the-size-of-our-agent-go-binaries-by-up-to-77-01b71ba25e3ec4b1"
canonical: "https://www.datadoghq.com/blog/engineering/agent-go-binaries/"
source: "Datadog Engineering"
published: "2026-02-18"
difficulty: "medium"
kind: "Case study"
reading_minutes: 14
tags: ["go","build-systems","compilers","performance"]
---

# How we reduced the size of our Agent Go binaries by up to 77%

A post on [Datadog Engineering](https://swe.quest/sources/datadog.md), published 2026-02-18, 14 min read, Case study. Original: [https://www.datadoghq.com/blog/engineering/agent-go-binaries/](https://www.datadoghq.com/blog/engineering/agent-go-binaries/)

## Summary

Datadog cut its Agent's Go binary sizes by up to 77% between versions 7.60.0 and 7.68.0 without removing features. The work combined three things: auditing imports with go list, goda and go-size-analyzer; moving code behind build tags or into separate packages; and re-enabling the linker's method dead code elimination. The last required finding reflect.MethodByName uses with -dumpdep and whydeadcode, patching about a dozen dependencies and forking text/template, which yielded 16–25% per binary. A single misplaced function had pulled 570 Kubernetes packages into trace-agent, about 36 MiB, and similar fixes upstream gave Kubernetes 16–37% reductions.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Go](https://swe.quest/tags/go.md) (Languages)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- Go build tags ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- Go packages and imports ([easy posts on Go](https://swe.quest/tags/go.md?difficulty=easy))
- linker basics

## Keywords

Datadog Agent, goda, go-size-analyzer, whydeadcode, reflect, text/template, Kubernetes

## Related posts

- [Debugging Go compiler performance in a large codebase](https://swe.quest/articles/debugging-go-compiler-performance-in-a-large-codebase-46b7968c79fa2123.md): incident.io · 2024-01-15 · Medium · 6 min read · Go, Build systems, Developer productivity, Performance engineering
  incident.io sped up builds of its Go monolith by tracing the compiler with \`go build -debug-trace\` and viewing the output in Perfetto.
- [From hand-tuned Go to self-optimizing code: Building BitsEvolve](https://swe.quest/articles/from-hand-tuned-go-to-self-optimizing-code-building-bitsevolve-65732e9f0f979e91.md): Datadog Engineering · 2025-09-18 · Medium · 17 min read · Performance engineering, Go, AI agents, Cost optimization, Compilers
  Datadog cut CPU in Go hot paths by removing compiler bounds checks in NormalizeTag (25% faster, 0.75% service CPU) and adding an ASCII fast path to NormalizeTagArbTagValue (90% faster, hundreds of thousands of dollars in projected annual savings), guided by production data showing nearly all inputs were ASCII.
- [Engineering nits: Generating code faster](https://swe.quest/articles/engineering-nits-generating-code-faster-1820d3fbfc60303a.md): incident.io · 2023-12-11 · Medium · 5 min read · Go, Developer productivity, Performance engineering, Build systems
  incident.io cut a Go code-generation step from about 16 seconds to under half a second (97% faster) by adding commonly used imports directly to the generator's template.
- [From single pull requests to full software packages: Detecting malicious code at scale](https://swe.quest/articles/from-single-pull-requests-to-full-software-packages-detecting-malicious-code-at-717a58a001a046a1.md): Datadog Engineering · 2026-06-02 · Medium · 12 min read · Supply chain security, Threat detection, AI agents, LLMs, Cost optimization
  Datadog extended BewAIre, its LLM-based malicious code detector, from pull requests to full dependency packages by stacking a cheap filter model in front of an agentic investigation model.
- [Performance improvements in the Datadog Agent metrics pipeline](https://swe.quest/articles/performance-improvements-in-the-datadog-agent-metrics-pipeline-2d01cccf9e289314.md): Datadog Engineering · 2023-01-31 · Medium · 11 min read · Performance engineering, Go, Observability, Algorithms
  Profiling the Go-based Datadog Agent under heavy DogStatsD load showed that computing a unique context key per metric, especially sorting and deduplicating tags, dominated CPU.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
