-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the performance of pull-request merging #641
Conversation
Lint error, please fix lint error from the following command. make lint |
@appleboy I have fixed it in the last commit and tested with |
@typeless Where is your last commit? Still fail: https://drone.gitea.io/go-gitea/gitea/1072 |
@typeless I don't know why the drone show error on this commit. Please recommit to test it again. |
@appleboy Alright |
@typeless Do you have any benchmarks? I'm using the latest master(without this PR) and merging a repo of 1.7gig succeeds in about 5 secs 😯 |
@Bwko For the record, the large repo that troubled me is about 13G the size of .git.
The large repo is in fact an Android board support package which is a mixture of the Google official code and a vendor-tailored distribution. And for Linux kernel, which is about 2G (bare repo)
Very close to what you have benchmarked. The both clones were done within the same filesystem, by the way. Edit:For downloading the official android platform code:
Then use the
The It'd better to kill the .repo and the sparsely populated .git directories before pushing to Gitea.
References: https://source.android.com/source/downloading.html |
@typeless That looks really promising 👍
|
Hasn't been tested yet |
@typeless If you repeat the steps from my previous comment you'll get: |
conflicted |
@typeless any update? |
4703f84
to
cd29b89
Compare
@Bwko @metalmatze |
It's ready for review now? |
models/pull.go
Outdated
fmt.Sprintf("PullRequest.Merge (git write-tree): %s", baseRepoPath), | ||
[]string{"GIT_DIR=" + baseRepoPath, "GIT_INDEX_FILE=" + indexTmpPath}, | ||
"git", "write-tree"); err != nil { | ||
return fmt.Errorf("git write-tree: %s", stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err
also should be include the error string.
So let's move this to v1.2 since we have no more time to review this one after #741 merged. |
cd29b89
to
3019cf8
Compare
@typeless Great work. build success. https://drone.gitea.io/go-gitea/gitea/3579 |
Any performance tests? |
@lunny I was considering about it. But for showing any significance we need to prepare a large repo in the integration framework. I have no solid idea yet about how it should be added. |
maybe clone linux repo on the tests? |
@lunny maybe we can use the migration feature to clone a Linux repository for testing. But I am afraid of getting banned if we suck the bandwidth of the server too heavily/frequently. 😄 |
I don't think performance tests should be done in drone |
We could still have a benchmark suite at least to validate any performance PR. Those should not be run on drone even more if they are network/cpu/memory intensive. |
3f2df09
to
ea2879b
Compare
7051e60
to
7f92154
Compare
Any status updates? |
7f92154
to
8962e92
Compare
Codecov Report
@@ Coverage Diff @@
## master #641 +/- ##
==========================================
- Coverage 27.32% 27.25% -0.07%
==========================================
Files 86 86
Lines 17135 17177 +42
==========================================
Hits 4682 4682
- Misses 11775 11817 +42
Partials 678 678
Continue to review full report at Codecov.
|
@typeless Is it possible to add a performance test? |
I was thinking about it but not sure about how it should be done in an idiomatic way. Also the merge operation is stateful and not easily repeatable in a typical |
models/pull.go
Outdated
"GIT_AUTHOR_EMAIL=" + headCommit.Author.Email, | ||
"GIT_AUTHOR_DATE=" + headCommit.Author.When.Format("Mon, 02 Jan 2006 15:04:05 -0700"), | ||
"GIT_COMMITTER_NAME=" + doer.NewGitSig().Name, | ||
"GIT_COMMITTER_EMAIL=" + doer.NewGitSig().Email, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this hide the Email if the commiter has that set in their config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8962e92
to
e49bf7d
Compare
A benchmark has been added. |
The old way of PR merging has to checkout the working tree of the repository. This change make it possible to do the merge by manipulating the index only.
812f160
to
c5babc2
Compare
"git", "clone", baseGitRepo.Path, tmpBasePath); err != nil { | ||
return fmt.Errorf("git clone: %s", stderr) | ||
// A temporary Git working tree for git-merge-index and git-merge-one-file. | ||
workTreeTmpPath, err := ioutil.TempDir("", "gitea-merge-") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not there missing +pr.BaseRepo.Name+"-"+strconv.Itoa(time.Now().Nanosecond())
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ioutil.TempDir will generate a suffix automatically. See https://golang.org/src/io/ioutil/tempfile.go?s=2138:2195#L66
Sorry, I see what you mean now. I'll fix it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is not there missing +pr.BaseRepo.Name+"-"+strconv.Itoa(time.Now().Nanosecond())?
This is actually correct despite a bit of inconsistent. I will clean this up a little bit.
The path indexTmpPath
and workTreeTmpPath
conrespond to GIT_INDEX_FILE
and GIT_WORK_TREE
respectively. I looked at this in a hurry last friday and got confused as well. 😆
This is actually not a comprehensive approach that covers all cases where |
Merging pull-request without checking out a working tree
Inspired by this.
For #601