---
title: "I made a build profiler to understand Bun's compile times"
slug: i-made-a-build-profiler-to-understand-buns-compile-times
url: https://listedarticles.com/articles/i-made-a-build-profiler-to-understand-buns-compile-times
canonical_url: https://lalitm.com/post/buildprof/
content_type: blog_post
language: en
published_at: 2026-09-12T12:00:00.000Z
updated_at: 2026-09-16T16:13:06.062Z
author: "Lalit Maganti"
author_url: https://lalitm.com/
authored_by: agent
publisher: "Lalit Maganti"
publisher_url: https://lalitm.com
topics: ["Performance", "Build Tools", "Rust", "Zig", "Profiling", "Bun", "Open Source"]
license: all-rights-reserved
word_count: 318
reading_minutes: 1
citation: "Lalit Maganti, Lalit Maganti. \"I made a build profiler to understand Bun's compile times.\" 12 Sept 2026. https://lalitm.com/post/buildprof/ (all-rights-reserved)"
# The full text follows. The web page shows an extract and sends readers
# to the source above; quote the citation and link the canonical URL.
---

# I made a build profiler to understand Bun's compile times

> Lalit Maganti built buildprof, an open-source Linux tool that records every process spawned during a build and renders them on a shared timeline. He used it to investigate the 5x speed difference between Bun's Zig and Rust builds, tracing the bottleneck to Full LTO in the linker and a downloaded WebKit library that amplified it.

> **Indexed summary.** This entry is an agent-written synopsis of an article first published at [lalitm.com](https://lalitm.com/post/buildprof/). Read the original for the full text.

The investigation started with a tweet from Bun's lead architect claiming a greater-than-5x build speedup when switching from Zig to Rust. Maganti was sceptical because Zig is generally known for fast compilation, and the tweet mentioned Full LTO only in passing. He reproduced the timing gap on his own machine, then built the tool he needed to understand it.

buildprof works by intercepting process launches — recursively, including sub-children — and recording start times, durations, and file reads/writes. The result is a Perfetto-compatible timeline that shows the entire build as a process tree. It works with any build system: `buildprof -- cargo build`, `buildprof -- ninja -C out/`, etc.

## Key points

- In the Zig-era build, the `ld.lld` linker ran alone for over 16 minutes at the very end, constituting two-thirds of the entire build time. LTO compiler passes accounted for almost all of that.
- Switching Bun's own code to ThinLTO reduced the link to around 13 minutes — still slow, because the downloaded WebKit library was also built with Full LTO.
- Rebuilding WebKit with ThinLTO settings brought the full build from 24 minutes down to 15.
- Even with matching LTO settings, the Zig build remained slower because it compiled everything as a single monolithic module, while the Rust build was split into over 90 crates that could compile in parallel.
- buildprof is open source; the article links to the GitHub repository and includes shareable interactive traces for each measured scenario.

## Why it matters

The post demonstrates how a simple tracing tool can turn a confusing build-time claim into a clear, causal explanation. buildprof fills a gap: most build profilers are specific to a single build system, while this one works at the OS process level and spans toolchain boundaries.

---

*Source: [I made a build profiler to understand Bun's compile times](https://lalitm.com/post/buildprof/)*
