---
title: "Debugging Go compiler performance in a large codebase"
description: "incident.io sped up builds of its Go monolith by tracing the compiler with `go build -debug-trace` and viewing the output in Perfetto."
url: "https://swe.quest/articles/debugging-go-compiler-performance-in-a-large-codebase-46b7968c79fa2123"
canonical: "https://incident.io/blog/go-build-faster"
source: "incident.io"
published: "2024-01-15"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["go","build-systems","developer-productivity","performance"]
---

# Debugging Go compiler performance in a large codebase

A post on [incident.io](https://swe.quest/sources/incident-io.md), published 2024-01-15, 6 min read, Case study. Original: [https://incident.io/blog/go-build-faster](https://incident.io/blog/go-build-faster)

## Summary

incident.io sped up builds of its Go monolith by tracing the compiler with \`go build -debug-trace\` and viewing the output in Perfetto. The trace exposed long stretches of idle cores while a large \`pkg/domain\` package (about 250 table structs, roughly 100k lines) compiled. Using \`depguard\` to cut that package's dependencies, notably the goldmark markdown library, let it start compiling at about 15s instead of 25s. Moving generated gomega test matchers into a separate \`pkg/domain/matchers\` package cut the package's compile time by about 30%, which matters because it is rebuilt 10–20 times a day across the team.

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)
- [Developer productivity](https://swe.quest/tags/developer-productivity.md) (Engineering practices)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

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

## Keywords

go build -debug-trace, Perfetto, depguard, actiongraph, gomega, goldmark

## Related posts

- [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.
- [How we reduced the size of our Agent Go binaries by up to 77%](https://swe.quest/articles/how-we-reduced-the-size-of-our-agent-go-binaries-by-up-to-77-01b71ba25e3ec4b1.md): Datadog Engineering · 2026-02-18 · Medium · 14 min read · Go, Build systems, Compilers, Performance engineering
  Datadog cut its Agent's Go binary sizes by up to 77% between versions 7.60.0 and 7.68.0 without removing features.
- [Tracking developer build times to decide if the M3 MacBook is worth upgrading](https://swe.quest/articles/tracking-developer-build-times-to-decide-if-the-m3-macbook-is-worth-upgrading-203da83e8808415f.md): incident.io · 2023-12-19 · Medium · 17 min read · Developer productivity, Go, Hardware, Performance engineering, Build systems
  incident.io built a custom Go hot-reloader that records build telemetry (platform, memory, power source, Go build stages, triggering files) from developer MacBooks and pipes it through Fivetran into BigQuery.
- [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.
- [The quest for the five minute deploy](https://swe.quest/articles/the-quest-for-the-five-minute-deploy-9b91763fbfd58020.md): incident.io · 2025-07-22 · Medium · 9 min read · CI/CD, Go, Build systems, Caching, Developer productivity
  incident.io cut CI/CD times by moving from a hosted provider, where a cold Go build cache made compiling 15,000+ tests across 350+ packages the bottleneck, to Buildkite running on three self-hosted 48-vCPU servers.

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)
