[PR #91] [MERGED] Faster commit lookup #97

Closed
opened 2026-02-16 10:24:06 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/git/pull/91
Author: @ethantkoenig
Created: 11/18/2017
Status: Merged
Merged: 12/10/2017
Merged by: @lafriks

Base: masterHead: fast_commits


📝 Commits (4)

📊 Changes

4 files changed (+366 additions, -168 deletions)

View changed files

commit_info.go (+307 -0)
commit_info_test.go (+59 -0)
📝 tree_entry.go (+0 -114)
📝 tree_entry_test.go (+0 -54)

📄 Description

A faster implementation of GetCommitsInfo, particularly for repositories with many files. Addresses https://github.com/go-gitea/gitea/issues/491 and https://github.com/go-gitea/gitea/issues/502.

A revival of the failed #53 (which was reverted by #73).

BENCHMARKS

Old implementations:

BenchmarkEntries_GetCommitsInfo/gitea-4         	     200	  89001816 ns/op
BenchmarkEntries_GetCommitsInfo/manyfiles-4     	       1	47869780305 ns/op
BenchmarkEntries_GetCommitsInfo/moby-4          	     100	 174120584 ns/op
BenchmarkEntries_GetCommitsInfo/go-4            	      20	 727309260 ns/op
BenchmarkEntries_GetCommitsInfo/linux-4         	      20	 853282140 ns/op

New implementation:

BenchmarkEntries_GetCommitsInfo/gitea-4         	     200	  79968242 ns/op
BenchmarkEntries_GetCommitsInfo/manyfiles-4     	      50	 261940680 ns/op
BenchmarkEntries_GetCommitsInfo/moby-4          	     100	 154584374 ns/op
BenchmarkEntries_GetCommitsInfo/go-4            	      20	 715422795 ns/op
BenchmarkEntries_GetCommitsInfo/linux-4         	      20	 833090406 ns/op

In summary, we see a >150x improvement in repos with many files, and mild improvements in other repos.

IMPLEMENTATION DETAILS:
Runs targeted and untargeted searches in parallel. The untargeted search (1 thread) sifts through the output of a git log --name-status -c -- <tree-path> command, seeing which files the most recent commits have affected. The targeted search (multiple threads) runs git rev-list -1 HEAD -- <entry> commands to get the latest commit for specific file that have not been found by the untargeted search. The targeted search is similar to the old implementation, with a few enhancements (e.g. uses git rev-list instead of git log).

If there are only a few remaining entries, then the untargeted search stops to allow the targeted-search threads to finish without any interference (in my tests, this interference had a non-negligible impact on performance).

TESTING:
I have not been able to test this new implementation on a Windows machine. If someone could test the new implementation on Windows (to check for forward-slash vs. backslash bugs), that would be great.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/git/pull/91 **Author:** [@ethantkoenig](https://github.com/ethantkoenig) **Created:** 11/18/2017 **Status:** ✅ Merged **Merged:** 12/10/2017 **Merged by:** [@lafriks](https://github.com/lafriks) **Base:** `master` ← **Head:** `fast_commits` --- ### 📝 Commits (4) - [`489f7b0`](https://github.com/go-gitea/git/commit/489f7b0cb287605d71a0f8f686f159f497b726e7) Faster commit lookup - [`e39b29f`](https://github.com/go-gitea/git/commit/e39b29f3921453f907e6a78dc0f67acc8411dfaf) Fix copy/rename bug - [`2706f5e`](https://github.com/go-gitea/git/commit/2706f5e7f6ef53c1e75cd454672e79540e42a869) Comment - [`acb3e0f`](https://github.com/go-gitea/git/commit/acb3e0f922b8319954e39742ae02a34d1ab50821) Use defer ### 📊 Changes **4 files changed** (+366 additions, -168 deletions) <details> <summary>View changed files</summary> ➕ `commit_info.go` (+307 -0) ➕ `commit_info_test.go` (+59 -0) 📝 `tree_entry.go` (+0 -114) 📝 `tree_entry_test.go` (+0 -54) </details> ### 📄 Description A faster implementation of `GetCommitsInfo`, particularly for repositories with many files. Addresses https://github.com/go-gitea/gitea/issues/491 and https://github.com/go-gitea/gitea/issues/502. A revival of the failed #53 (which was reverted by #73). __BENCHMARKS__ Old implementations: ``` BenchmarkEntries_GetCommitsInfo/gitea-4 200 89001816 ns/op BenchmarkEntries_GetCommitsInfo/manyfiles-4 1 47869780305 ns/op BenchmarkEntries_GetCommitsInfo/moby-4 100 174120584 ns/op BenchmarkEntries_GetCommitsInfo/go-4 20 727309260 ns/op BenchmarkEntries_GetCommitsInfo/linux-4 20 853282140 ns/op ``` New implementation: ``` BenchmarkEntries_GetCommitsInfo/gitea-4 200 79968242 ns/op BenchmarkEntries_GetCommitsInfo/manyfiles-4 50 261940680 ns/op BenchmarkEntries_GetCommitsInfo/moby-4 100 154584374 ns/op BenchmarkEntries_GetCommitsInfo/go-4 20 715422795 ns/op BenchmarkEntries_GetCommitsInfo/linux-4 20 833090406 ns/op ``` In summary, we see a >150x improvement in repos with many files, and mild improvements in other repos. __IMPLEMENTATION DETAILS__: Runs targeted and untargeted searches in parallel. The untargeted search (1 thread) sifts through the output of a `git log --name-status -c -- <tree-path>` command, seeing which files the most recent commits have affected. The targeted search (multiple threads) runs `git rev-list -1 HEAD -- <entry>` commands to get the latest commit for specific file that have not been found by the untargeted search. The targeted search is similar to the old implementation, with a few enhancements (e.g. uses `git rev-list` instead of `git log`). If there are only a few remaining entries, then the untargeted search stops to allow the targeted-search threads to finish without any interference (in my tests, this interference had a non-negligible impact on performance). __TESTING__: I have not been able to test this new implementation on a Windows machine. If someone could test the new implementation on Windows (to check for forward-slash vs. backslash bugs), that would be great. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 10:24:06 -05:00
yindo closed this issue 2026-02-16 10:24:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: go-gitea/git#97