# A Rust experiment uncovers an 18% speedup in Git reference deletion

Original title: Optimizing Reference Deletions in Git

> Hacker News story 50416365 · language: en · submitted 2026-11-08
> Web version: https://zeli.app/story/50416365
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 36 · by [nayak](<https://news.ycombinator.com/user?id=nayak>) · 💬 1
[original](<https://nayak.im/posts/optimizing-reference-deletion/>) · [HN discussion](<https://news.ycombinator.com/item?id=50416365>)

## Summary

Git's files backend rewrites the entire packed-refs file on every deletion, which can be gigabytes in large monorepos. While benchmarking a Rust rewrite of the backend against the C original, the author noticed the Rust version was faster. The C code was needlessly reformatting untouched references with fprintf and oid_to_hex; writing them verbatim with fwrite instead cut deletion time by about 18%. The patch is now merged and ships in Git v2.98.

## Key quote

> The C version iterates through the references and writes any unmodified reference to the 'packed-refs' file. But unlike the Rust version, which writes it verbatim, it calls write_packed_entry().

---

## Cite

- Page: https://zeli.app/story/50416365
- Date: 2026-11-08
- Source: nayak.im (https://nayak.im/posts/optimizing-reference-deletion/)
- Hacker News: https://news.ycombinator.com/item?id=50416365

## Other languages

- zh: https://zeli.app/zh/story/50416365 · markdown: https://zeli.app/zh/story/50416365.md
- ja: https://zeli.app/ja/story/50416365 · markdown: https://zeli.app/ja/story/50416365.md
- ko: https://zeli.app/ko/story/50416365 · markdown: https://zeli.app/ko/story/50416365.md
- de: https://zeli.app/de/story/50416365 · markdown: https://zeli.app/de/story/50416365.md
- es: https://zeli.app/es/story/50416365 · markdown: https://zeli.app/es/story/50416365.md
- ru: https://zeli.app/ru/story/50416365 · markdown: https://zeli.app/ru/story/50416365.md
