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

Re: [PATCH] Preallocate hash tables when the number of inserts are known in advance

From
Jeff King <peff@peff.net>
Date
Mar 17, 2013, 08:51 UTC
Message-ID
<20130317085107.GB934@sigill.intra.peff.net>
In-Reply-To
<1363490886-29729-1-git-send-email-pclouds@gmail.com>
On Sun, Mar 17, 2013 at 10:28:06AM +0700, Nguyen Thai Ngoc Duy wrote:
> This avoids unnecessary re-allocations and reinsertions. On webkit.git
> (i.e. about 182k inserts to the name hash table), this reduces about
> 100ms out of 3s user time.
Good idea.

I had a similar thought when analyzing the hashing behavior of pack-objects' "Counting objects..." phase, but it had even less impact there. The insertions are just drowned out by the number of lookups in that case.

-Peff
Previous: Junio C Hamano
Message 5 of 5 in “Preallocate hash tables when the number of inserts are known in advance”
  1. Preallocate hash tables when the number of inserts are known in advanceNguyễn Thái Ngọc Duy, Mar 17, 2013
  2. Junio C HamanoMar 17, 2013
  3. Duy NguyenMar 17, 2013
  4. Junio C HamanoMar 17, 2013
  5. Jeff KingMar 17, 2013

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.