Skip to content
This repository has been 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
47 changes: 28 additions & 19 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 = { version = "0.12.0", path = "../../../../parity-common/kvdb" }
kvdb-rocksdb = { version = "0.16.0", path = "../../../../parity-common/kvdb-rocksdb" }
ordian marked this conversation as resolved.
Show resolved Hide resolved
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
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
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
10 changes: 2 additions & 8 deletions client/informant/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ 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;
Expand Down Expand Up @@ -56,13 +55,13 @@ impl Default for OutputFormat {
pub async fn build<B: BlockT, C, N, P>(
client: Arc<C>,
network: N,
pool: Arc<P>,
_pool: Arc<P>,
mrcnski marked this conversation as resolved.
Show resolved Hide resolved
format: OutputFormat,
) where
N: NetworkStatusProvider<B>,
C: UsageProvider<B> + HeaderMetadata<B> + BlockchainEvents<B>,
<C as HeaderMetadata<B>>::Error: Display,
P: TransactionPool + MallocSizeOf,
P: TransactionPool,
{
let mut display = display::InformantDisplay::new(format.clone());

Expand All @@ -83,11 +82,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.17.0", features = ["time", "rt-multi-thread", "parking_lot"] }
tempfile = "3.1.0"
Expand Down
1 change: 0 additions & 1 deletion client/service/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,6 @@ where
TBl::Header: Unpin,
TBackend: 'static + sc_client_api::backend::Backend<TBl> + Send,
TExPool: MaintainedTransactionPool<Block = TBl, Hash = <TBl as BlockT>::Hash>
+ parity_util_mem::MallocSizeOf
+ 'static,
{
let SpawnTasksParams {
Expand Down
20 changes: 0 additions & 20 deletions client/service/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct PrometheusMetrics {
// I/O
database_cache: Gauge<U64>,
state_cache: Gauge<U64>,
state_db: GaugeVec<U64>,
}

impl PrometheusMetrics {
Expand Down Expand Up @@ -117,13 +116,6 @@ impl PrometheusMetrics {
Gauge::new("substrate_state_cache_bytes", "State cache size in bytes")?,
registry,
)?,
state_db: register(
GaugeVec::new(
Opts::new("substrate_state_db_cache_bytes", "State DB cache in bytes"),
&["subtype"],
)?,
registry,
)?,
})
}
}
Expand Down Expand Up @@ -254,18 +246,6 @@ impl MetricsService {
if let Some(info) = info.usage.as_ref() {
metrics.database_cache.set(info.memory.database_cache.as_bytes() as u64);
metrics.state_cache.set(info.memory.state_cache.as_bytes() as u64);

metrics
.state_db
.with_label_values(&["non_canonical"])
.set(info.memory.state_db.non_canonical.as_bytes() as u64);
if let Some(pruning) = info.memory.state_db.pruning {
metrics.state_db.with_label_values(&["pruning"]).set(pruning.as_bytes() as u64);
}
metrics
.state_db
.with_label_values(&["pinned"])
.set(info.memory.state_db.pinned.as_bytes() as u64);
}
}

Expand Down
2 changes: 0 additions & 2 deletions client/state-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"] }
log = "0.4.17"
parity-util-mem = { version = "0.12.0", default-features = false, features = ["primitive-types"] }
parity-util-mem-derive = "0.1.0"
parking_lot = "0.12.1"
sc-client-api = { version = "4.0.0-dev", path = "../api" }
sp-core = { version = "7.0.0", path = "../../primitives/core" }
Loading