Performance regression in `git branch` due to ref-filter usage
- From
Michael Haggerty <mhagger@alum.mit.edu>
- Date
- May 17, 2017, 11:14 UTC
- Message-ID
- <dfc3a334-8047-26b0-1142-81c703010507@alum.mit.edu>
While working on reference code, I was running `git branch` under `strace`, when I noticed that `$GIT_DIR/HEAD` was being `lstat()`ed and `read()` 121 times. This is in a repository with 114 branches, so probably it is being run once per branch. The extra work makes a measurable difference to the (admittedly, short) runtime.
As recently as 2.12.3 the file was only read 4 times when running the same command [1].
The regression bisects to
949af0684c (branch: use ref-filter printing APIs, 2017-01-10)
It would be nice if these extra syscalls could be avoided.
I haven't checked whether other commands have similar regressions.
Michael
[1] One wonders why the file has to be read more than once, but that's a different story and probably harder to fix.