Skip to content
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

Possible Memory Leak in LFS push #13318

Closed
1 of 6 tasks
v-byte-cpu opened this issue Oct 26, 2020 · 14 comments
Closed
1 of 6 tasks

Possible Memory Leak in LFS push #13318

v-byte-cpu opened this issue Oct 26, 2020 · 14 comments
Labels
performance/memory Performance issues affecting memory use

Comments

@v-byte-cpu
Copy link

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

Description

I fetched all lfs files from one repo (not in gitea) with git lfs fetch --all and pushed them to private gitea instance with git lfs push --all. First I allocated 500mb to gitea in container orchestrator, it was always enough for gitea that consumed only 128mb. I noticed that gitea was killed with OOM right after lfs push. Then I increased ram to 1gb, lfs push succeeded but memory consumption significantly increased to 780mb.

Screenshots

image

stats from orchestrator:

image

@lunny
Copy link
Member

lunny commented Oct 27, 2020

图片

Golang holds 780MB, but it in fact use 116MB.

@v-byte-cpu
Copy link
Author

v-byte-cpu commented Oct 27, 2020

@lunny Yes, but in fact app memory consumption is still high. Can it be released back to OS ?

@zeripath
Copy link
Contributor

As @lunny says I don't think your graphs show a memory leak at all.

However the spike in memory consumption is concerning to me that the LFS stream is somehow being read entirely in to memory (temporarily) before being released.

That's weird though because we definitely try not to do that - so the question is where is that occurring.

Now I see that you're using 1.12.1 - it would be helpful is you could update to at least 1.12.5 as there was a problem with repo stats reading entire files in to memory in that version and then try again.

@v-byte-cpu
Copy link
Author

@zeripath ok, I will update gitea version and try again

@v-byte-cpu
Copy link
Author

v-byte-cpu commented Oct 28, 2020

@zeripath I updated gitea to 1.12.5

Before lfs push:

image

After lfs push files with total summary size 40mb (like in original case):

image

image

The situation is much better now. However, Heap Memory Obtained is still increasing (1.5x). Is it possible to release Heap Memory Idle ? And yes, it is still pretty high spike in memory consumption in relation to upload file size (40mb).

@zeripath
Copy link
Contributor

In regards to relating heap memory that's something that you'd have to look at the golang tuning parameters. Garbage collected languages always have a delay between releasing memory and releasing heap. Go won't be using all that memory it's just there in case it needs it again.

Now the real question is the cause of that spike - because that worries me that we're loading a lot of stuff directly in to memory - which even if temporary is still bad.

The question is how to figure out what's doing that, where and how to stop it.

We do have a pprof option the problem is I genuinely don't know how to use it or where to look to learn about how to use it. But if you do - it's there for this reason.

@zeripath zeripath added the performance/memory Performance issues affecting memory use label Dec 12, 2020
@zeripath
Copy link
Contributor

zeripath commented Jan 14, 2021

I think this is likely related to the go-git memory leak problems and should now be fixed after the no-go-git PR

@v-byte-cpu would it be possible to recheck on master?

@v-byte-cpu
Copy link
Author

yes, sure. Do you have pre-built docker images for master branch ?

@JamesYFC
Copy link

JamesYFC commented Feb 11, 2021

Not sure if this is a separate issue or not but I'm seeing massive memory spikes and a consistent server crash on pushing a fairly large repo (2gb), seemingly at the end of the lfs upload.

This is the latest version of gitea (1.13.2) in a docker container on ubuntu 18.04.

Our gitea lfs is set to an external bucket (backblaze b2).

Our instance has 8gb memory and 8gb storage, but running df -h shows we use less than half the storage.
Upping the storage is no issue if that's the problem, but the crash is worrying considering I'd like to upload even bigger repos (even 20gb ones, but pretty much everything big goes to lfs)

@zeripath
Copy link
Contributor

What version?

Have you tried changing you password hashing algorithm from argon2 to a different algorithm?

@JamesYFC
Copy link

JamesYFC commented Feb 11, 2021

I mentioned it at the end, 1.13.2.
I'll edit the comment to clarify.

I'll try that and get back to you, see if it makes a difference.

@lunny
Copy link
Member

lunny commented Feb 13, 2021

I think #14673 and #14675 will fix the problem.

@zeripath
Copy link
Contributor

OK I think we can probably close this - as @lunny says the likely issue here is the memory use of argon2 on password hashing if you are using http(s) pushing. I do expect that the no-go-git PR will also have helped.

Therefore I'm going to close this.

(Of note we will need to think carefully about argon2 and other hashing limits in future - perhaps with some maximal hashing pool or the like.)

@zeripath
Copy link
Contributor

Resolved by #14673 and #14675

@go-gitea go-gitea locked and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
performance/memory Performance issues affecting memory use
Projects
None yet
Development

No branches or pull requests

4 participants