Skip to content

Commit ab1d31a

Browse files
paritytech-release-backport-bot[bot]alexgghsandreimgithub-actions[bot]EgorPopelyaev
authored
[stable2503] Backport #8832 (#8846)
Backport #8832 into `stable2503` from alexggh. See the [documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md) on how to use this bot. <!-- # To be used by other automation, do not modify: original-pr-number: #${pull_number} --> Signed-off-by: Alexandru Gheorghe <[email protected]> Co-authored-by: Alexandru Gheorghe <[email protected]> Co-authored-by: Andrei Sandu <[email protected]> Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Egor_P <[email protected]>
1 parent dfa3e3b commit ab1d31a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

polkadot/node/subsystem-util/src/runtime/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
//! Convenient interface to runtime information.
1818
19+
use polkadot_node_primitives::MAX_FINALITY_LAG;
1920
use schnellru::{ByLength, LruMap};
2021

2122
use codec::Encode;
@@ -135,7 +136,12 @@ impl RuntimeInfo {
135136
/// Create with more elaborate configuration options.
136137
pub fn new_with_config(cfg: Config) -> Self {
137138
Self {
138-
session_index_cache: LruMap::new(ByLength::new(cfg.session_cache_lru_size.max(10))),
139+
// Usually messages are processed for blocks pointing to hashes from last finalized
140+
// block to to best, so make this cache large enough to hold at least this amount of
141+
// hashes, so that we get the benefit of caching even when finality lag is large.
142+
session_index_cache: LruMap::new(ByLength::new(
143+
cfg.session_cache_lru_size.max(2 * MAX_FINALITY_LAG),
144+
)),
139145
session_info_cache: LruMap::new(ByLength::new(cfg.session_cache_lru_size)),
140146
disabled_validators_cache: LruMap::new(ByLength::new(100)),
141147
pinned_blocks: LruMap::new(ByLength::new(cfg.session_cache_lru_size)),

prdoc/pr_8832.prdoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
title: increase session index cache
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
A 10 session index cache is not enough when you run under intense pressure and finality is lagg since you will end requesting the session index for blocks older than that. So let's make this cache larger to achieve its purpose even under intense load when it actually matters more to be faster.
6+
7+
The session_index_cache keeps a Hash and a u32, so that's about 36 bytes per entry, with this increase it can grow up to 65k which is not that big in my book.
8+
crates:
9+
- name: polkadot-node-subsystem-util
10+
bump: patch

0 commit comments

Comments
 (0)