From 21b67179a44dad0e456fd574bc281280208e5d59 Mon Sep 17 00:00:00 2001 From: benbierens Date: Thu, 13 Jul 2023 16:06:16 +0200 Subject: [PATCH] remove baseline yeahstack --- codex/asyncyeah.nim | 1 + codex/blockexchange/engine/discovery.nim | 7 +++++++ codex/rest/api.nim | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) 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)