From: Jeff King <peff@peff.net>
To: David Kastrup <dak@gnu.org>
Cc: git@vger.kernel.org, "Junio C Hamano" <gitster@pobox.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: Re: [PATCH/RFH 0/3] stable priority-queue
Date: Mon, 21 Jul 2014 05:07:35 -0400 [thread overview]
Message-ID: <20140721090735.GA14548@peff.net> (raw)
In-Reply-To: <87tx6k5hjz.fsf@fencepost.gnu.org>
On Mon, Jul 14, 2014 at 01:02:56PM +0200, David Kastrup wrote:
> Jeff King <peff@peff.net> writes:
>
> > As Junio and I discussed earlier in [1], this series makes the
> > prio_queue struct stable with respect to object insertion (which in turn
> > means we can use it to replace commit_list in more places).
>
> I don't think that this makes sense in general since it assumes the
> appropriate fallback behavior to be FIFO. Depending on the use case, it
> might be the other way round, or something else (like topology-based)
> entirely.
Remember that this is just a tie-breaker for the regular comparison
function. If you want to represent some other ordering, you are free to
do the tie-breaking yourself in your comparison function. The one thing
we can easily provide but do not is LIFO ordering for the tie-breaker.
That would be trivial to add as a flag on the prio_queue, but I'd wait
until there is actually a caller who wants it.
Yes, it's a bit hacky to provide it for cases which _don't_ care about
order (or implement their own separate tie-breaker). But the worst case
there is that we are wasting some memory, and I wasn't able to measure a
real slow-down. I think it's a reasonable compromise given the lack of
generics in C.
But if you have a case that is measurably affected, please let me know,
and I can look into implementing it in a type-agnostic way (so that the
embedded insertion counter becomes just another type).
> I see that struct commit already contains an integer field called
> "index", assigned sequentially, which might conceivably be used for
> tie-breaking independent from the actual prio_queue use at no extra
> cost.
I don't think it's a good idea to rely on that index, as it is anything
but stable. It represents whatever order commits happened to be first
touched in the current program run. So:
1. Performing the same operation in-process versus in a sub-process
may produce different results.
2. Arguments to a command may have unexpected effects. E.g.,
specifying "--tags" to "rev-list" will look up the commit at
each tag ref, giving them much lower index numbers than they would
if we reached only through the normal traversal.
-Peff
prev parent reply other threads:[~2014-07-21 9:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-14 5:40 [PATCH/RFH 0/3] stable priority-queue Jeff King
2014-07-14 5:42 ` [PATCH 1/3] prio-queue: factor out compare and swap operations Jeff King
2014-07-14 5:51 ` [PATCH 2/3] prio-queue: make output stable with respect to insertion Jeff King
2014-07-14 5:53 ` [PATCH 3/3] paint_down_to_common: use prio_queue Jeff King
2014-07-14 10:12 ` [PATCH/RFH 0/3] stable priority-queue Duy Nguyen
2014-07-14 11:02 ` David Kastrup
2014-07-21 9:07 ` Jeff King [this message]
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=20140721090735.GA14548@peff.net \
--to=peff@peff.net \
--cc=dak@gnu.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=pclouds@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.