hn.today

Optimizing Reference Deletions in Git

nayak.im3 points0 comments
Screenshot of Optimizing Reference Deletions in Git

Git’s traditional files reference backend stores newly created branches and tags as separate loose files, while housekeeping can consolidate them into a sorted packed-refs file. Packing reduces the cost and limitations of managing millions of individual files, but creates a bottleneck: deleting a reference already in the packed file requires rewriting that file. In a demonstrated repository with a 700 MB packed-refs file, deleting one reference took about 2.14 seconds. The newer reftable backend avoids this particular cost by representing deletions as tombstones, but the files backend remains widely used while Git transitions toward reftable.

A Rust implementation of the files backend, built as an experiment, appeared faster than Git’s C implementation when deleting packed references. Investigating the difference revealed that C rewrote each unchanged reference by formatting its fields again, even though the original record was already available. The fix tracks the record’s location and copies its bytes directly into the new file with fwrite, avoiding unnecessary formatting. Benchmarks showed an approximately 18% speed improvement, bringing C performance in line with the Rust version. The change has been merged into Git master and is slated for Git 2.98, illustrating how a small optimization can improve a long-established code path despite broader plans to replace it.

Read on nayak.im0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Ggml v1.0.0

Ggml v1.0.0

ggml 1.0.0 removes deprecated public APIs and legacy DIAG_MASK operations, while adding configurable YaRN truncation and FP8 support. It also improves backend performance with quantized matrix multiplication, fused MoE operations, and new attention and scheduling paths. (github.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.