Report memory usage
This commit is contained in:
parent
cb3608c6d3
commit
1a73d70334
@ -15,6 +15,7 @@ log = "0.3"
|
|||||||
env_logger = "0.3"
|
env_logger = "0.3"
|
||||||
time = "0.1.34"
|
time = "0.1.34"
|
||||||
rand = "0.3.13"
|
rand = "0.3.13"
|
||||||
|
heapsize = "0.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
@ -39,9 +39,10 @@ use ethcore::error::*;
|
|||||||
use ethcore::block::Block;
|
use ethcore::block::Block;
|
||||||
use io::SyncIo;
|
use io::SyncIo;
|
||||||
use time;
|
use time;
|
||||||
use std::option::Option;
|
|
||||||
use super::SyncConfig;
|
use super::SyncConfig;
|
||||||
|
|
||||||
|
known_heap_size!(0, PeerInfo, Header, HeaderId);
|
||||||
|
|
||||||
impl ToUsize for BlockNumber {
|
impl ToUsize for BlockNumber {
|
||||||
fn to_usize(&self) -> usize {
|
fn to_usize(&self) -> usize {
|
||||||
*self as usize
|
*self as usize
|
||||||
@ -134,6 +135,8 @@ pub struct SyncStatus {
|
|||||||
pub num_peers: usize,
|
pub num_peers: usize,
|
||||||
/// Total number of active peers
|
/// Total number of active peers
|
||||||
pub num_active_peers: usize,
|
pub num_active_peers: usize,
|
||||||
|
/// Heap memory used in bytes
|
||||||
|
pub mem_used: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||||
@ -246,6 +249,15 @@ impl ChainSync {
|
|||||||
blocks_total: match self.highest_block { None => 0, Some(x) => x - self.starting_block },
|
blocks_total: match self.highest_block { None => 0, Some(x) => x - self.starting_block },
|
||||||
num_peers: self.peers.len(),
|
num_peers: self.peers.len(),
|
||||||
num_active_peers: self.peers.values().filter(|p| p.asking != PeerAsking::Nothing).count(),
|
num_active_peers: self.peers.values().filter(|p| p.asking != PeerAsking::Nothing).count(),
|
||||||
|
mem_used:
|
||||||
|
// TODO: https://github.com/servo/heapsize/pull/50
|
||||||
|
// self.downloading_hashes.heap_size_of_children()
|
||||||
|
//+ self.downloading_bodies.heap_size_of_children()
|
||||||
|
//+ self.downloading_hashes.heap_size_of_children()
|
||||||
|
self.headers.heap_size_of_children()
|
||||||
|
+ self.bodies.heap_size_of_children()
|
||||||
|
+ self.peers.heap_size_of_children()
|
||||||
|
+ self.header_ids.heap_size_of_children(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,8 @@ extern crate ethcore;
|
|||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
extern crate rand;
|
extern crate rand;
|
||||||
|
#[macro_use]
|
||||||
|
extern crate heapsize;
|
||||||
|
|
||||||
use std::ops::*;
|
use std::ops::*;
|
||||||
use std::sync::*;
|
use std::sync::*;
|
||||||
|
Loading…
Reference in New Issue
Block a user