mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-13 15:05:50 +00:00
Subsystems memory tracking: 1. Transaction pool (#4822)
* update sp-runtime * total update * usage informant * update to crates.io version * update Cargo.lock * update dummy update * fix todo * cleanup * avoid custom impl * Update client/transaction-pool/graph/src/future.rs Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com> * remove another custom impl * remove another custom impl * add kb in report * update Cargo.lock * review suggestions * --amend * --amend * bump parity-util-mem to 0.5.0 * bumps * update macro and versions * add to grafana * naming Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
@@ -29,6 +29,7 @@ use sp_runtime::transaction_validity::{
|
||||
|
||||
use crate::base_pool::Transaction;
|
||||
|
||||
#[derive(parity_util_mem::MallocSizeOf)]
|
||||
/// Transaction with partially satisfied dependencies.
|
||||
pub struct WaitingTransaction<Hash, Ex> {
|
||||
/// Transaction details.
|
||||
@@ -109,7 +110,7 @@ impl<Hash, Ex> WaitingTransaction<Hash, Ex> {
|
||||
///
|
||||
/// Contains transactions that are still awaiting for some other transactions that
|
||||
/// could provide a tag that they require.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, parity_util_mem::MallocSizeOf)]
|
||||
pub struct FutureTransactions<Hash: hash::Hash + Eq, Ex> {
|
||||
/// tags that are not yet provided by any transaction and we await for them
|
||||
wanted_tags: HashMap<Tag, HashSet<Hash>>,
|
||||
@@ -243,3 +244,30 @@ impl<Hash: hash::Hash + Eq + Clone, Ex> FutureTransactions<Hash, Ex> {
|
||||
self.waiting.values().fold(0, |acc, tx| acc + tx.transaction.bytes)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn can_track_heap_size() {
|
||||
let mut future = FutureTransactions::default();
|
||||
future.import(WaitingTransaction {
|
||||
transaction: Transaction {
|
||||
data: vec![0u8; 1024],
|
||||
bytes: 1,
|
||||
hash: 1,
|
||||
priority: 1,
|
||||
valid_till: 2,
|
||||
requires: vec![vec![1], vec![2]],
|
||||
provides: vec![vec![3], vec![4]],
|
||||
propagate: true,
|
||||
}.into(),
|
||||
missing_tags: vec![vec![1u8], vec![2u8]].into_iter().collect(),
|
||||
imported_at: std::time::Instant::now(),
|
||||
});
|
||||
|
||||
// data is at least 1024!
|
||||
assert!(parity_util_mem::malloc_size(&future) > 1024);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user