More ideas about how to record data

This commit is contained in:
Nadja Reitzenstein 2022-06-23 14:37:17 +02:00
parent 567df800f3
commit 2f5f7cb0d7
4 changed files with 48 additions and 12 deletions

35
Cargo.lock generated
View File

@ -1119,11 +1119,13 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
"futures-timer", "futures-timer",
"futures-util", "futures-util",
"hdrhistogram",
"lazy_static", "lazy_static",
"libc", "libc",
"lightproc", "lightproc",
"num_cpus", "num_cpus",
"once_cell", "once_cell",
"parking_lot",
"pin-utils", "pin-utils",
"rand", "rand",
"slab", "slab",
@ -1782,6 +1784,16 @@ dependencies = [
"pkg-config", "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]] [[package]]
name = "log" name = "log"
version = "0.4.17" version = "0.4.17"
@ -2029,6 +2041,29 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" 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]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.1.0" version = "2.1.0"

View File

@ -40,13 +40,17 @@ libc = "0.2"
num_cpus = "1.13" num_cpus = "1.13"
pin-utils = "0.1.0" pin-utils = "0.1.0"
slab = "0.4" slab = "0.4"
parking_lot = "0.12"
# Allocator # Allocator
arrayvec = { version = "0.7.0" } arrayvec = { version = "0.7.0" }
futures-timer = "3.0.2" futures-timer = "3.0.2"
once_cell = "1.4.0" once_cell = "1.4.0"
tracing = "0.1.19"
crossbeam-queue = "0.3.0" crossbeam-queue = "0.3.0"
hdrhistogram = "7.5"
# Stats & Tracing
tracing = "0.1"
[dev-dependencies] [dev-dependencies]
async-std = "1.10.0" async-std = "1.10.0"

View File

@ -48,21 +48,12 @@ impl Spooler<'_> {
/// Global executor /// Global executor
pub struct Executor<'a> { pub struct Executor<'a> {
spooler: Arc<Spooler<'a>>, spooler: Arc<Spooler<'a>>,
span: Span,
} }
impl<'a, 'executor: 'a> Executor<'executor> { impl<'a, 'executor: 'a> Executor<'executor> {
pub fn new() -> Self { pub fn new() -> Self {
Executor { Executor {
spooler: Arc::new(Spooler::new()), 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 location = std::panic::Location::caller();
let span = tracing::trace_span!( let span = tracing::trace_span!(
target: "executor::task", target: "executor::task",
parent: Span::current(),
"runtime.spawn", "runtime.spawn",
loc.file = location.file(), loc.file = location.file(),
loc.line = location.line(), loc.line = location.line(),
@ -138,7 +128,6 @@ impl<'a, 'executor: 'a> Executor<'executor> {
let location = std::panic::Location::caller(); let location = std::panic::Location::caller();
let span = tracing::trace_span!( let span = tracing::trace_span!(
target: "executor::task", target: "executor::task",
parent: Span::current(),
"runtime.spawn", "runtime.spawn",
loc.file = location.file(), loc.file = location.file(),
loc.line = location.line(), loc.line = location.line(),

View File

@ -191,6 +191,14 @@ impl<R> Drop for ProcHandle<R> {
let mut output = None; let mut output = None;
unsafe { 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 // 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 // proc. This is a common case so if the handle is not used, the overhead of it is only
// one compare-exchange operation. // one compare-exchange operation.