Subject: Re: [PATCH 2/2] upload-pack: reduce lock contention when writing packfile data

From: Patrick Steinhardt <[email-masked]>
Date: Tue, 3 Mar 2026 14:47:08 +0100

On Tue, Mar 03, 2026 at 08:35:40AM -0500, Jeff King wrote:
> On Tue, Mar 03, 2026 at 10:31:46AM +0100, Patrick Steinhardt wrote:
> > We would likely hit this issue if we insist on the buffer being
> > completely filled before sending it out. But that's why I adapted the
> > logic to say that we send out once we've filled it at least 2/3rds of
> > the pktline limit. So in your case above we wouldn't face an issue as
> > we'd already send the first 50kB, as it is smaller than 2/3rds of the
> > maximum length (~42kB).
> > 
> > That being said, you'll still be able to construct cases where we have
> > weird edge cases. For example if you consistently send one byte less
> > than 2/3rds of the capacity.
> 
> Right, my numbers were just meant as examples. Whatever the values, it
> means that whatever is generating the pack data (pack-objects or
> otherwise) really wants to be in sync with how upload-pack is buffering.
> Or vice versa. If we just pass back whole chunks of what we read() in
> upload-pack, then that happens automatically.

Yeah, that's fair. I'll include this part in v2 for now so that we can
discuss once the bigger picture emerges :)

Thanks!

Patrick