From 2f5f7cb0d79b900d808a5a578a132e5ca72a9640 Mon Sep 17 00:00:00 2001 From: Nadja Reitzenstein Date: Thu, 23 Jun 2022 14:37:17 +0200 Subject: [PATCH] More ideas about how to record data --- Cargo.lock | 35 ++++++++++++++++++++++++++++ runtime/executor/Cargo.toml | 6 ++++- runtime/executor/src/pool.rs | 11 --------- runtime/lightproc/src/proc_handle.rs | 8 +++++++ 4 files changed, 48 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4764797..6932cc5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1119,11 +1119,13 @@ dependencies = [ "crossbeam-utils", "futures-timer", "futures-util", + "hdrhistogram", "lazy_static", "libc", "lightproc", "num_cpus", "once_cell", + "parking_lot", "pin-utils", "rand", "slab", @@ -1782,6 +1784,16 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "lock_api" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" +dependencies = [ + "autocfg", + "scopeguard", +] + [[package]] name = "log" version = "0.4.17" @@ -2029,6 +2041,29 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-sys", +] + [[package]] name = "percent-encoding" version = "2.1.0" diff --git a/runtime/executor/Cargo.toml b/runtime/executor/Cargo.toml index ac3a2c3..85c6df6 100644 --- a/runtime/executor/Cargo.toml +++ b/runtime/executor/Cargo.toml @@ -40,13 +40,17 @@ libc = "0.2" num_cpus = "1.13" pin-utils = "0.1.0" slab = "0.4" +parking_lot = "0.12" # Allocator arrayvec = { version = "0.7.0" } futures-timer = "3.0.2" once_cell = "1.4.0" -tracing = "0.1.19" crossbeam-queue = "0.3.0" +hdrhistogram = "7.5" + +# Stats & Tracing +tracing = "0.1" [dev-dependencies] async-std = "1.10.0" diff --git a/runtime/executor/src/pool.rs b/runtime/executor/src/pool.rs index 50adb8b..4f288d6 100644 --- a/runtime/executor/src/pool.rs +++ b/runtime/executor/src/pool.rs @@ -48,21 +48,12 @@ impl Spooler<'_> { /// Global executor pub struct Executor<'a> { spooler: Arc>, - span: Span, } impl<'a, 'executor: 'a> Executor<'executor> { pub fn new() -> Self { Executor { spooler: Arc::new(Spooler::new()), - span: tracing::span!(Level::INFO, "executor"), - } - } - - pub fn new_with_parent_span(parent: &Span) -> Self { - Executor { - spooler: Arc::new(Spooler::new()), - span: tracing::span!(parent: parent, Level::INFO, "executor"), } } @@ -115,7 +106,6 @@ impl<'a, 'executor: 'a> Executor<'executor> { let location = std::panic::Location::caller(); let span = tracing::trace_span!( target: "executor::task", - parent: Span::current(), "runtime.spawn", loc.file = location.file(), loc.line = location.line(), @@ -138,7 +128,6 @@ impl<'a, 'executor: 'a> Executor<'executor> { let location = std::panic::Location::caller(); let span = tracing::trace_span!( target: "executor::task", - parent: Span::current(), "runtime.spawn", loc.file = location.file(), loc.line = location.line(), diff --git a/runtime/lightproc/src/proc_handle.rs b/runtime/lightproc/src/proc_handle.rs index 2dd7666..7a399d6 100644 --- a/runtime/lightproc/src/proc_handle.rs +++ b/runtime/lightproc/src/proc_handle.rs @@ -191,6 +191,14 @@ impl Drop for ProcHandle { let mut output = None; unsafe { + // Record dropping the handle for this task + let id = (&(*pdata).span).id().map(|id| id.into_u64()).unwrap_or(0); + tracing::trace!( + target: "executor::handle", + op = "handle.drop", + task.id = id, + ); + // Optimistically assume the `ProcHandle` is being dropped just after creating the // proc. This is a common case so if the handle is not used, the overhead of it is only // one compare-exchange operation.