diff --git a/codex/asyncyeah.nim b/codex/asyncyeah.nim index 603873aa..ca6cffae 100644 --- a/codex/asyncyeah.nim +++ b/codex/asyncyeah.nim @@ -1,6 +1,7 @@ import std/[macros] var globalYeahStack* {.global, threadvar.}: seq[string] +var globalBaselineYeahStack* {.global, threadvar.}: seq[string] var globalYeahInt {.global, threadvar.}: int macro asyncyeah*(functionlike: untyped{nkProcDef | nkMethodDef | nkFuncDef}): untyped = diff --git a/codex/blockexchange/engine/discovery.nim b/codex/blockexchange/engine/discovery.nim index c47d5891..2d78da73 100644 --- a/codex/blockexchange/engine/discovery.nim +++ b/codex/blockexchange/engine/discovery.nim @@ -83,6 +83,13 @@ proc discoveryQueueLoop(b: DiscoveryEngine) {.asyncyeah.} = proc heartbeatLoop(b: DiscoveryEngine) {.asyncyeah.} = while b.discEngineRunning: await sleepAsync(1.seconds) + await sleepAsync(1.seconds) + await sleepAsync(1.seconds) + await sleepAsync(1.seconds) + await sleepAsync(1.seconds) + if globalBaselineYeahStack.len == 0: + for entry in globalYeahStack: + globalBaselineYeahStack.add(entry) proc advertiseQueueLoop*(b: DiscoveryEngine) {.asyncyeah.} = while b.discEngineRunning: diff --git a/codex/rest/api.nim b/codex/rest/api.nim index 2440f8a5..a275ecdb 100644 --- a/codex/rest/api.nim +++ b/codex/rest/api.nim @@ -342,9 +342,10 @@ proc initRestApi*(node: CodexNodeRef, conf: CodexConf, loopMeasure: LoopMeasure) when defined(chronosDurationThreshold): var breaches = newSeq[string]() proc onBreach(durationUs: int64) = - var trace = "" + var trace = "trace: " for entry in globalYeahStack: - trace = trace & " -> " & entry + if globalBaselineYeahStack.find(entry) == -1: + trace = trace & " -> " & entry error "Duration threshold breached", durationUs, trace breaches.add($durationUs & " usecs: " & trace)