Optimizing Reference Deletions in Git
Web page · https://nayak.im/posts/optimizing-reference-deletion
First seen by Oriel on .
AI summary
This article explains how Git’s files backend deletes packed references and presents a merged C optimization that improves deletion speed by 18% through verbatim record copying.
- The files backend stores references as loose files or a sorted packed-refs file, creating scalability and update limitations for repositories with millions of references.
- Deleting a packed reference rewrites the entire packed-refs file, which can reach several gigabytes and makes individual deletions slow.
- The original C implementation reconstructed unchanged references with fprintf() and oid_to_hex(), while the Rust implementation copied their existing bytes directly.
- The merged fix uses fwrite() to copy unchanged packed-reference records verbatim, reducing benchmark wall time from 66.5 ms to 54.9 ms for 100,000 references.
- The patch, identified as fc70f528aa1927012538052014d7ea784b5a38fa, will be included in Git v2.98.
#git #rust #reftable #filesystems
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Hacker News: 36, latest observation ; +28 over observed period since
- Lobsters: 10, latest observation ; +9 over observed period since
Comments
Comment count reported by the source.
- Hacker News: 1, latest observation ; +1 over observed period since
- Lobsters: 0, latest observation ; 0 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Hacker News | 50416365 | https://nayak.im/posts/optimizing-reference-deletion/ Read discussion |
| Lobsters | ic1ora | https://nayak.im/posts/optimizing-reference-deletion/ Read discussion |