git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC/PATCH 0/4] commit lists as priority queues

From
Junio C Hamano <gitster@pobox.com>
Date
May 20, 2011, 22:03 UTC
Message-ID
<7v4o4p2foj.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110519212349.GA28589@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 6 quoted lines
> ... I also had a feeling we
> could use a faster commit_list in other places, since get_revision is
> all based around the same pop-and-push-the-parents workflow. But after
> spending a few hours on it, it seems that _lots_ of places in the code
> work on the assumption of a linked list (or at least doing very simple
> in-order traversal), and the changes got very ugly very quickly.

I recall looking at the same codepaths a few years ago for different reasons. get_revision() callchain does a _lot_ of alloc/free, so I naturally wanted to catch all the allocations and frees to replace them with a custom allocator that slices from a larger slab. It involved too many places so I decided it wasn't really worth doing only that change without other benefit (e.g. lifting the "listness" assumption), and stopped.

If somebody is interested to tackle it, we would probably need a two step conversion process. First introduce an abstracted interface that passes around the "list-as-a-whole" object with a few selected methods (e.g. drop an element into it at the sorted location and get a "cursor" that points at it, given a "cursor", grab an element from the list, increment the "cursor" to point at the next object, etc.), choosing a set just sufficient to express the patterns of accesses the current codebase makes, and implement the API over the existing linked-list implementation to convert all the callers. After making sure this works, update the API implementation with the queue in this patch.

Or something like that.
Show 5 quoted lines
> ... And
> performance-wise, it doesn't seem to be a huge problem, mainly because:
>
>   1. We don't tend to put more items in a commit_list than the width of
>      the history graph. So our "n" tends to be in the dozens at most.

I was worried that you may end up with many concurrent traversal going in a very bushy history (think: traversing from the tip of "next"), but I agree that it would be in the order of dozens, not thousands.

Previous: Jeff KingNext: Junio C Hamano
Message 11 of 12 in “fetch: avoid repeated commits in mark_complete”
  1. fetch: avoid repeated commits in mark_completeJeff King, May 19, 2011
  2. 0/4 commit lists as priority queuesJeff King, May 19, 2011
  3. 1/4 Makefile: sort TEST_PROGRAMS listJeff King, May 19, 2011
  4. 2/4 basic priority queue implementationJeff King, May 19, 2011
  5. Thiago FarinaMay 20, 2011
  6. Jeff KingMay 20, 2011
  7. Thiago FarinaMay 20, 2011
  8. Jeff KingMay 20, 2011
  9. 3/4 commit: add infrastructure for priority queues of commitsJeff King, May 19, 2011
  10. 4/4 fetch-pack: use priority queue for mark_completeJeff King, May 19, 2011
  11. Junio C HamanoMay 20, 2011
  12. Junio C HamanoMay 20, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.