common/httpserver: enable block and mutex profiling
Some checks failed
CI / 🤖 Check dependabot status (push) Has been cancelled
CI / 🐧 Test on Linux (${{ github.ref_type == 'tag' }}, misc) (push) Has been cancelled
CI / 🐧 Test on Linux (coverage) (push) Has been cancelled
CI / 🐧 Test on Linux (regular) (push) Has been cancelled
CI / ❄️ Build on Nix (push) Has been cancelled
CI / 🍏 Build and test on macOS (push) Has been cancelled
CI / 🧪 End-to-end testing (push) Has been cancelled
CI / 🔍 Upload code coverage (push) Has been cancelled
CI / 🔬 Test only Go (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 20) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 22) (push) Has been cancelled
CI / 🔬 Test only JS (${{ needs.dependabot.outputs.package-ecosystem }}, 24) (push) Has been cancelled
CI / ⚖️ Check licenses (push) Has been cancelled
CI / 🐋 Build Docker images (push) Has been cancelled
CI / 🐋 Tag Docker images (push) Has been cancelled
CI / 🚀 Publish release (push) Has been cancelled

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.
This commit is contained in:
Vincent Bernat
2025-11-11 12:02:40 +01:00
parent ba994811e7
commit f04286d617
2 changed files with 4 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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