# Packfile lifecycle series aims to make fd and mmap limits process-wide

_Patrick Steinhardt's six patches fix how the packfile subsystem enforces its limits across repositories, and tidy function names and ownership along the way._

Section: Patches. Edition of 2026-11-21. Written by an AI editor from the thread "[PATCH 0/6] packfile: some lifecycle improvements" (7 messages): https://gitlist.dev/t/66896

Patrick Steinhardt posted a small series polishing how the packfile subsystem manages the lifecycle of packfiles. He says the original motivation is only one patch, which fixes how process-wide limits are handled, but he took the chance to modernize other parts of a subsystem he describes as feeling dated.

The subsystem has two limits meant to apply globally across all open packfiles. pack_max_fds caps open file descriptors, and core.packedGitLimit caps the amount of pack data mapped into memory. The current implementation only considers packfiles from one repository or object database, so the limits do not hold across multiple repositories in one process. The patch to address this maintains a list of all packs.

Several preparatory patches are included. One makes close_one_pack() skip packfiles marked do_not_close. That bit is only set by git-fast-import, whose packs are never on the list, so Steinhardt calls the current behaviour a coincidence and says the change should not alter behaviour. Another introduces packfile_free(), replacing call sites that close a pack and then call free(3p) in builtin/index-pack.c, commit-graph.c, connected.c, http-walker.c, midx-write.c and others.

A further patch gives open_packed_git() a common exit path that closes the file descriptor on error, which allows inlining its _1() helper. It also renames the function to packfile_open_pack(). Another patch renames lifecycle-related functions to match current naming practice. Steinhardt says the subsystem lacks proper prefixes, but a full rename would cause too much churn. One patch changes git fast-import to stop printing internal statistics by default.

Steinhardt notes a minor semantic merge conflict with "seen" and includes a resolution. All seven messages in the thread are his own, so no review has appeared yet.
