Skip to content
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

Refactor the usage of batch catfile #31754

Merged
merged 9 commits into from
Aug 20, 2024

Conversation

lunny
Copy link
Member

@lunny lunny commented Aug 1, 2024

When opening a repository, it will call ensureValidRepository and also CatFileBatch. But sometimes these will not be used until repository closed. So it's a waste of CPU to invoke 3 times git command for every open repository.

This PR removed all of these from OpenRepository but only kept checking whether the folder exists. When a batch is necessary, the necessary functions will be invoked.

@lunny lunny added type/bug type/refactoring Existing code has been cleaned up. There should be no new functionality. labels Aug 1, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 1, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 1, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Aug 1, 2024
@lunny lunny changed the title For temprory batch catfile, it should not be assigned to the repository's member fields Refactor the usage of batch catfile Aug 1, 2024
@lunny lunny removed the type/bug label Aug 1, 2024
@lunny lunny added this to the 1.23.0 milestone Aug 1, 2024
@lunny lunny force-pushed the lunny/fix_possible_catfile branch from 015fd4a to 7041756 Compare August 1, 2024 19:51
@lunny lunny added performance/cpu backport/v1.22 This PR should be backported to Gitea 1.22 labels Aug 1, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 5, 2024
@yp05327 yp05327 self-requested a review August 18, 2024 23:45
Copy link
Contributor

@yp05327 yp05327 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to adjust the newly added logs, they are copy and paste, same logs from different places are not good for debug.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 20, 2024
@lunny
Copy link
Member Author

lunny commented Aug 20, 2024

I think it is better to adjust the newly added logs, they are copy and paste, same logs from different places are not good for debug.

I will try to merge the two functions in following PRs

@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 20, 2024
@lunny lunny enabled auto-merge (squash) August 20, 2024 16:35
@lunny lunny merged commit c03baab into go-gitea:main Aug 20, 2024
26 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Aug 20, 2024
When opening a repository, it will call `ensureValidRepository` and also
`CatFileBatch`. But sometimes these will not be used until repository
closed. So it's a waste of CPU to invoke 3 times git command for every
open repository.

This PR removed all of these from `OpenRepository` but only kept
checking whether the folder exists. When a batch is necessary, the
necessary functions will be invoked.
@GiteaBot GiteaBot added backport/done All backports for this PR have been created and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Aug 20, 2024
silverwind pushed a commit that referenced this pull request Aug 20, 2024
Backport #31754 by @lunny

When opening a repository, it will call `ensureValidRepository` and also
`CatFileBatch`. But sometimes these will not be used until repository
closed. So it's a waste of CPU to invoke 3 times git command for every
open repository.

This PR removed all of these from `OpenRepository` but only kept
checking whether the folder exists. When a batch is necessary, the
necessary functions will be invoked.

Co-authored-by: Lunny Xiao <[email protected]>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 21, 2024
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Refactor the usage of batch catfile (go-gitea#31754)
  Fix agit automerge (go-gitea#31207)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.22 This PR should be backported to Gitea 1.22 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code performance/cpu size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants