sil2100//vx developer log

Welcome to my personal web page

Empty

Slow git status response

This is a trick that my colleague Michał Wróbel showed me when I had problems with slow git response on my local repository. Sometimes it strangely so happens that git status becomes really really slow, taking even a few minutes to complete - on a big, multi submodule repository in this case. This can be really annoying. Quoting my colleague:

2010-11-27

"Under some (still not fully known) circumstances git starts to work in a strange mode scanning the contents of the files instead of just stat()ing them:"

Right:

firmware/code/linux$ strace git status
(...)
lstat(".mailmap", {st_mode=S_IFREG|0664, st_size=4021, ...}) = 0
lstat("COPYING", {st_mode=S_IFREG|0664, st_size=18693, ...}) = 0
lstat("CREDITS", {st_mode=S_IFREG|0664, st_size=94027, ...}) = 0
(...)

Wrong:

firmware/code/linux$ strace git status
(...)
lstat(".mailmap", {st_mode=S_IFREG|0664, st_size=4021, ...}) = 0
open(".mailmap", O_RDONLY)              = 3
read(3, "#\n# This list is used by git-sho"..., 4021) = 4021
close(3)                                = 0
lstat("COPYING", {st_mode=S_IFREG|0664, st_size=18693, ...}) = 0
open("COPYING", O_RDONLY)               = 3
read(3, "\n   NOTE! This copyright does *n"..., 18693) = 18693
close(3)                                = 0
lstat("CREDITS", {st_mode=S_IFREG|0664, st_size=94027, ...}) = 0
open("CREDITS", O_RDONLY)               = 3
mmap(NULL, 94027, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f52ad1fb000
munmap(0x7f52ad1fb000, 94027)           = 0
close(3)                                = 0
(...)

The trick that worked with me was doing git checkout <your_branch_here> and git update-index --refresh on the main repository and all its submodules, with an additional git submodule update at the end, just in case.