mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
Slow to open a repo if there’s many branches in it #6598
Closed
opened 2025-11-02 07:00:45 -06:00 by GiteaMirror
·
28 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16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0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#6598
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking 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?
Originally created by @skyline75489 on GitHub (Dec 29, 2020).
[x]):Description
The title may be a bit misleading.
I was building a local mirror of PyTorch manually using
git push —mirror. And I found that opening the repo is exceptionally slow (~11 seconds). I also built a clone of gitea itself and the time to open the repo is reasonable (~2 seconds).I think the reason is that PyTorch has over 4000 branches in it.
Screenshots
@skyline75489 commented on GitHub (Dec 30, 2020):
So I did a little debugging with Gitea code and found that the reason is the number of branches.
@skyline75489 commented on GitHub (Dec 30, 2020):
The root cause of this seem to be
git show-refused by gitea becomes very slow for a repo like PyTorch which have 4000+ branches@zeripath commented on GitHub (Jan 1, 2021):
Could you use pprof to confirm where the delay is?
@skyline75489 commented on GitHub (Jan 2, 2021):
I’m new to golang. I’ll try pprof later. Based on my debugging using logging, I found most of the time was spent in
GetTags&GetBranchesinrepoAssginment. This is why I filed theshow-refPR.By the way because
repoAssignmentis called every time we need to get the repo context, the entire PyTorch repo feels unresponsive. Everything is slow, be it opening issues, opening commits.@zeripath commented on GitHub (Jan 2, 2021):
Yes. Before I broke my hand this was precisely the kind of thing I was working on.
Ok. pprof can be enabled by setting
ENABLE_PPROF=truein[server]in app.iniOnce you have that running on your server you can run:
Ok. pprof can be enabled by setting ENABLE_PPROF=true in [server] in app.ini
And get a SVG on your browser with:
web.topwould give some other data.@zeripath commented on GitHub (Jan 2, 2021):
I've just reread the issue opening comment - please could you try again on current master. You will likely find it much faster
@skyline75489 commented on GitHub (Jan 2, 2021):
I was using the latest master on my mac. And it is still not good. I also delibrately tried building it with 'gogit' flag. But changing 'show-ref' to 'branch/tag' without gogit gives me the best performance.
I'm having a hard time setting up a golang dev environment on my Windows machine. But i'll keep trying.
@zeripath commented on GitHub (Jan 2, 2021):
Interestingly I am not able to duplicate the slow down on linux - ah found it
@skyline75489 commented on GitHub (Jan 2, 2021):
On Linux there's buff/cache, which will aggresively cache everything used on the file system. So i think on Linux it should be better. But still, 'show-ref' feels like an unnecessary slow path for me. All the hashes retrieved end up being just ignored. There has to be a better way, right? Even it's not 'branch/tag'.
@zeripath commented on GitHub (Jan 2, 2021):
is it this path that is the slow down http://localhost/gitea/administrator/pytorch/branches/ ?
@skyline75489 commented on GitHub (Jan 2, 2021):
The one with 4000+ branches on the same page? TBH I never once successfully opened the page until I added pagination myself.
The repo homepage feels considerably slow to me, which is the first thing I noticed.
@zeripath commented on GitHub (Jan 2, 2021):
OK I've managed to get pprof results.
callshowref is not the problem
@skyline75489 commented on GitHub (Jan 2, 2021):
Interesting. That explains why using 'branch/tag' still feels slower, comparing to repos that have a smaller size.
Way to go, PyTorch.
@zeripath commented on GitHub (Jan 2, 2021):
it's Gitea's fault - not pytorches tbh.
@zeripath commented on GitHub (Jan 2, 2021):
OK - this means that your PR will definitely be helpful - but if we're doing optimisations we should be guided by what actually takes time.
I'm not quite sure why:
takes so long - I'd have to check - but it's likely that anything that reduces the number of branches will improve that.
In terms of main repo showing being slow that's likely to do with generating the history for each file. That is unfortunately a slightly difficult problem - and is necessarily slow - we need to ajax getting that info instead of delaying render. However you would likely benefit from enabling the cache:
https://docs.gitea.io/en-us/config-cheat-sheet/#cache---lastcommitcache-settings-cachelast_commit
@skyline75489 commented on GitHub (Jan 4, 2021):
@zeripath I was joking about PyTorch. I'm glad my findings turned out to be useful to gitea.
@lunny commented on GitHub (Jan 6, 2021):
Last commit cache is only for treepath view page but not branches page ?
@skyline75489 commented on GitHub (Jan 19, 2021):
So I was trying pprof but got something like this:
I don't know what I did wrong. The steps I took is:
Anything else I need to do to get the method trace?
@michaelbutler commented on GitHub (Feb 3, 2021):
We will be watching this too. Our repo has 1600+ branches and as we evaluate Gitea we are seeing 8-10 second page load times. Git clones don't seem to be affected.
@lunny commented on GitHub (Feb 4, 2021):
The branches list on repo home page should be loaded asynchronously.
@sandsenter commented on GitHub (Jan 7, 2022):
any progress for this issue?
We found that for two repositories, one repo is a mirror repository, the other is a normal repository for developing.
Both have hundreds of branches, the mirror repository's page is opened faster than the other one.
@zeripath commented on GitHub (Jan 8, 2022):
When you say progress have you tried main recently? There have been some improvements there.
However, we still need to stop loading all of the branches for every page.
@lunny commented on GitHub (Jul 13, 2022):
There is also another example https://gitea1.dev.blender.org/blender-foundation/blender/branches
@lunny commented on GitHub (Aug 4, 2022):
To accelerate the branches list, maybe we have to sync all branches into database like we did with tags.
@lafriks commented on GitHub (Aug 4, 2022):
I agree, this would also help for PR creating page where branches need to be selected and other places where we currently show all branches to make that dropdown to show only top branches and make it async searchable
@delvh commented on GitHub (Aug 4, 2022):
Yes, I can somewhat understand that proposal, but I do have to say that this will be difficult and error-prone to implement/ maintain:
This database entry will need to be updated correctly with every single push. Not to forget all UI-related branch interactions: Creating a branch, deleting a branch, renaming a branch...
If we do that, many potential edge cases are just waiting to invalidate the stored state of branches.
And in the worst case, if we store no longer valid branches there could even be a security issue in case someone names a branch after a security-relevant bug(fix) and deletes the branch later on, but the stored state still displays the branch.
@lunny commented on GitHub (Aug 5, 2022):
Yes, that's why I hesitate so long to post the comment. Since we have stored tags in database and it works well, what's the different from storing branches names? And if we have a better method, I would like to give up the idea.
@lunny commented on GitHub (Jul 3, 2023):
I think this could be closed per #22743. I have tested pytorch which have over 8700 branches and the home page takes about 1200ms in my macBook pro.
Future PRs could make the branches loading async.