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

Improve pull request list api #34052

Merged
merged 6 commits into from
Mar 31, 2025

Conversation

lunny
Copy link
Member

@lunny lunny commented Mar 28, 2025

The pull request list API is slow, for every pull request, it needs to open a git repository. Assume it has 30 records, there will be 30 sub processes back because every repository will open a git cat-file --batch sub process. This PR use base git repository to get the head commit id rather than read it from head repository to avoid open any head git repository.

@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Mar 28, 2025
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 28, 2025
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 28, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Mar 28, 2025
@lunny lunny added this to the 1.24.0 milestone Mar 28, 2025
@lunny lunny added the performance/speed performance issues with slow downs label Mar 29, 2025
@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 Mar 29, 2025
@wxiaoguang
Copy link
Contributor

This PR use base git repository to get the head commit id rather than read it from head repository to avoid open any head git repository.

The commit might not exist in base repo.

@lunny
Copy link
Member Author

lunny commented Mar 30, 2025

This PR use base git repository to get the head commit id rather than read it from head repository to avoid open any head git repository.

The commit might not exist in base repo.

Since the reference refs/pull/<index>/head has been pushed to base repository and hold the commit id successfully, it should exist except the repository is broken.

image

@wxiaoguang
Copy link
Contributor

This PR use base git repository to get the head commit id rather than read it from head repository to avoid open any head git repository.

The commit might not exist in base repo.

Since the reference refs/pull/<index>/head has been pushed to base repository and hold the commit id successfully, it should exist except the repository is broken.

The question is: what if the repo is broken (or the refs/pull/xxx refs were deleted)? End users could only see 500 but nothing else to do? Should it ignore these errors?

@lunny
Copy link
Member Author

lunny commented Mar 30, 2025

If refs/pull/xxx missed, many web pages will return 500 not only this API. There is a PR #31931 to reject push deleting operation for refs/pull/xxx references even if the user is admin. The error can be ignored

This PR use base git repository to get the head commit id rather than read it from head repository to avoid open any head git repository.

The commit might not exist in base repo.

Since the reference refs/pull/<index>/head has been pushed to base repository and hold the commit id successfully, it should exist except the repository is broken.

The question is: what if the repo is broken (or the refs/pull/xxx refs were deleted)? End users could only see 500 but nothing else to do? Should it ignore these errors?

3167f20

@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 Mar 31, 2025
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 31, 2025
@lunny lunny merged commit a2e8a28 into go-gitea:main Mar 31, 2025
26 checks passed
@lunny lunny deleted the lunny/improve_pull_request_list_api branch March 31, 2025 19:54
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 31, 2025
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 1, 2025
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  fix users being able bypass limits with repo transfers (go-gitea#34031)
  Improve pull request list api (go-gitea#34052)
  fix(go-gitea#34076):replace assgniee translation key (go-gitea#34077)
  [Fix] Resolve the problem of commit_statuses not being loaded at the top - right when switching files from the file tree (go-gitea#34079)
  Enable testifylint rules (go-gitea#34075)
  Fix markup content overflow (go-gitea#34072)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/speed performance issues with slow downs size/M Denotes a PR that changes 30-99 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.

5 participants