Re: git slow unless piped to cat
- From
Jeff King <peff@peff.net>
- Date
- Aug 27, 2019, 18:59 UTC
- Message-ID
- <20190827185929.GA3150@sigill.intra.peff.net>
- In-Reply-To
- <20190827100427.u3a5uvmylm5vddn2@pengutronix.de>
On Tue, Aug 27, 2019 at 12:04:27PM +0200, Uwe Kleine-König wrote:
Show 11 quoted lines
> $ sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"; time env GIT_CONFIG_NOSYSTEM=1 HOME=/nonexistant XDG_CONFIG_HOME=/nonexistant git --no-pager show --no-color --no-decorate v5.2 > ... > > real 0m1.041s > user 0m0.000s > sys 0m0.021s > > $ git for-each-ref |wc -l > 10013 > > So this is indeed the problem.
That's not that many refs. Are they mostly unpacked? Loose refs are awful on a cold cache, since it's one inode per ref (or worse, since it has walk the directories, too).
Try:
find .git/refs -type f | wc -l
to see the loose ones. If there are a lot, try:
git pack-refs --prune --all
(or just "git gc", which does this).
Modern versions of Git should delete any leftover empty directories after pruning the loose variants, but I think won't go out of their way to remove ones they didn't delete from. And those are still expensive to walk on a cold cache. If it's still slow, try:
find .git/refs/* -type d | xargs rmdir -v
-Peff