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

feat(storage): Trie cache limit on value cached #2770

Merged
merged 7 commits into from
Jun 4, 2020
Merged

Conversation

mikhailOK
Copy link
Contributor

Don't cache large values and assume that accessing rocksdb is good
enough for them.

Also don't cache when a hash is missing from storage: retrieve_rc does
not benefit from caching those cases, and retrieve_raw_bytes is never
supposed to be called for missing values.

Also add no_cache feature to near-store and make
runtime-params-estimator enable it.

Fixes #940

Test plan

Existing tests

Don't cache large values and assume that accessing rocksdb is good
enough for them.

Also don't cache when a hash is missing from storage: retrieve_rc does
not benefit from caching those cases, and retrieve_raw_bytes is never
supposed to be called for missing values.

Also add no_cache feature to near-store and make
runtime-params-estimator enable it.

Fixes #940

Test plan
---------
Existing tests
@gitpod-io
Copy link

gitpod-io bot commented Jun 2, 2020

@mikhailOK mikhailOK requested a review from lexfrl as a code owner June 2, 2020 22:56

/// Values above this size are never cached.
/// Note that Trie inner nodes are always smaller than this.
const TRIE_MAX_VALUE_CACHED: usize = 4000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to annotate the unit as well (looks like it's byte here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the comment?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we call it TRIE_LIMIT_CACHED_VALUE_SIZE; I find the current name confusing as it sounds like there are values 1, 2, 3, .... 4000, 100500, and we only cache the values that are below 4000 (max value).

core/store/src/trie/trie_storage.rs Outdated Show resolved Hide resolved

/// Values above this size are never cached.
/// Note that Trie inner nodes are always smaller than this.
const TRIE_MAX_VALUE_CACHED: usize = 4000;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we call it TRIE_LIMIT_CACHED_VALUE_SIZE; I find the current name confusing as it sounds like there are values 1, 2, 3, .... 4000, 100500, and we only cache the values that are below 4000 (max value).

@bowenwang1996 bowenwang1996 merged commit dc2974f into master Jun 4, 2020
@bowenwang1996 bowenwang1996 deleted the trie_cache branch June 4, 2020 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TrieCachingStorage cache: limit caching large values
4 participants