allow configuration of profiler output volume from CLI option
This commit is contained in:
parent
e70c40cb45
commit
3c6ef3019f
21
codex.nim
21
codex.nim
|
@ -19,13 +19,11 @@ import pkg/confutils/toml/std/uri as confTomlUri
|
||||||
import pkg/toml_serialization
|
import pkg/toml_serialization
|
||||||
import pkg/libp2p
|
import pkg/libp2p
|
||||||
|
|
||||||
when defined(chronosFuturesInstrumentation):
|
|
||||||
import ./codex/utils/asyncprofiler
|
|
||||||
|
|
||||||
import ./codex/conf
|
import ./codex/conf
|
||||||
import ./codex/codex
|
import ./codex/codex
|
||||||
import ./codex/units
|
import ./codex/units
|
||||||
import ./codex/utils/keyutils
|
import ./codex/utils/keyutils
|
||||||
|
import ./codex/utils/asyncprofiler
|
||||||
|
|
||||||
export codex, conf, libp2p, chronos, chronicles
|
export codex, conf, libp2p, chronos, chronicles
|
||||||
|
|
||||||
|
@ -57,6 +55,11 @@ when isMainModule:
|
||||||
config.setupLogging()
|
config.setupLogging()
|
||||||
config.setupMetrics()
|
config.setupMetrics()
|
||||||
|
|
||||||
|
# TODO this should not be here, but currently can't have it in setupMetrics
|
||||||
|
# or we get a circular import.
|
||||||
|
when chronosFuturesInstrumentation:
|
||||||
|
AsyncProfilerInfo.initDefault(k = config.profilerMaxMetrics)
|
||||||
|
|
||||||
case config.cmd:
|
case config.cmd:
|
||||||
of StartUpCommand.noCommand:
|
of StartUpCommand.noCommand:
|
||||||
|
|
||||||
|
@ -109,18 +112,6 @@ when isMainModule:
|
||||||
|
|
||||||
notice "Stopping Codex"
|
notice "Stopping Codex"
|
||||||
|
|
||||||
when defined(chronosFuturesInstrumentation):
|
|
||||||
let metrics = getFutureSummaryMetrics()
|
|
||||||
for (k,v) in metrics.pairs():
|
|
||||||
let count = v.count
|
|
||||||
if count > 0:
|
|
||||||
echo ""
|
|
||||||
echo "metric: ", $k
|
|
||||||
echo "count: ", count
|
|
||||||
echo "avg execTime:\t", v.totalExecTime div count, "\ttotal: ", v.totalExecTime
|
|
||||||
echo "avg wallTime:\t", v.totalWallTime div count, "\ttotal: ", v.totalWallTime
|
|
||||||
echo "avg runTime:\t", v.totalRunTime div count, "\ttotal: ", v.totalRunTime
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
setControlCHook(controlCHandler)
|
setControlCHook(controlCHandler)
|
||||||
except Exception as exc: # TODO Exception
|
except Exception as exc: # TODO Exception
|
||||||
|
|
|
@ -106,6 +106,11 @@ type
|
||||||
abbr: "d"
|
abbr: "d"
|
||||||
name: "data-dir" }: OutDir
|
name: "data-dir" }: OutDir
|
||||||
|
|
||||||
|
profilerMaxMetrics* {.
|
||||||
|
desc: "Maximum number of metrics to export to Prometheus."
|
||||||
|
defaultValue: 100
|
||||||
|
name: "profiler-max-metrics" }: int
|
||||||
|
|
||||||
case cmd* {.
|
case cmd* {.
|
||||||
command
|
command
|
||||||
defaultValue: noCommand }: StartUpCommand
|
defaultValue: noCommand }: StartUpCommand
|
||||||
|
|
|
@ -181,9 +181,12 @@ when defined(metrics):
|
||||||
resetMetric(chronos_largest_exec_time_total)
|
resetMetric(chronos_largest_exec_time_total)
|
||||||
resetMetric(chronos_largest_exec_time_max)
|
resetMetric(chronos_largest_exec_time_max)
|
||||||
|
|
||||||
var asyncProfilerInfo* {.global.}: AsyncProfilerInfo = AsyncProfilerInfo.newCollector(
|
var asyncProfilerInfo* {.global.}: AsyncProfilerInfo
|
||||||
|
|
||||||
|
proc initDefault*(AsyncProfilerInfo: typedesc, k: int) =
|
||||||
|
asyncProfilerInfo = AsyncProfilerInfo.newCollector(
|
||||||
perfSampler = getFutureSummaryMetrics,
|
perfSampler = getFutureSummaryMetrics,
|
||||||
k = 10,
|
k = k,
|
||||||
# We want to collect metrics every 5 seconds.
|
# We want to collect metrics every 5 seconds.
|
||||||
sampleInterval = initDuration(seconds = 5),
|
sampleInterval = initDuration(seconds = 5),
|
||||||
clock = proc (): Time = getTime(),
|
clock = proc (): Time = getTime(),
|
||||||
|
|
|
@ -16,9 +16,8 @@ import pkg/codex/chunker
|
||||||
import pkg/codex/discovery
|
import pkg/codex/discovery
|
||||||
import pkg/codex/blocktype
|
import pkg/codex/blocktype
|
||||||
import pkg/codex/utils/asyncheapqueue
|
import pkg/codex/utils/asyncheapqueue
|
||||||
|
import pkg/codex/utils/asyncprofiler
|
||||||
|
|
||||||
when defined(chronosFuturesInstrumentation):
|
|
||||||
import pkg/codex/utils/asyncprofiler
|
|
||||||
import ../../helpers
|
import ../../helpers
|
||||||
import ../../examples
|
import ../../examples
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue