perf: Various performance regression fixes (#38078)

Fixes five N+1 / O(n) query patterns found across common user paths.
Each uses a bulk query that already existed elsewhere in the codebase.

| Location | Problem | Introduced in |
| -------------------------------- |
-------------------------------------------------------------------------------------------------------------------------------
| ------------- |
| `IssueList.LoadIsRead` | `.In("issue_id")` missing its arg — xorm
generates `WHERE 0=1`, so `IsRead` is **never** set; every issue always
appears unread | #29515 |
| `ParseCommitsWithStatus` | `GetLatestCommitStatus` called once per
commit (O(n) queries on commit list / PR commits tab) | #33605 |
| `getReleaseInfos` (release list) | `GetLatestCommitStatus` called once
per release for CI badges | #29149 |
| User milestone dashboard | O(n×m) nested loop matching milestones to
repos | #26300 |
| `findCodeComments` (PR diff) | `LoadResolveDoer` + `LoadReactions`
called per inline comment — up to ~150 queries on a PR with 50 comments
| #20821 |

---------

Co-authored-by: Lauris B <lauris@nix.lv>
This commit is contained in:
bircni
2026-06-21 14:34:07 +00:00
committed by GitHub
co-authored by Lauris B
parent ceec230fc0
commit 180af33f86
7 changed files with 135 additions and 32 deletions
+6 -6
View File
@@ -242,13 +242,13 @@ func Milestones(ctx *context.Context) {
}
sort.Sort(showRepos)
repoByID := make(map[int64]*repo_model.Repository, len(showRepos))
for _, repo := range showRepos {
repoByID[repo.ID] = repo
}
for i := 0; i < len(milestones); {
for _, repo := range showRepos {
if milestones[i].RepoID == repo.ID {
milestones[i].Repo = repo
break
}
}
milestones[i].Repo = repoByID[milestones[i].RepoID]
if milestones[i].Repo == nil {
log.Warn("Cannot find milestone %d 's repository %d", milestones[i].ID, milestones[i].RepoID)
milestones = append(milestones[:i], milestones[i+1:]...)