mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-07 21:14:01 -05:00
High CPU consumption due to frequently Garbage Collect (GC) #13442
Closed
opened 2025-11-02 10:42:27 -06:00 by GiteaMirror
·
20 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.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
v1.4.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#13442
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 @Syize on GitHub (Sep 2, 2024).
Description
Hi,
Recently I've been troubled by the issue of high CPU consumption of Gitea. The CPU consumption often become very high after running about 10 hours, and restart gitea can temporally solve this problem.
The most suspicious behavior of gitea during high CPU consumption is frequent GC. I have taken a screen record when cpu consumption becomes high.
https://github.com/user-attachments/assets/da2e4e8a-bf8c-468d-8a60-8f7b8a6dfaa4
After restarting Gitea, GC seems "calm down".
Here is the log of gitea (Though I can't find any related information.)
Gitea Version
1.22.1
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
2.46.0
Operating System
Arch Linux
How are you running Gitea?
I install the latest gitea from Arch Linux repo
and make it a system service by using systemd
Database
MySQL/MariaDB
@silverwind commented on GitHub (Sep 2, 2024):
Could be be the bleve indexer, see https://github.com/go-gitea/gitea/issues/31565 and try disabling it via
REPO_INDEXER_ENABLED = false.@Syize commented on GitHub (Sep 3, 2024):
set
REPO_INDEXER_ENABLED = falsedoesn't help.@Syize commented on GitHub (Sep 7, 2024):
I set
REPO_INDEXER_ENABLED = falseand observed Gitea for a few days. This issue won't happen even Gitea has run 1-2 days, but it happens after system reboot, and the change of system time seems to be one of the causes triggering this problem.Sometimes I switch to Windows to play games and then switch back to Arch Linux. Because of the different ways Windows and Linux handle the hardware clock (its a normal issue), the system time in Linux is 8 hours ahead(because I'm in UTC+8 timezone), and Linux will update system time as soon as it connect to Internet. I found this issue occurs immediately after system time update. Restart gitea manually could calm Gitea down.
As for Gitea's log, I have changed log level to
trace, but Gitea doesn't output any additional information inlog/gitea.log.@lunny commented on GitHub (Jan 5, 2025):
You need to change the log mode to
fileto record the log to file. Your logs uploaded don't record what happened when theGCis running.@Syize commented on GitHub (Jan 5, 2025):
The log mode had been
MODE = console, filebefore I changed log level toTrace.This issue hasn't occured again after I set
REPO_INDEXER_ENABLED = falseand resolved this time synchronization issue between Windows and Linux. It works fine now.@wxiaoguang commented on GitHub (Jan 6, 2025):
https://docs.gitea.com/help/support
@coder-xiaomo commented on GitHub (Jan 23, 2025):
facing the same problem in gitea 1.23.1
CPU consumption is very high, and currently my REPO_INDEXER_ENABLED is set to false.
this problem cames after i update to version 1.23.1, older versions (1.22.x) didn't have this problem
Maybe there is another solution?
@coder-xiaomo commented on GitHub (Jan 23, 2025):
the 内存分配次数 and 内存释放次数 number was growing very very fast, about 10,000 times in 1 second
@wxiaoguang commented on GitHub (Jan 24, 2025):
https://docs.gitea.com/help/support
@wxiaoguang commented on GitHub (Jan 24, 2025):
And from your screenshot, I can see the the "free memory" is low. It seems that you are running a lot of services in a host which only has 3.4G memory. Maybe you could try to stop unrelated services or move Gitea to a new host to try.
@wxiaoguang commented on GitHub (Jan 24, 2025):
In 1.23 , there is a license classifier, which consumes much more memory than 1.22 (100MB more) , so if the memory is low, the GC number could also become very high.
@yp05327
license classifier memory usage screenshot
@yp05327 commented on GitHub (Jan 24, 2025):
The origin issue is in 1.22.1 and there's another issue in 1.23.1 which seems that it is caused by the new license detect feature.
About the issue in 1.22.1, I also met a simillar situation in 1.22.x once before, but can not reproduce it again.
About the issue in 1.23.1. If the memory usage of licenseclassifier should be considered as annoying, maybe we can add an option to disable this feature. IMO, It is similar to a indexer (or a search system) to compare between the detected license file and the sample files. I don't know how to reduce the mem usage from Gitea side, as it seems that these marked functions are all internal functions in licenseclassifier, and how to design a search system which uses very low mem usage and very fast search speed?
ps: Your instance which has no mem swap and less than 4GB mem is running Redis + Mysql+ Gitea + JAVA App + YDService and maybe more which seems too heavy.
@silverwind commented on GitHub (Jan 24, 2025):
I don't see it similar. All that should be stored with licenseclassifier is is a simple map of repo to license, e.g. a small cached map, and that should consume miniscule amounts of memory.
While it is running, increased memory is acceptable, but if there is more in use after it has run, that would indicate unnecessary storage or a memory leak in the module.
@yp05327 commented on GitHub (Jan 24, 2025):
licenseclassifier is used to classify/detect the provided license file belongs to which kind of license, not a
map of repo to license(it is saved in DB)The solution is loading the raw data of all known sample license files to licenseclassifier (in mem) when server start, then we can use it in any time instead of loading them every time. You can check the implementation in
InitLicenseClassifierfunc.All all known sample license files are in:
https://github.com/go-gitea/gitea/tree/main/options/license
and custom license files will also be loaded, IIRC.
The total size is 6.1M
@silverwind commented on GitHub (Jan 24, 2025):
DB "cache" is fine too, but I'd advise against loading all license files into memory, that won't scale too well with instances that have millions of repos. Just re-write the DB entry when the repo is being pushed to.
@silverwind commented on GitHub (Jan 24, 2025):
Maybe I misread. 6MB static sample licenses is fine of course.
@lunny commented on GitHub (Jan 24, 2025):
An advantage to putting those license information in a database is they can be updated on the fly but not always wait for another release.
@wxiaoguang commented on GitHub (Jan 31, 2025):
Some of these discussions are off-topic. Let's focus on the problem:
Update:
The "license" memory usage should should have been fixed by Only keep popular licenses #33832 (in the current development branch "main" 1.24)
@GiteaBot commented on GitHub (Mar 3, 2025):
We close issues that need feedback from the author if there were no new comments for a month. 🍵
@wxiaoguang commented on GitHub (Mar 10, 2025):
The "license" memory usage should should have been fixed by Only keep popular licenses #33832 (in the current development branch "main" 1.24)