feat(trie): add Prometheus metrics for tries #2720
Closed
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.
Changes
💁 this PR shall be the foundation to accommodate several future additional metrics (such as number of key bytes, number of value bytes for all tries, number of encodings, disk operations etc.)
Changes consist essentially in:
internal/runtime/metrics/roothash
internal/runtime/metrics/proof
internal/state/metrics
Die()
method to clear metrics (add nodes removed). This is used when the trie is no longer needed and would be GC. We kind of need this to keep track of the total number of nodes kept in memory, especially for state tries.The alternative implementation would be to return statistics from trie operations (
Put
,Delete
etc.) and handle all the metrics in callers (lib/runtime/wasmer/imports.go and dot/state/tries.go). That makes a bit more sense so we handle all the metricing in callers, since those metrics are not specific to a single trie. On the other hand, that looks like it would require a lot more code changes 😢Tests
Issues
#2229
Primary Reviewer
@timwu20