---
title: "Copy Hunting"
description: "Reading Zig's emitted LLVM IR as plain text and grepping it is a practical substitute for staring at disassembly when chasing implicit memcopies and binary bloat."
url: "https://swe.quest/articles/copy-hunting-7c2f19f97f1f7edc"
canonical: "https://tigerbeetle.com/blog/2023-07-26-copy-hunting"
source: "TigerBeetle"
published: "2023-07-26"
difficulty: "medium"
kind: "How-to"
reading_minutes: 11
tags: ["zig","compilers","performance","debugging","developer-tools"]
---

# Copy Hunting

A post on [TigerBeetle](https://swe.quest/sources/tigerbeetle.md), published 2023-07-26, 11 min read, How-to. Original: [https://tigerbeetle.com/blog/2023-07-26-copy-hunting](https://tigerbeetle.com/blog/2023-07-26-copy-hunting)

## Summary

Reading Zig's emitted LLVM IR as plain text and grepping it is a practical substitute for staring at disassembly when chasing implicit memcopies and binary bloat. A small line-by-line tool, copyhound, flags large \`llvm.memcpy\` calls per function and also sums IR lines per generic function name to expose monomorphization blowup, the same idea as cargo-llvm-lines. In TigerBeetle it traced copies to \`std.meta.eql\`, which was replaced with a comptime-checked word-wise byte comparison. In the Zig compiler it found an inlined float-parsing slow path costing 10 KB of stack, fixed with \`@setCold\`. Making comptime parameters runtime in a version-printing function cut 300 bytes from the binary.

Written by swe.quest, not by the author.

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

## Topics

- [Zig](https://swe.quest/tags/zig.md) (Languages)
- [Compilers](https://swe.quest/tags/compilers.md) (Compilers & runtimes)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Debugging](https://swe.quest/tags/debugging.md) (Engineering practices)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)

## Prerequisites

- Zig or Rust basics ([easy posts on Zig](https://swe.quest/tags/zig.md?difficulty=easy))
- compiler optimization basics ([easy posts on Performance engineering](https://swe.quest/tags/performance.md?difficulty=easy))
- generics and monomorphization

## Keywords

LLVM IR, TigerBeetle, copyhound, Zig, memcpy, cargo-llvm-lines, monomorphization

## Related posts

- [Synadia and TigerBeetle Pledge $512,000 to the Zig Software Foundation](https://swe.quest/articles/synadia-and-tigerbeetle-pledge-512-000-to-the-zig-software-foundation-124e30142ae18e3c.md): TigerBeetle · 2025-10-25 · Easy · 8 min read · Zig, Language design, Memory safety, Open source
  Synadia and TigerBeetle are jointly donating $512,000 to the Zig Software Foundation over two years, with no strings attached.
- [bun.report is Bun's new crash reporter](https://swe.quest/articles/bun-report-is-bun-s-new-crash-reporter-19b1535d615212f4.md): Bun · 2024-04-26 · Medium · 8 min read · Debugging, Zig, Developer tools, Privacy
  Bun v1.1.5 replaces unsymbolicated crash output with a compact ~150-byte bun.report URL that encodes platform, subcommand, commit SHA, a 64-bit feature-usage bitfield, crash type and message, and ASLR-adjusted stack addresses as base64 VLQs, with no personal information.
- [Speculative Optimizations for WebAssembly using Deopts and Inlining](https://swe.quest/articles/speculative-optimizations-for-webassembly-using-deopts-and-inlining-bb89e7c53ac7945f.md): V8 · 2025-06-24 · Hard · 17 min read · WebAssembly, Compilers, Runtimes & VMs, Performance engineering
  V8 in Chrome M137 adds speculative call\_indirect inlining and deoptimization support for WebAssembly, using runtime call-target feedback gathered by the Liftoff baseline compiler so TurboFan can inline up to four likely callees behind cheap instance and target checks.
- [Rewriting Bun in Rust](https://swe.quest/articles/rewriting-bun-in-rust-9aa67adf0dcbde60.md): Bun · 2026-07-08 · Medium · 29 min read · Rust, Zig, AI for coding, Refactoring & migrations, Memory safety
  Bun, a 535k-line Zig JavaScript runtime, was mechanically ported to Rust over 11 days using about 50 continuously running Claude Code workflows.
- [Speeding up LZ4 in ClickHouse](https://swe.quest/articles/speeding-up-lz4-in-clickhouse-dbbd26281ee7c0df.md): ClickHouse · 2023-04-12 · Hard · 32 min read · Performance engineering, Storage engines, C & C++, Algorithms, Analytics & OLAP
  LZ4 decompression often tops ClickHouse query profiles because highly compressible, cached columnar data shifts the cost onto CPU, yet storing data uncompressed proved impractical due to disk space.

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)
