Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Use system allocator when profiling memory #8831

Merged
merged 1 commit into from
Jun 7, 2018
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
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ slow-blocks = ["ethcore/slow-blocks"]
secretstore = ["ethcore-secretstore"]
final = ["parity-version/final"]
deadlock_detection = ["parking_lot/deadlock_detection"]
# to create a memory profile (requires nightly rust), use e.g.
# `heaptrack /path/to/parity <parity params>`,
# to visualize a memory profile, use `heaptrack_gui`
# or
# `valgrind --tool=massif /path/to/parity <parity params>`
# and `massif-visualizer` for visualization
memory_profiling = []

[lib]
path = "parity/lib.rs"
Expand Down
10 changes: 10 additions & 0 deletions parity/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! Ethcore client application.

#![warn(missing_docs)]
#![cfg_attr(feature = "memory_profiling", feature(alloc_system, global_allocator, allocator_api))]

extern crate ansi_term;
extern crate docopt;
Expand Down Expand Up @@ -91,6 +92,9 @@ extern crate pretty_assertions;
#[cfg(test)]
extern crate tempdir;

#[cfg(feature = "memory_profiling")]
extern crate alloc_system;

mod account;
mod blockchain;
mod cache;
Expand Down Expand Up @@ -125,10 +129,16 @@ use cli::Args;
use configuration::{Cmd, Execute};
use deprecated::find_deprecated;
use ethcore_logger::setup_log;
#[cfg(feature = "memory_profiling")]
use alloc_system::System;

pub use self::configuration::Configuration;
pub use self::run::RunningClient;

#[cfg(feature = "memory_profiling")]
#[global_allocator]
static A: System = System;

fn print_hash_of(maybe_file: Option<String>) -> Result<String, String> {
if let Some(file) = maybe_file {
let mut f = BufReader::new(File::open(&file).map_err(|_| "Unable to open file".to_owned())?);
Expand Down