Skip to content

[stable2506] Backport #8832 #8847

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

Merged
merged 5 commits into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion polkadot/node/subsystem-util/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

//! Convenient interface to runtime information.

use polkadot_node_primitives::MAX_FINALITY_LAG;
use schnellru::{ByLength, LruMap};

use codec::Encode;
Expand Down Expand Up @@ -135,7 +136,12 @@ impl RuntimeInfo {
/// Create with more elaborate configuration options.
pub fn new_with_config(cfg: Config) -> Self {
Self {
session_index_cache: LruMap::new(ByLength::new(cfg.session_cache_lru_size.max(10))),
// Usually messages are processed for blocks pointing to hashes from last finalized
// block to to best, so make this cache large enough to hold at least this amount of
// hashes, so that we get the benefit of caching even when finality lag is large.
session_index_cache: LruMap::new(ByLength::new(
cfg.session_cache_lru_size.max(2 * MAX_FINALITY_LAG),
)),
session_info_cache: LruMap::new(ByLength::new(cfg.session_cache_lru_size)),
disabled_validators_cache: LruMap::new(ByLength::new(100)),
pinned_blocks: LruMap::new(ByLength::new(cfg.session_cache_lru_size)),
Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_8832.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: increase session index cache
doc:
- audience: Node Dev
description: |-
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.

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.
crates:
- name: polkadot-node-subsystem-util
bump: patch
Loading