/explore/code rendering slowly when there are many repositories (> 2000) and a logged in user #6004

Closed
opened 2025-11-02 06:42:34 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @jnlin on GitHub (Sep 15, 2020).

  • Gitea version (or commit ref): 6a1a6332de
  • Git version: 2.11.0
  • Operating system: Docker
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist: N/A

Description

We have a lot of repositories (>2000), and the rendering of /explore/code is slow (see the attached screenshot, > 17 seconds) with a logged in user.

We tried to remove some permission checking feature and the speed becomes good, however we are not sure which is the slowest part. The removed code is: https://github.com/go-gitea/gitea/compare/master...jnlin:jnlin_test

The possible parts under suspicion are:
https://github.com/go-gitea/gitea/blob/master/routers/home.go#L330
https://github.com/go-gitea/gitea/blob/master/routers/home.go#L338-L343

Screenshots

截圖 2020-09-15 上午10 13 02
Originally created by @jnlin on GitHub (Sep 15, 2020). - Gitea version (or commit ref): 6a1a6332de5b5000d31ec26efaef6f78a4ee10f0 - Git version: 2.11.0 - Operating system: Docker - Database (use `[x]`): - [ ] PostgreSQL - [X] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [x] No - [ ] Not relevant - Log gist: N/A ## Description We have a lot of repositories (>2000), and the rendering of `/explore/code` is slow (see the attached screenshot, > 17 seconds) with a logged in user. We tried to remove some permission checking feature and the speed becomes good, however we are not sure which is the slowest part. The removed code is: https://github.com/go-gitea/gitea/compare/master...jnlin:jnlin_test The possible parts under suspicion are: https://github.com/go-gitea/gitea/blob/master/routers/home.go#L330 https://github.com/go-gitea/gitea/blob/master/routers/home.go#L338-L343 ## Screenshots <img width="1243" alt="截圖 2020-09-15 上午10 13 02" src="https://user-images.githubusercontent.com/284245/93163982-0d8a5980-f74b-11ea-90f0-0093294304fe.png">
GiteaMirror added the issue/confirmedperformance/speed labels 2025-11-02 06:42:34 -06:00
Author
Owner

@lunny commented on GitHub (Sep 15, 2020):

The differences are GetRepositoriesMapByIDs and ctx.Data["RepoMaps"] = rightRepoMap.

@lunny commented on GitHub (Sep 15, 2020): The differences are `GetRepositoriesMapByIDs` and `ctx.Data["RepoMaps"] = rightRepoMap`.
Author
Owner

@jnlin commented on GitHub (Sep 15, 2020):

https://github.com/go-gitea/gitea/blob/master/routers/home.go#L330

This spends < 0.5 secs

https://github.com/go-gitea/gitea/blob/master/routers/home.go#L338-L343

This spends 17 secs, there may be some N+1 queries in CheckUnitUser()

@jnlin commented on GitHub (Sep 15, 2020): > https://github.com/go-gitea/gitea/blob/master/routers/home.go#L330 This spends < 0.5 secs > https://github.com/go-gitea/gitea/blob/master/routers/home.go#L338-L343 This spends 17 secs, there may be some N+1 queries in `CheckUnitUser()`
Author
Owner

@a1012112796 commented on GitHub (Sep 15, 2020):

https://github.com/go-gitea/gitea/blob/master/routers/home.go#L330

This spends < 0.5 secs

https://github.com/go-gitea/gitea/blob/master/routers/home.go#L338-L343

This spends 17 secs, there may be some N+1 queries in CheckUnitUser()

How about #12854 ?

@a1012112796 commented on GitHub (Sep 15, 2020): > > https://github.com/go-gitea/gitea/blob/master/routers/home.go#L330 > > This spends < 0.5 secs > > > https://github.com/go-gitea/gitea/blob/master/routers/home.go#L338-L343 > > This spends 17 secs, there may be some N+1 queries in `CheckUnitUser()` How about #12854 ?
Author
Owner

@jnlin commented on GitHub (Sep 15, 2020):

How about #12854 ?

Still needs 15 secs

image

@jnlin commented on GitHub (Sep 15, 2020): > > How about #12854 ? Still needs 15 secs ![image](https://user-images.githubusercontent.com/284245/93222884-06426a80-f7a2-11ea-8e85-4b622ae74ca3.png)
Author
Owner

@lunny commented on GitHub (Sep 16, 2020):

We need more PRs here, but let's merge this one at first.

@lunny commented on GitHub (Sep 16, 2020): We need more PRs here, but let's merge this one at first.
Author
Owner

@a1012112796 commented on GitHub (Sep 16, 2020):

Now the main issue is how to quickly find out all repos that the user has code read permission?

@a1012112796 commented on GitHub (Sep 16, 2020): Now the main issue is how to quickly find out all repos that the user has code read permission?
Author
Owner

@jnlin commented on GitHub (Sep 16, 2020):

@a1012112796 yes

@jnlin commented on GitHub (Sep 16, 2020): @a1012112796 yes
Author
Owner

@stale[bot] commented on GitHub (Nov 15, 2020):

This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.

@stale[bot] commented on GitHub (Nov 15, 2020): This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
Author
Owner

@lafriks commented on GitHub (Nov 15, 2020):

Up

@lafriks commented on GitHub (Nov 15, 2020): Up
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6004