From f04286d617b765ac6480f3773e4f20971c22dd06 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Tue, 11 Nov 2025 12:02:40 +0100 Subject: [PATCH] common/httpserver: enable block and mutex profiling The value for block should match CPU profiling at 99Hz. The value for mutex looks low enough to not add too much overhead. There is no overhead while not profiling. --- common/httpserver/root.go | 3 +++ console/data/docs/99-changelog.md | 1 + 2 files changed, 4 insertions(+) diff --git a/common/httpserver/root.go b/common/httpserver/root.go index 40dd4cd0..52f7a5a1 100644 --- a/common/httpserver/root.go +++ b/common/httpserver/root.go @@ -10,6 +10,7 @@ import ( "net" "net/http" "net/http/pprof" + "runtime" "time" "github.com/chenyahui/gin-cache/persist" @@ -65,6 +66,8 @@ func New(r *reporter.Reporter, configuration Configuration, dependencies Depende c.mux.HandleFunc("/debug/pprof/profile", pprof.Profile) c.mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) c.mux.HandleFunc("/debug/pprof/trace", pprof.Trace) + runtime.SetBlockProfileRate(int(10 * time.Millisecond.Nanoseconds())) // 1/10ms + runtime.SetMutexProfileFraction(1000) // 0.1% } return &c, nil } diff --git a/console/data/docs/99-changelog.md b/console/data/docs/99-changelog.md index effb0ae5..3bff25f5 100644 --- a/console/data/docs/99-changelog.md +++ b/console/data/docs/99-changelog.md @@ -16,6 +16,7 @@ identified with a specific icon: ClickHouse, Kafka and remote data sources (previously, `verify` was set to false by default) - 🩹 *outlet*: provide additional gracetime for a worker to send to ClickHouse +- 🌱 *common*: enable block and mutex profiling - 🌱 *config*: rename `verify` to `skip-verify` in TLS configurations for ClickHouse, Kafka and remote data sources (with inverted logic) - 🌱 *config*: remote data sources accept a specific TLS configuration