-
Notifications
You must be signed in to change notification settings - Fork 325
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 snappy/s2 memory leak #442
Comments
@joe-elliott Do you have an memory pprof that shows what is being leaked? Calling Close twice shouldn't hurt, so forcefully closing before returning the Writer could help in case you don't always get it called. |
I've spent some time tracking down codepaths and I believe that we are always correctly calling This is after ~6.5 hours of run time: And the same image after ~5 mins of run time: The large |
Also, running a goroutine profile and seeing 157 encoder goroutines.
Blocked on this line:
So either we are not calling Close 100% of the time or there is some sequence of calls that can orphan this goroutine. The calling order for the provided profiles was:
|
@joe-elliott That is why you IMO should just call This will also dereference the upsteam |
I found and fixed the issue in grafana/tempo#980. There was one codepath that resulted in an unclosed writer. I apologize for the noise! Thank you for your work on this excellent compression library. |
I unfortunately am unable to provide exact details or a minimally reproducible code sample, but we are seeing a memory leak when we swapped from
github.com/golang/snappy
tojackfan.us.kg/klauspost/compress/snappy
. The latter definitely performed better and we were excited to try the s2 compression as well, but we will have to revert for now.Here is the change but I don't expect you to dig through this code. It's difficult for someone unfamiliar with our codebase to track down the exact code path that makes use of compression. As far as I can tell we are correctly calling
.Close()
on the writer and allowing the reader to fall out of scope.Here is our latest attempt to use snappy. In this PR we removed all attempts to pool the reader/writer and always allocate New, but it still exhibits the leak. This mirrors how we use your zstd encoder/decoder where we do not see this issue.
Thank you for this compression library and I apologize for this vague issue, but I wanted to pass on what we were seeing. If I have time I will attempt to repro with a minimal sample and will pass along any updates.
FWIW we are using snappy for our WAL on incoming data and compressing about 5MB/s. We are seeing a leak of ~300MB/hour.
The text was updated successfully, but these errors were encountered: