Re: git status: small difference between stating whole repository and small subdirectory
From: Piotr Krukowiecki <hidden>
Date: 2016-06-15 22:53:05
On Tue, Feb 14, 2012 at 12:34 PM, Thomas Rast [off-list ref] wrote:
Piotr Krukowiecki [off-list ref] writes:quoted
On Fri, Feb 10, 2012 at 10:42 AM, Piotr Krukowiecki [off-list ref] wrote:quoted
I compared stating whole tree vs one small subdirectory, and I expected that for the subdirectory status will be very very fast. After all, it has only few files to stat. But it's not fast. Why? With cold cache (echo 3 | sudo tee /proc/sys/vm/drop_caches): $ time git status > /dev/null real 0m41.670s user 0m0.980s sys 0m2.908s $ time git status -- src/.../somedir > /dev/null real 0m17.380s user 0m0.748s sys 0m0.328s[...]quoted
I can't reproduce this behavior at the moment. 'status' on the directory takes about 1.5s instead of 17s. status on whole repository takes 27s. This is my work repository, so it was changed today.To me these timings smell like a combination of either a network filesystem or a slow/busy disk, and non-packed repositories. Next time this happens look at 'git count-objects', run 'git gc' and redo the timings. If you are indeed on a network filesystem, also look at the core.preloadIndex setting.
All is on local disk and system is idle. Indeed, after gc the times went down: 10s -> 2.3s (subdirectory) 17s -> 9.5s (whole repo) 2 seconds is much better and I'd say acceptable for me. But my questions are: - why is it so slow with not packed repo? - can it be faster without repacking? - even with packed repo, the time on small subdirectory is much higher than I'd expect given time on whole repo and subdirectory size - why? $ git count-objects -v count: 5095 size: 37084 in-pack: 755364 packs: 21 size-pack: 2398468 prune-packable: 0 garbage: 0 $ git gc Counting objects: 760212, done. Compressing objects: 100% (158651/158651), done. Writing objects: 100% (760212/760212), done. Total 760212 (delta 535848), reused 736108 (delta 513257) Checking connectivity: 760212, done. $ time git status -- . real 0m2.503s user 0m0.160s sys 0m0.096s $ time git status real 0m9.663s user 0m0.232s sys 0m0.556s -- Piotr Krukowiecki