mirror of
https://github.com/go-gitea/git.git
synced 2026-07-25 12:46:00 -04:00
[PR #53] [MERGED] Faster commit lookup #61
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/go-gitea/git/pull/53
Author: @ethantkoenig
Created: 5/22/2017
Status: ✅ Merged
Merged: 5/26/2017
Merged by: @lunny
Base:
master← Head:commit_lookup📝 Commits (8)
c84e4aaAdd bench task96af092Create tree_entry_test.goeef76cdRemove init timeae8ee36Add TODO informationdcfda73Add linux repo76cec74Faster implementation of GetCommitsInfoe8bc37cStart/stop timerf22ce90Use benchmark/ directory for benchmark repos📊 Changes
4 files changed (+197 additions, -95 deletions)
View changed files
📝
.gitignore(+2 -0)📝
Makefile(+6 -2)📝
tree_entry.go(+125 -93)➕
tree_entry_test.go(+64 -0)📄 Description
A faster implementation of
GetCommitsInfo, addresses https://github.com/go-gitea/gitea/issues/491 and https://github.com/go-gitea/gitea/issues/502.The previous implementation made a call to
git logfor each entry, each of which required scanning through the commit history. This new implementation instead makes a single call togit log. This is faster, because it involves scanning the commit history only once.BENCHMARK RESULTS:
Shoutout to @sapk for the benchmark tests he wrote (#54), which I have stolen here.
Old implementation:
New implementation:
IMPLEMENTATION DETAILS:
Gets the 16 latest commits affecting the relevant entries (
git log --name-only -16 HEAD -- <treePath>). The output of this command containing which files were affect by each commit. Scan through this list of cmmit, and stop once a commit has been found for each entry.If you go through the first batch of 16 commits, you get then next 32 commits (
git log --name-only -32 <last-commit-from-first-batch>^ -- entry1 entry2 ...); each time you double the number of commits. This ensures that in the common case you'll only have to read in a small number (16) of commits, but you also won't have to make too many calls togit logif you need to go further into the commit history.Finally, if you are looking for 32 or fewer entries, manually list out each entry in the
git logcommand (git log --name-only -- entry1 entry2...) to support a more targeted search.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.