summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2023-05-14 21:45:47 +0800
committerGitHub <noreply@github.com>2023-05-14 21:45:47 +0800
commit3af2c8e4ab4dca53a16ead9940a0ac4752072045 (patch)
treebd5c07ff8c26ab936c13c536e5c9d76b2e9abfbc /routers
parent116f8e12a7db9572161eaba064f71a384ad6eb37 (diff)
downloadgitea-3af2c8e4ab4dca53a16ead9940a0ac4752072045.tar.gz
gitea-3af2c8e4ab4dca53a16ead9940a0ac4752072045.zip
Remove the parallelizing when loading repo for dashboard (#24705)
Ref: #24638 IMO, parallelizing might run out server resources more quickly. Gitea shouldn't use a lot of go-routine in a web handler. And add a comment about how many repositories there could be at most. Co-authored-by: Yarden Shoham <git@yardenshoham.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/repo.go20
1 files changed, 7 insertions, 13 deletions
diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go
index f697d9433e..8944890f6a 100644
--- a/routers/web/repo/repo.go
+++ b/routers/web/repo/repo.go
@@ -9,7 +9,6 @@ import (
"fmt"
"net/http"
"strings"
- "sync"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
@@ -579,20 +578,15 @@ func SearchRepo(ctx *context.Context) {
}
// collect the latest commit of each repo
- repoIDsToLatestCommitSHAs := make(map[int64]string)
- wg := sync.WaitGroup{}
- wg.Add(len(repos))
+ // at most there are dozens of repos (limited by MaxResponseItems), so it's not a big problem at the moment
+ repoIDsToLatestCommitSHAs := make(map[int64]string, len(repos))
for _, repo := range repos {
- go func(repo *repo_model.Repository) {
- defer wg.Done()
- commitID, err := repo_service.GetBranchCommitID(ctx, repo, repo.DefaultBranch)
- if err != nil {
- return
- }
- repoIDsToLatestCommitSHAs[repo.ID] = commitID
- }(repo)
+ commitID, err := repo_service.GetBranchCommitID(ctx, repo, repo.DefaultBranch)
+ if err != nil {
+ continue
+ }
+ repoIDsToLatestCommitSHAs[repo.ID] = commitID
}
- wg.Wait()
// call the database O(1) times to get the commit statuses for all repos
repoToItsLatestCommitStatuses, err := git_model.GetLatestCommitStatusForPairs(ctx, repoIDsToLatestCommitSHAs, db.ListOptions{})