Subject: Re: remove_duplicates() in builtin/fetch-pack.c is O(N^2)

From: Martin Fick <[email-masked]>
Date: Thu, 24 May 2012 19:32:36 -0600

On Thursday, May 24, 2012 07:04:34 pm Jeff King wrote:
> On Thu, May 24, 2012 at 06:54:56PM -0600, Martin Fick 
wrote:
> > > Yes, exclusively warm. And all of the refs were
> We'd have to give some thought to potential race
> conditions, though. Usually pack-refs isn't modifying
> the ref, so it can just write out the value to the
> packed-refs file, then delete the loose ref if nobody
> has touched it since we wrote. But here we're combining
> it with a modification, so I suspect there would be a
> race with another process trying to modify it.

Yeah, I thought about that.  Could you just right the new 
packed-ref file with the new refs and the old refs which 
were in the file already, then just delete any loose refs 
which were ones which were just added by this operation, 
only if they have not changed?

This way, if someone else modifies one of the same refs, 
they could just win?

-Martin

-- 
Employee of Qualcomm Innovation Center, Inc. which is a 
member of Code Aurora Forum