trie: don't report the root flushlist as an alloc #16945
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #16907.
The trie database (memcache) has a method to retrieve the currently consumed memory. When adding the streaming GC, I modified it so it also reports the size of the doubly-linked flushlist, which we use to flush out old data first.
There was a slight error in this reporting. The trie database has a root node (unkeyed), which acts as the singleton parent for all tries to ensure correct GC. The flushlist size was reported as the number of nodes * 2 hashes. The root node however is a metanode that's never destroyed, so if we count this node too into the flushlist size, the trie database will always report a non-zero size (64 bytes when empty).
This caused the blockchain to always print an
ERROR
log on exit, reporting that GC is faulty due to non-zero memory use after cleanup. The memory use however was only the root metanode. This PR fixes the size reporting so that it doesn't count the metanode any more into this group.