-
Notifications
You must be signed in to change notification settings - Fork 69
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
Fix memory leak due to emitting infinite events during snapshot #391
Conversation
@@ -138,14 +138,12 @@ func (iter *cacheMergeIterator) Value() []byte { | |||
// If parent is invalid, get the cache value. | |||
if !iter.parent.Valid() { | |||
value := iter.cache.Value() | |||
iter.eventManager.EmitResourceAccessReadEvent("iterator", iter.storeKey, iter.cache.Key(), value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These events are causing memory leak during snapshot creation, it should be safe to delete since those events are not being used in critical path at all
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #391 +/- ##
==========================================
- Coverage 54.80% 54.79% -0.01%
==========================================
Files 622 622
Lines 52168 52166 -2
==========================================
- Hits 28590 28585 -5
- Misses 21495 21498 +3
Partials 2083 2083
|
Describe your changes and provide context
Problem:
Currently when the wasmd snapshotter export snapshot, it will create a CacheMultiStore and use cachekv to access the historical state, which will then create a mergeIterator to iterate through key/values. In MergeIterator, everytime we access a key or value, it will emit a resource access events for "iterate" operation, but there's no limit on how many events to be emitted, so as we append more and more events to event manager during wasm snapshot, it starts to fill up the memory.
Solution:
We can completely get rid of this iterator events, that event is not useful at all.
Testing performed to validate your change
Tested and validated on atlantic-2