From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Shawn Pearce <spearce@spearce.org>,
Martin von Gagern <Martin.vGagern@gmx.net>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [BUG] resolved deltas
Date: Thu, 28 Aug 2014 18:08:21 -0400 [thread overview]
Message-ID: <20140828220821.GA31545@peff.net> (raw)
In-Reply-To: <53FB66D1.709@web.de>
On Mon, Aug 25, 2014 at 06:39:45PM +0200, René Scharfe wrote:
> Thanks, that looks good. But while preparing the patch I noticed that
> the added test sometimes fails. Helgrind pointed outet a race
> condition. It is not caused by the patch to turn the asserts into
> regular ifs, however -- here's a Helgrind report for the original code
> with the new test:
Interesting. I couldn't convince Helgrind to catch such a case, but it
makes sense. We split the delta-resolving work by dividing up the base
objects. We then find any deltas that need that base object (which is
read-only). If there's only one instances of the base, then we'll be the
only thread working on those delta. But if there are two such bases,
they're going to look at the same deltas.
So we need some kind of mutual exclusion so that only one thread
proceeds with resolving the delta. The "real_type" check sort-of
functions in that way (except of course it is not actually thread safe).
So one obvious option is just a coarse-grained global lock to modify or
check real_type fields. That would probably perform badly (lots of
useless lock contention on unrelated objects), but at least it would
work.
If we accept pushing a lock into _each_ object_entry, then we would get
a lot less lock contention (i.e., none at all in the common case of no
duplicates). The cost is storing one lock per object, though. Not great,
but probably OK.
Is there some way we can make real_type itself more atomic? I.e., use it
as the mutex with the rule that we do not "claim" the object_entry as
ours to work on until we atomically set delta_obj->real_type. I think
doing a compare-and-swap looking for OBJ_REF_DELTA and replacing it with
base->real_type would be enough there (and substitute OBJ_OFS_DELTA for
the second conditional, of course).
However, I'm not sure we can portably rely on having a compare-and-swap
primitive (or that we want to go through the hassle of conditionally
using it).
-Peff
next prev parent reply other threads:[~2014-08-28 22:08 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 11:35 [BUG] resolved deltas Petr Stodulka
2014-08-21 18:25 ` Petr Stodulka
2014-08-22 19:41 ` Martin von Gagern
2014-08-23 10:12 ` René Scharfe
2014-08-23 10:56 ` Jeff King
2014-08-23 11:04 ` Jeff King
2014-08-23 11:18 ` Jeff King
2014-08-25 16:39 ` René Scharfe
2014-08-28 22:08 ` Jeff King [this message]
2014-08-28 22:15 ` Jeff King
2014-08-28 23:04 ` Jeff King
2014-08-28 22:22 ` Jeff King
2014-08-28 23:14 ` Junio C Hamano
2014-08-29 20:55 ` Jeff King
2014-08-29 20:57 ` [PATCH 1/2] index-pack: fix race condition with duplicate bases Jeff King
2014-08-29 20:58 ` [PATCH 2/2] index-pack: handle duplicate base objects gracefully Jeff King
2014-08-29 21:56 ` Junio C Hamano
2014-08-29 22:08 ` Jeff King
2014-08-30 2:59 ` Shawn Pearce
2014-08-30 13:16 ` Jeff King
2014-08-30 16:00 ` René Scharfe
2014-08-31 15:17 ` Jeff King
2014-08-31 16:30 ` René Scharfe
2014-08-31 1:10 ` Shawn Pearce
2014-08-31 15:24 ` Jeff King
2014-08-31 22:23 ` Junio C Hamano
2014-08-30 13:23 ` [PATCH 3/2] t5309: mark delta-cycle failover tests as passing Jeff King
2014-08-31 15:15 ` Jeff King
2014-09-02 17:19 ` Junio C Hamano
2014-08-25 17:19 ` [BUG] resolved deltas Shawn Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140828220821.GA31545@peff.net \
--to=peff@peff.net \
--cc=Martin.vGagern@gmx.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).