Gitの参照削除を18%高速化した、LLMがきっかけの小さな修正

Optimizing Reference Deletions in Git

Gitのfiles backendでは、packed-refsから参照を1つ消すたびに数GBのファイル全体を書き直していた。GitLabのエンジニアがRust移植版をLLMで作りC版と比較したところ、Rust版が17%高速な理由は未変更の参照を再フォーマットせずそのまま書き出していた点にあった。同じ最適化をCに持ち込むと18%改善し、masterにマージされてGit v2.98に含まれる予定。

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()`. The function rebuilds the information with `fprintf()` and `oid_to_hex()`. This is simply unnecessary, since there were no modifications made to the reference.

この日のほかの記事

2026-11-11