perf: use git cat-file -e instead of git rev-list in _rev_exists#3601
perf: use git cat-file -e instead of git rev-list in _rev_exists#3601ptarjan wants to merge 1 commit intopre-commit:mainfrom
Conversation
Replace git rev-list --quiet with git cat-file -e for checking if a revision exists. This changes the operation from O(commits) to O(1). Benchmarks from a large monorepo: - git rev-list --quiet <sha>: 5150ms - git cat-file -e <sha>: 4ms Both commands have the same semantics: return success if the revision exists in the local repo, failure otherwise.
6a3e48c to
66d1c07
Compare
|
sorry but I unfortunately can't accept ai submissions |
|
this piece of code also isn't performance critical -- are you solving an actual problem? |
Would you prefer me to set the author to my account?
Absolutely. As per the summary, in our repo our users are seeing a large delay with our pre-push hooks. So much so that about 7% of users are skipping them entirely. I'm trying to reduce the performance footprint and this was one of the largest slowdowns. |
|
I updated the commit metadata to my name and username. |
that's just being disingenuous then? you didn't author this |
I'm not sure what you mean by "author"? I mean I didn't open But I'd prefer not to split hairs if possible. What would you like me to do now so that we can accomplish this performance improvement? |
Replace
git rev-list --quietwithgit cat-file -efor checking if a revision exists. This changes the operation from O(commits) to O(1).Benchmarks (repo with ~1M commits, 5 runs each):
Both commands have the same semantics: return success if the revision exists in the local repo, failure otherwise.