mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +00:00
Expose state-db memory info (#5110)
This exposes memory statistics from the state-db.
This commit is contained in:
@@ -46,9 +46,11 @@ use std::path::PathBuf;
|
||||
use std::io;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use sc_client_api::{execution_extensions::ExecutionExtensions, ForkBlocks, UsageInfo, MemoryInfo, BadBlocks, IoInfo};
|
||||
use sc_client_api::backend::NewBlockState;
|
||||
use sc_client_api::backend::PrunableStateChangesTrieStorage;
|
||||
use sc_client_api::{
|
||||
ForkBlocks, UsageInfo, MemoryInfo, BadBlocks, IoInfo, MemorySize,
|
||||
execution_extensions::ExecutionExtensions,
|
||||
backend::{NewBlockState, PrunableStateChangesTrieStorage},
|
||||
};
|
||||
use sp_blockchain::{
|
||||
Result as ClientResult, Error as ClientError,
|
||||
well_known_cache_keys, HeaderBackend,
|
||||
@@ -1455,13 +1457,17 @@ impl<Block: BlockT> sc_client_api::backend::Backend<Block> for Backend<Block> {
|
||||
self.state_usage.take(),
|
||||
)
|
||||
);
|
||||
let database_cache = parity_util_mem::malloc_size(&*self.storage.db);
|
||||
let state_cache = (*&self.shared_cache).lock().used_storage_cache_size();
|
||||
let database_cache = MemorySize::from_bytes(parity_util_mem::malloc_size(&*self.storage.db));
|
||||
let state_cache = MemorySize::from_bytes(
|
||||
(*&self.shared_cache).lock().used_storage_cache_size(),
|
||||
);
|
||||
let state_db = self.storage.state_db.memory_info();
|
||||
|
||||
Some(UsageInfo {
|
||||
memory: MemoryInfo {
|
||||
state_cache,
|
||||
database_cache,
|
||||
state_db,
|
||||
},
|
||||
io: IoInfo {
|
||||
transactions: io_stats.transactions,
|
||||
|
||||
@@ -317,7 +317,7 @@ impl<Block: BlockT> LightStorage<Block> {
|
||||
// if the header includes changes trie root, let's build a changes tries roots CHT
|
||||
if header.digest().log(DigestItem::as_changes_trie_root).is_some() {
|
||||
let mut current_num = new_cht_start;
|
||||
let cht_range = ::std::iter::from_fn(|| {
|
||||
let cht_range = std::iter::from_fn(|| {
|
||||
let old_current_num = current_num;
|
||||
current_num = current_num + One::one();
|
||||
Some(old_current_num)
|
||||
@@ -572,15 +572,16 @@ impl<Block> LightBlockchainStorage<Block> for LightStorage<Block>
|
||||
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
fn usage_info(&self) -> Option<UsageInfo> {
|
||||
use sc_client_api::{MemoryInfo, IoInfo};
|
||||
use sc_client_api::{MemoryInfo, IoInfo, MemorySize};
|
||||
|
||||
let database_cache = parity_util_mem::malloc_size(&*self.db);
|
||||
let database_cache = MemorySize::from_bytes(parity_util_mem::malloc_size(&*self.db));
|
||||
let io_stats = self.io_stats.take_or_else(|| self.db.io_stats(kvdb::IoStatsKind::SincePrevious));
|
||||
|
||||
Some(UsageInfo {
|
||||
memory: MemoryInfo {
|
||||
database_cache,
|
||||
state_cache: 0,
|
||||
state_cache: Default::default(),
|
||||
state_db: Default::default(),
|
||||
},
|
||||
io: IoInfo {
|
||||
transactions: io_stats.transactions,
|
||||
|
||||
Reference in New Issue
Block a user