-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Open Pull-Requests view with > 500 organizations need more than 1 minute #15412
Comments
This looks like the offending call stack for anyone interested:
Since this code path only appears to be used in this pull request page it might be worth making a more specific functions for this query? |
@nsmith5 the first question is, how the "show pulls" process should be changed? I see two ways:
Which option you choose depends on your target group. |
Have you created empty orgs? Yes, it will be faster with better hardware. But I would say, that the current flow is not scalable. At the moment I have:
And there are ZERO pull requests. Here the result ... |
@lunny tested now with official 1.14.3 |
It's not backported to 1.14.3 |
Can you give us some updated logs? |
Take a look from this timestamp
See attachment. There are no more logs. Gitea makes for every repo 2 or 3 queries. I have 5997 repos. ;) Sorry. |
To reproduce it just import ~100 mirrors or create repos. Without this you can't analyze it. |
Could you change your configuration file to change log stack level to error? And give a new log file include http and xorm |
This is now my configuration:
But there will be nothing logged and the runtime chanched to: Issues: Powered by Gitea Version: 1.15.0 Seite: 23249ms Template: 34ms Pulls: Powered by Gitea Version: 1.15.0 Seite: 23240ms Template: 33ms @lunny why is loggin in Gitea so slow? 23 seconds with loglevel=error and ~70 seconds with loglevel=debug. |
You have to change |
Yes. This looks so:
But sql queries are not logged. The queries can you see here: #15412 (comment) |
You need to re-read the logging documentation https://docs.gitea.io/en-us/logging-configuration/#debugging-problems. Some points:
So, this is what your logging configuration should look like: [database]
...
LOG_SQL = true ; Normally we want this to be false but I'm explicitly asking you to set this to true
[log]
MODE=console ; PLEASE JUST SEND EVERYTHING TO THE CONSOLE AND REDIRECT FROM THERE
LEVEL=debug
ROUTER = console
REDIRECT_MACARON_LOG=true
COLORIZE=false That's it nothing else should be necessary - drop the rest of the Just that. If you still don't see XORM logs you can set If you absolutely cannot send things to the console and send us logs from back from there then: [database]
...
LOG_SQL = true
[log]
;ROOT_PATH= ; set this to what you need it to be
MODE=file
LEVEL=debug
ROUTER=file
XORM=file
REDIRECT_MACARON_LOG=true
COLORIZE=false but please try to give us the consolidated console logs as it is so much easier for us. |
Sorry, can't set it to console. I used the last part
Logs are attached. Gitea start -> open pull requests -> Gitea stop It will be easier if you add 100-200 mirrors on your instance. So you can better reproduce it. You don't need 5000 repos. |
Every repo have three database queries. They are repeated about 6000 times.
|
I know. This is what I wrote here #15412 (comment) (see the attached log). |
So all the 6000 repos in one org? |
Current stats: Orgs: 642 |
These calls are all occuring in: gitea/routers/web/user/home.go Line 544 in b60e814
this does: gitea/routers/web/user/home.go Lines 817 to 844 in b60e814
The issueCountByRepo is filled: gitea/routers/web/user/home.go Line 487 in b60e814
This is a regression from #13220 |
This is the first problem in this process. The first query should return all the repos which have issues (issue table has repo_id) or pull requests (pull_request table hast base_repo_id). And than you have a list of possible repos (in my case 0) to get all the needed data. But this should be optimized to. And for my 6000 repos there are NULL issues and NULL pull requests. In this case gitea should show "empty" page in less than 1-2 seconds. |
@somera if you can compile gitea - if you say that these counts are all 0, then a simple solution may be to change: repoByID := make(map[int64]*models.Repository, len(issueCountByRepo))
for id := range issueCountByRepo {
if id <= 0 {
continue
} to repoByID := make(map[int64]*models.Repository, len(issueCountByRepo))
for id, count := range issueCountByRepo {
if id <= 0 || count == 0 {
continue
} but I'm not certain. The whole code needs to be rewritten as it's clearly brutally inefficient. |
@zeripath I can work with the current release. I'm not using this feature at the moment. But if, gitea wasn't usable for me in normal process with this workflow. |
[x]
):Description
This with 1 minute is on my internal mini-server configuration.
I try to analyze what are you doing after I open the Pull-Requests link.
What I see.
First this PostgreSQL query:
explain analyze SELECT "repository"."id" FROM "repository" INNER JOIN "team_user" ON repository.owner_id = team_user.org_id INNER JOIN "team_repo" ON ('true' != 'false' and repository.is_private != 't') OR (team_user.team_id = team_repo.team_id AND repository.id = team_repo.repo_id) WHERE (team_user.uid = '1') GROUP BY repository.id
Which needs ~7 seconds on my NUC (https://ark.intel.com/content/www/us/en/ark/products/126137/intel-nuc-kit-nuc7pjyh.html -> I'm running here Gitea 1.14.0, PostgreSQL 13, Nginx, InfluxDB, Grafana), And after the first query I see a lot small PostgreSQL queries. I think one for every organization.
And when I choose other organization from the long list
I see > 500 http requests to the Gitea server
Looks like the process is "complicated" and not scalable for a lot of organizations and repos. Cause I have no pull requests on my Gitea instance
I think you should return back only all organizations which has pull requests. In my case: no one. Just the info: you dind't have any pull requests.
But this "problem" has only user with a lot of organizations and repos.
Am I right?
The text was updated successfully, but these errors were encountered: