Add instrumentation, with performance profiling capability (#4132)

* Implement instrumentation for performance profiling

* Add profiling to runtime functions declared in `decl_module` inc.
`on_initialize` and `on_finalize`

* Remove changes

* add docs, tidy up

* fix versions

* fix copyright date

* switch to hashmap and instant

* update example

* update example

* implement receiver for logger and make default

* fix comment

* use `if_std!` macro

* remove whitespace

* fix whitespace

* fix nits
This commit is contained in:
mattrutherford
2019-11-22 14:21:36 +00:00
committed by Gavin Wood
parent 082c58176e
commit 9cc16e539e
14 changed files with 382 additions and 11 deletions
+5 -2
View File
@@ -205,7 +205,6 @@ where
);
panic_handler::set(version.support_url, &full_version);
let matches = CoreParams::<CC, RP>::clap()
.name(version.executable_name)
.author(version.author)
@@ -216,7 +215,6 @@ where
.setting(AppSettings::SubcommandsNegateReqs)
.get_matches_from(args);
let cli_args = CoreParams::<CC, RP>::from_clap(&matches);
init_logger(cli_args.get_log_filter().as_ref().map(|v| v.as_ref()).unwrap_or(""));
fdlimit::raise_fd_limit();
@@ -846,6 +844,9 @@ where
config.telemetry_endpoints = Some(TelemetryEndpoints::new(cli.telemetry_endpoints));
}
config.tracing_targets = cli.tracing_targets.into();
config.tracing_receiver = cli.tracing_receiver.into();
// Imply forced authoring on --dev
config.force_authoring = cli.shared_params.dev || cli.force_authoring;
@@ -901,6 +902,8 @@ fn init_logger(pattern: &str) {
builder.filter(Some("ws"), log::LevelFilter::Off);
builder.filter(Some("hyper"), log::LevelFilter::Warn);
builder.filter(Some("cranelift_wasm"), log::LevelFilter::Warn);
// Always log the special target `substrate_tracing`, overrides global level
builder.filter(Some("substrate_tracing"), log::LevelFilter::Info);
// Enable info for others.
builder.filter(None, log::LevelFilter::Info);
+32
View File
@@ -259,6 +259,24 @@ pub struct TransactionPoolParams {
pub pool_kbytes: usize,
}
arg_enum! {
#[allow(missing_docs)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum TracingReceiver {
Log,
Telemetry,
}
}
impl Into<substrate_tracing::TracingReceiver> for TracingReceiver {
fn into(self) -> substrate_tracing::TracingReceiver {
match self {
TracingReceiver::Log => substrate_tracing::TracingReceiver::Log,
TracingReceiver::Telemetry => substrate_tracing::TracingReceiver::Telemetry,
}
}
}
/// Execution strategies parameters.
#[derive(Debug, StructOpt, Clone)]
pub struct ExecutionStrategies {
@@ -491,6 +509,20 @@ pub struct RunCmd {
#[structopt(long = "force-authoring")]
pub force_authoring: bool,
/// Comma separated list of targets for tracing
#[structopt(long = "tracing-targets", value_name = "TARGETS")]
pub tracing_targets: Option<String>,
/// Receiver to process tracing messages
#[structopt(
long = "tracing-receiver",
value_name = "RECEIVER",
possible_values = &TracingReceiver::variants(),
case_insensitive = true,
default_value = "Log"
)]
pub tracing_receiver: TracingReceiver,
/// Specify custom keystore path.
#[structopt(long = "keystore-path", value_name = "PATH", parse(from_os_str))]
pub keystore_path: Option<PathBuf>,