Browse Source

Only use event kind in latency warning (instead of debug output)

Avoid performance overhead.

Add comments on why we check the handling time.
tags/v0.3.12-rc0
Philipp Oppermann 9 months ago
parent
commit
20a1ade6ad
Failed to extract signature
2 changed files with 42 additions and 4 deletions
  1. +20
    -2
      binaries/coordinator/src/lib.rs
  2. +22
    -2
      binaries/daemon/src/lib.rs

+ 20
- 2
binaries/coordinator/src/lib.rs View File

@@ -197,8 +197,9 @@ async fn start_inner(
let mut daemon_connections = DaemonConnections::default();

while let Some(event) = events.next().await {
// used below for measuring the event handling duration
let start = Instant::now();
let event_debug = format!("{event:?}");
let event_kind = event.kind();

if event.log() {
tracing::trace!("Handling event {event:?}");
@@ -738,10 +739,11 @@ async fn start_inner(
},
}

// warn if event handling took too long -> the main loop should never be blocked for too long
let elapsed = start.elapsed();
if elapsed > Duration::from_millis(100) {
tracing::warn!(
"Coordinator took {}ms for handling event: {event_debug}",
"Coordinator took {}ms for handling event: {event_kind}",
elapsed.as_millis()
);
}
@@ -1154,6 +1156,22 @@ impl Event {
_ => true,
}
}

fn kind(&self) -> &'static str {
match self {
Event::NewDaemonConnection(_) => "NewDaemonConnection",
Event::DaemonConnectError(_) => "DaemonConnectError",
Event::DaemonHeartbeat { .. } => "DaemonHeartbeat",
Event::Dataflow { .. } => "Dataflow",
Event::Control(_) => "Control",
Event::Daemon(_) => "Daemon",
Event::DaemonHeartbeatInterval => "DaemonHeartbeatInterval",
Event::CtrlC => "CtrlC",
Event::Log(_) => "Log",
Event::DaemonExit { .. } => "DaemonExit",
Event::DataflowSpawnResult { .. } => "DataflowSpawnResult",
}
}
}

#[derive(Debug)]


+ 22
- 2
binaries/daemon/src/lib.rs View File

@@ -320,8 +320,9 @@ impl Daemon {
tracing::warn!("failed to update HLC with incoming event timestamp: {err}");
}

// used below for checking the duration of event handling
let start = Instant::now();
let event_debug = format!("{inner:?}");
let event_kind = inner.kind();

match inner {
Event::Coordinator(CoordinatorEvent { event, reply_tx }) => {
@@ -430,10 +431,11 @@ impl Daemon {
}
}

// warn if event handling took too long -> the main loop should never be blocked for too long
let elapsed = start.elapsed();
if elapsed > Duration::from_millis(100) {
tracing::warn!(
"Daemon took {}ms for handling event: {event_debug}",
"Daemon took {}ms for handling event: {event_kind}",
elapsed.as_millis()
);
}
@@ -2152,6 +2154,24 @@ impl From<DoraEvent> for Event {
}
}

impl Event {
pub fn kind(&self) -> &'static str {
match self {
Event::Node { .. } => "Node",
Event::Coordinator(_) => "Coordinator",
Event::Daemon(_) => "Daemon",
Event::Dora(_) => "Dora",
Event::DynamicNode(_) => "DynamicNode",
Event::HeartbeatInterval => "HeartbeatInterval",
Event::CtrlC => "CtrlC",
Event::SecondCtrlC => "SecondCtrlC",
Event::DaemonError(_) => "DaemonError",
Event::SpawnNodeResult { .. } => "SpawnNodeResult",
Event::SpawnDataflowResult { .. } => "SpawnDataflowResult",
}
}
}

#[derive(Debug)]
pub enum DaemonNodeEvent {
OutputsDone {


Loading…
Cancel
Save