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

Re: [PATCH v2] use a hashmap to make remotes faster

From
Jeff King <peff@peff.net>
Date
Jul 29, 2014, 17:46 UTC
Message-ID
<20140729174642.GB20042@peff.net>
In-Reply-To
<25222.0938886865-sendEmail@debian>
On Tue, Jul 29, 2014 at 02:43:39PM +0000, Patrick Reynolds wrote:
Show 14 quoted lines
> Remotes are stored as an array, so looking one up or adding one without
> duplication is an O(n) operation.  Reading an entire config file full of
> remotes is O(n^2) in the number of remotes.  For a repository with tens of
> thousands of remotes, the running time can hit multiple minutes.
> 
> Hash tables are way faster.  So we add a hashmap from remote name to
> struct remote and use it for all lookups.  The time to add a new remote to
> a repo that already has 50,000 remotes drops from ~2 minutes to < 1
> second.
> 
> We retain the old array of remotes so iterators proceed in config-file
> order.
> 
> Signed-off-by: Patrick Reynolds <patrick.reynolds@github.com>

As observers might have guessed, I already reviewed this off-list, but to make it clear:

  Reviewed-by: Jeff King <peff@peff.net>
-Peff
Previous: Patrick ReynoldsNext: Junio C Hamano
Message 2 of 5 in “use a hashmap to make remotes faster”
  1. use a hashmap to make remotes fasterPatrick Reynolds, Jul 29, 2014
  2. Jeff KingJul 29, 2014
  3. Junio C HamanoJul 30, 2014
  4. Stefan BellerSep 5, 2014
  5. Jeff KingSep 5, 2014

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.