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",
"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"

View File

@ -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"

View File

@ -48,21 +48,12 @@ impl Spooler<'_> {
/// Global executor
pub struct Executor<'a> {
spooler: Arc<Spooler<'a>>,
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(),

View File

@ -191,6 +191,14 @@ impl<R> Drop for ProcHandle<R> {
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.