From: Karthik Nayak Date: Wed, 11 Nov 2026 16:48:30 GMT Subject: Re: [PATCH 4/4] object-file: create ODB transaction temporary directory eagerly Message-ID: In-Reply-To: <20261110002251.2007617-5-jltobler@gmail.com> Justin Tobler writes: > By default, ODB transactions for the "files" backend create their > temporary object directory lazily once the first loose object is about > to be written, and only if batched fsync is enabled. Transactions > configured for git-receive-pack(1) are the exception as the directory is > needed to quarantine incoming objects up front. Lazily creating the > temporary directory in this manner is awkward for a couple of reasons: > > - Writing loose objects has to know about the transaction internals to > trigger the lazy creation of the temporary object directory. > > - Whether objects are staged in a temporary object directory, and thus > whether they become visible at once on commit, depends on the > configured fsync method. > > Create the temporary object directory eagerly for every transaction when > it is started instead. This also ensures that no object is written to > the main object database before the transaction is committed. > > Note that committing a transaction migrates every written object into > the primary object directory even when batched fsync is disabled. This > adds some minor overhead to ODB transaction callers that previously only > used a temporary directory if batched fsync was enabled. The following > benchmark uses the default fsync configuration and adds 10000 files of 4 > KiB each to a freshly initialized repository via git-add(1): > > Benchmark 1: git add . (rev = HEAD~) > Time (mean ± σ): 895.0 ms ± 23.8 ms [User: 545.3 ms, System: 340.7 ms] > Range (min … max): 866.7 ms … 928.7 ms 20 runs > > Benchmark 2: git add . (rev = HEAD) > Time (mean ± σ): 956.3 ms ± 26.1 ms [User: 541.4 ms, System: 405.2 ms] > Range (min … max): 923.9 ms … 993.6 ms 20 runs > > Summary > git add . (rev = HEAD~) ran > 1.07 ± 0.04 times faster than git add . (rev = HEAD) > The explanation hre is well written and nicely explains what the cover letter didn't _cover_. Nice. > Typically large numbers of loose objects are not expected to be written > into an ODB transaction so the overhead here should be marginal. > Question: why is that? > Signed-off-by: Justin Tobler > --- > object-file.c | 56 +++++++++---------------------------------- > object-file.h | 1 - > odb/source-loose.c | 6 ----- > t/t0004-unwritable.sh | 19 +++++++-------- > 4 files changed, 19 insertions(+), 63 deletions(-) The changes itself looks good.