Skip to content

Commit 776cce9

Browse files
Neopalliumbkchr
andcommitted
TrieCache: Fine tune the size of the local and node cache (#14191) (paritytech#37)
First, we increase the size to 10MiB for the local cache. Second, we give the node cache a bigger max size than the value cache, see the changed comment on why. In general this should ensure that we are able to cache the `:code` and not directly throw it out of the cache because it is too big (which currently happens when the size of the runtime > 2MiB). In the future this should be improved to ensure that certain values are not removed from the cache at all, like `:code`. Co-authored-by: Bastian Köcher <git@kchr.de> Signed-off-by: Robert G. Jakabosky <rjakabosky+neopallium@neoawareness.com>
1 parent 572b55a commit 776cce9

File tree

1 file changed

+6
-2
lines changed
  • substrate/primitives/trie/src/cache

1 file changed

+6
-2
lines changed

substrate/primitives/trie/src/cache/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,13 @@ const LOCAL_NODE_CACHE_MAX_INLINE_SIZE: usize = 512 * 1024;
9191
const LOCAL_VALUE_CACHE_MAX_INLINE_SIZE: usize = 512 * 1024;
9292

9393
/// The maximum size of the memory allocated on the heap by the local cache, in bytes.
94-
const LOCAL_NODE_CACHE_MAX_HEAP_SIZE: usize = 2 * 1024 * 1024;
94+
///
95+
/// The size of the node cache should always be bigger than the value cache. The value
96+
/// cache is only holding weak references to the actual values found in the nodes and
97+
/// we account for the size of the node as part of the node cache.
98+
const LOCAL_NODE_CACHE_MAX_HEAP_SIZE: usize = 8 * 1024 * 1024;
9599
/// Same as [`LOCAL_NODE_CACHE_MAX_HEAP_SIZE`].
96-
const LOCAL_VALUE_CACHE_MAX_HEAP_SIZE: usize = 4 * 1024 * 1024;
100+
const LOCAL_VALUE_CACHE_MAX_HEAP_SIZE: usize = 2 * 1024 * 1024;
97101

98102
/// The size of the shared cache.
99103
#[derive(Debug, Clone, Copy)]

0 commit comments

Comments
 (0)