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

Re: [PATCH] upload-pack: use priority queue in reachable() check

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 11, 2016, 21:26 UTC
Message-ID
<xmqqshs27f21.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20161011212016.hnw4dl473puhyax7@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 20 quoted lines
> Like a lot of old commit-traversal code, this keeps a
> commit_list in commit-date order, and and inserts parents
> into the list. This means each insertion is potentially
> linear, and the whole thing is quadratic (though the exact
> runtime depends on the relationship between the commit dates
> and the parent topology).
>
> These days we have a priority queue, which can do the same
> thing with a much better worst-case time.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> This was inspired by a real-world case where several instances of
> upload-pack were chewing minutes of CPU, and backtraces in each instance
> pointed to this function.  Unfortunately, I only saw the server side of
> these requests. I pulled the contents of have_obj and want_obj out of
> the process via gdb, but I wasn't able to reproduce the slow fetch.
>
> So I'm not 100% sure that this fixes it, but the problem hasn't happened
> again. And it certainly seems like it couldn't _hurt_ to optimize this.
This does look good and looks like a quite straight-forward change.
Will queue; thanks.
Previous: Jeff King
Message 2 of 2 in “upload-pack: use priority queue in reachable() check”
  1. upload-pack: use priority queue in reachable() checkJeff King, Oct 11, 2016
  2. Junio C HamanoOct 11, 2016

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.