Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
default cache size with .min(1)
Signed-off-by: koushiro <[email protected]>
  • Loading branch information
koushiro committed Nov 1, 2022
commit 4064db8741b48cfef261f57b2a6865b9a4684bcc
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub struct RunCmd {
pub max_runtime_instances: Option<usize>,

/// Maximum number of different runtimes that can be cached.
#[arg(long, default_value_t = 2, value_parser = clap::value_parser!(u8).range(1..))]
#[arg(long, default_value_t = 2)]
pub runtime_cache_size: u8,

/// Run a temporary node.
Expand Down
2 changes: 1 addition & 1 deletion client/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
lazy_static = "1.4.0"
lru = "0.8.1"
lru = "0.8.0"
parking_lot = "0.12.1"
tracing = "0.1.29"
wasmi = "0.13"
Expand Down
3 changes: 2 additions & 1 deletion client/executor/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ impl RuntimeCache {
cache_path: Option<PathBuf>,
runtime_cache_size: u8,
) -> RuntimeCache {
let cap = NonZeroUsize::new(runtime_cache_size as usize).expect("cache size is not zero");
let cap =
NonZeroUsize::new(runtime_cache_size.min(1) as usize).expect("cache size is not zero");
RuntimeCache { runtimes: Mutex::new(LruCache::new(cap)), max_runtime_instances, cache_path }
}

Expand Down
2 changes: 1 addition & 1 deletion client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ futures = "0.3.21"
futures-timer = "3.0.1"
libp2p = { version = "0.49.0", default-features = false }
log = "0.4.17"
lru = "0.8.1"
lru = "0.8.0"
tracing = "0.1.29"
prometheus-endpoint = { package = "substrate-prometheus-endpoint", version = "0.10.0-dev", path = "../../utils/prometheus" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
Expand Down
2 changes: 1 addition & 1 deletion client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ libp2p = { version = "0.49.0", features = ["async-std", "dns", "identify", "kad"
linked_hash_set = "0.1.3"
linked-hash-map = "0.5.4"
log = "0.4.17"
lru = "0.8.1"
lru = "0.8.0"
parking_lot = "0.12.1"
pin-project = "1.0.12"
prost = "0.11"
Expand Down
5 changes: 3 additions & 2 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,9 @@ where
};

let cache_capacity = NonZeroUsize::new(
network_config.default_peers_set.in_peers as usize +
network_config.default_peers_set.out_peers as usize,
(network_config.default_peers_set.in_peers as usize +
network_config.default_peers_set.out_peers as usize)
.min(1),
)
.expect("cache capacity is not zero");
let block_announce_data_cache = LruCache::new(cache_capacity);
Expand Down
2 changes: 1 addition & 1 deletion client/network/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
futures = "0.3.21"
libp2p = "0.49.0"
log = "0.4.17"
lru = "0.8.1"
lru = "0.8.0"
mockall = "0.11.2"
prost = "0.11"
smallvec = "1.8.0"
Expand Down
3 changes: 2 additions & 1 deletion client/network/sync/src/block_request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ where
);
protocol_config.inbound_queue = Some(tx);

let capacity = NonZeroUsize::new(num_peer_hint * 2).expect("cache capacity is not zero");
let capacity =
NonZeroUsize::new(num_peer_hint.min(1) * 2).expect("cache capacity is not zero");
let seen_requests = LruCache::new(capacity);

(Self { client, request_receiver, seen_requests }, protocol_config)
Expand Down
3 changes: 2 additions & 1 deletion client/network/sync/src/state_request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ where
);
protocol_config.inbound_queue = Some(tx);

let capacity = NonZeroUsize::new(num_peer_hint * 2).expect("cache capacity is not zero");
let capacity =
NonZeroUsize::new(num_peer_hint.min(1) * 2).expect("cache capacity is not zero");
let seen_requests = LruCache::new(capacity);

(Self { client, request_receiver, seen_requests }, protocol_config)
Expand Down
3 changes: 1 addition & 2 deletions primitives/blockchain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
futures = "0.3.21"
log = "0.4.17"
lru = "0.8.1"
lru = "0.8.0"
parking_lot = "0.12.1"
thiserror = "1.0.30"
sp-api = { version = "4.0.0-dev", path = "../api" }
sp-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
sp-database = { version = "4.0.0-dev", path = "../database" }
sp-runtime = { version = "6.0.0", path = "../runtime" }
sp-state-machine = { version = "0.12.0", path = "../state-machine" }
sp-std = { version = "4.0.0", path = "../std" }
2 changes: 1 addition & 1 deletion primitives/blockchain/src/header_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use lru::LruCache;
use parking_lot::RwLock;
use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One};
use sp_std::num::NonZeroUsize;
use std::num::NonZeroUsize;

/// Set to the expected max difference between `best` and `finalized` blocks at sync.
const LRU_CACHE_SIZE: usize = 5_000;
Expand Down
2 changes: 1 addition & 1 deletion primitives/trie/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hashbrown = { version = "0.12.3", optional = true }
hash-db = { version = "0.15.2", default-features = false }
lazy_static = { version = "1.4.0", optional = true }
lru = { version = "0.8.1", optional = true }
lru = { version = "0.8.0", optional = true }
memory-db = { version = "0.30.0", default-features = false }
nohash-hasher = { version = "0.2.0", optional = true }
parking_lot = { version = "0.12.1", optional = true }
Expand Down