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