Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Remove mem_info and references to parity-util-mem #12795

Merged
merged 13 commits into from
Dec 6, 2022
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
63 changes: 10 additions & 53 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions bin/node/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ sp-state-machine = { version = "0.13.0", path = "../../../primitives/state-machi
serde = "1.0.136"
serde_json = "1.0.85"
derive_more = { version = "0.99.17", default-features = false, features = ["display"] }
kvdb = "0.12.0"
kvdb-rocksdb = "0.16.0"
kvdb = "0.13.0"
kvdb-rocksdb = "0.17.0"
sp-trie = { version = "7.0.0", path = "../../../primitives/trie" }
sp-core = { version = "7.0.0", path = "../../../primitives/core" }
sp-consensus = { version = "0.10.0-dev", path = "../../../primitives/consensus/common" }
Expand All @@ -37,7 +37,6 @@ tempfile = "3.1.0"
fs_extra = "1"
rand = { version = "0.7.2", features = ["small_rng"] }
lazy_static = "1.4.0"
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
parity-db = "0.4.2"
sc-transaction-pool = { version = "4.0.0-dev", path = "../../../client/transaction-pool" }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../../../client/transaction-pool/api" }
Expand Down
1 change: 0 additions & 1 deletion bin/node/bench/src/tempdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub enum DatabaseType {
pub struct TempDatabase(tempfile::TempDir);

struct ParityDbWrapper(parity_db::Db);
parity_util_mem::malloc_size_of_is_0!(ParityDbWrapper);

impl KeyValueDB for ParityDbWrapper {
/// Get a value by key.
Expand Down
5 changes: 0 additions & 5 deletions bin/node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ node-inspect = { version = "0.9.0-dev", optional = true, path = "../inspect" }
try-runtime-cli = { version = "0.10.0-dev", optional = true, path = "../../../utils/frame/try-runtime/cli" }
serde_json = "1.0.85"

[target.'cfg(any(target_arch="x86_64", target_arch="aarch64"))'.dependencies]
sp-trie = { version = "7.0.0", default-features = false, path = "../../../primitives/trie", features = [
"memory-tracker",
] }

[dev-dependencies]
sc-keystore = { version = "4.0.0-dev", path = "../../../client/keystore" }
sc-client-db = { version = "0.10.0-dev", path = "../../../client/db" }
Expand Down
17 changes: 0 additions & 17 deletions client/api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,26 +197,13 @@ impl fmt::Display for MemorySize {
}
}

/// Memory statistics for state db.
#[derive(Default, Clone, Debug)]
pub struct StateDbMemoryInfo {
/// Memory usage of the non-canonical overlay
pub non_canonical: MemorySize,
/// Memory usage of the pruning window.
pub pruning: Option<MemorySize>,
/// Memory usage of the pinned blocks.
pub pinned: MemorySize,
}

/// Memory statistics for client instance.
#[derive(Default, Clone, Debug)]
pub struct MemoryInfo {
/// Size of state cache.
pub state_cache: MemorySize,
/// Size of backend database cache.
pub database_cache: MemorySize,
/// Size of the state db.
pub state_db: StateDbMemoryInfo,
}

/// I/O statistics for client instance.
Expand Down Expand Up @@ -264,13 +251,9 @@ impl fmt::Display for UsageInfo {
write!(
f,
"caches: ({} state, {} db overlay), \
state db: ({} non-canonical, {} pruning, {} pinned), \
i/o: ({} tx, {} write, {} read, {} avg tx, {}/{} key cache reads/total, {} trie nodes writes)",
self.memory.state_cache,
self.memory.database_cache,
self.memory.state_db.non_canonical,
self.memory.state_db.pruning.unwrap_or_default(),
self.memory.state_db.pinned,
self.io.transactions,
self.io.bytes_written,
self.io.bytes_read,
Expand Down
8 changes: 4 additions & 4 deletions client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
hash-db = "0.15.2"
kvdb = "0.12.0"
kvdb-memorydb = "0.12.0"
kvdb-rocksdb = { version = "0.16.0", optional = true }
kvdb = "0.13.0"
kvdb-memorydb = "0.13.0"
kvdb-rocksdb = { version = "0.17.0", optional = true }
linked-hash-map = "0.5.4"
log = "0.4.17"
parity-db = "0.4.2"
Expand All @@ -36,7 +36,7 @@ sp-trie = { version = "7.0.0", path = "../../primitives/trie" }

[dev-dependencies]
criterion = "0.3.3"
kvdb-rocksdb = "0.16.0"
kvdb-rocksdb = "0.17.0"
rand = "0.8.4"
tempfile = "3.1.0"
quickcheck = { version = "1.0.3", default-features = false }
Expand Down
3 changes: 1 addition & 2 deletions client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2086,10 +2086,9 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
let state_cache = MemorySize::from_bytes(
self.shared_trie_cache.as_ref().map_or(0, |c| c.used_memory_size()),
);
let state_db = self.storage.state_db.memory_info();

Some(UsageInfo {
memory: MemoryInfo { state_cache, database_cache, state_db },
memory: MemoryInfo { state_cache, database_cache },
io: IoInfo {
transactions: io_stats.transactions,
bytes_read: io_stats.bytes_read,
Expand Down
10 changes: 3 additions & 7 deletions client/db/src/storage_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,11 @@ pub struct Cache<B: BlockT> {

struct LRUMap<K, V>(LinkedHashMap<K, V>, usize, usize);

/// Internal trait similar to `heapsize` but using
/// a simply estimation.
/// Internal trait similar to `heapsize` but using a simple estimation.
///
/// This should not be made public, it is implementation
/// detail trait. If it need to become public please
/// consider using `malloc_size_of`.
/// This should not be made public, it is an implementation detail trait.
trait EstimateSize {
/// Return a size estimation of additional size needed
/// to cache this struct (in bytes).
/// Return a size estimation of the additional size needed to cache this struct (in bytes).
fn estimate_size(&self) -> usize;
}

Expand Down
1 change: 0 additions & 1 deletion client/informant/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ansi_term = "0.12.1"
futures = "0.3.21"
futures-timer = "3.0.1"
log = "0.4.17"
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sc-network-common = { version = "0.10.0-dev", path = "../network/common" }
sc-transaction-pool-api = { version = "4.0.0-dev", path = "../transaction-pool/api" }
Expand Down
16 changes: 2 additions & 14 deletions client/informant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ use ansi_term::Colour;
use futures::prelude::*;
use futures_timer::Delay;
use log::{debug, info, trace};
use parity_util_mem::MallocSizeOf;
use sc_client_api::{BlockchainEvents, UsageProvider};
use sc_network_common::service::NetworkStatusProvider;
use sc_transaction_pool_api::TransactionPool;
use sp_blockchain::HeaderMetadata;
use sp_runtime::traits::{Block as BlockT, Header};
use std::{collections::VecDeque, fmt::Display, sync::Arc, time::Duration};
Expand Down Expand Up @@ -53,16 +51,11 @@ impl Default for OutputFormat {
}

/// Builds the informant and returns a `Future` that drives the informant.
pub async fn build<B: BlockT, C, N, P>(
client: Arc<C>,
network: N,
pool: Arc<P>,
format: OutputFormat,
) where
pub async fn build<B: BlockT, C, N>(client: Arc<C>, network: N, format: OutputFormat)
where
N: NetworkStatusProvider<B>,
C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
<C as HeaderMetadata<B>>::Error: Display,
P: TransactionPool + MallocSizeOf,
{
let mut display = display::InformantDisplay::new(format.clone());

Expand All @@ -83,11 +76,6 @@ pub async fn build<B: BlockT, C, N, P>(
"Usage statistics not displayed as backend does not provide it",
)
}
trace!(
target: "usage",
"Subsystems memory [txpool: {} kB]",
parity_util_mem::malloc_size(&*pool) / 1024,
);
display.display(&info, net_status);
future::ready(())
});
Expand Down
3 changes: 0 additions & 3 deletions client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ sp-tracing = { version = "6.0.0", path = "../../primitives/tracing" }
sc-sysinfo = { version = "6.0.0-dev", path = "../sysinfo" }
tracing = "0.1.29"
tracing-futures = { version = "0.2.4" }
parity-util-mem = { version = "0.12.0", default-features = false, features = [
"primitive-types",
] }
async-trait = "0.1.57"
tokio = { version = "1.22.0", features = ["time", "rt-multi-thread", "parking_lot"] }
tempfile = "3.1.0"
Expand Down
Loading