From 709723b9295f760677736e06956db530066cccc4 Mon Sep 17 00:00:00 2001 From: zwl-williamzha Date: Mon, 12 Jan 2026 15:55:15 -0800 Subject: [PATCH 1/3] Go delta prof --- go.mod | 2 ++ go.sum | 4 ++++ router/admin.go | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/go.mod b/go.mod index 5daafb4c9bc..086f2525a53 100644 --- a/go.mod +++ b/go.mod @@ -20,6 +20,7 @@ require ( github.com/gofrs/uuid v4.2.0+incompatible github.com/golang/glog v1.2.4 github.com/google/go-cmp v0.6.0 + github.com/grafana/pyroscope-go/godeltaprof v0.1.9 github.com/json-iterator/go v1.1.12 github.com/julienschmidt/httprouter v1.3.0 github.com/lib/pq v1.10.4 @@ -56,6 +57,7 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d // indirect + github.com/klauspost/compress v1.17.8 // indirect github.com/magiconair/properties v1.8.6 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/reflectwalk v1.0.2 // indirect diff --git a/go.sum b/go.sum index f18a34e0ea1..de7723b629d 100644 --- a/go.sum +++ b/go.sum @@ -246,6 +246,8 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/grafana/pyroscope-go/godeltaprof v0.1.9 h1:c1Us8i6eSmkW+Ez05d3co8kasnuOY813tbMN8i/a3Og= +github.com/grafana/pyroscope-go/godeltaprof v0.1.9/go.mod h1:2+l7K7twW49Ct4wFluZD3tZ6e0SjanjcUUBPVD/UuGU= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= @@ -312,6 +314,8 @@ github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4d github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= +github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= diff --git a/router/admin.go b/router/admin.go index a90e5f233d9..54d79352afc 100644 --- a/router/admin.go +++ b/router/admin.go @@ -1,6 +1,7 @@ package router import ( + "github.com/grafana/pyroscope-go/godeltaprof" "net/http" "net/http/pprof" "time" @@ -14,12 +15,21 @@ func Admin(rateConverter *currency.RateConverter, rateConverterFetchingInterval // Add endpoints to the admin server // Making sure to add pprof routes mux := http.NewServeMux() + // Register pprof handlers mux.HandleFunc("/debug/pprof/", pprof.Index) mux.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) mux.HandleFunc("/debug/pprof/profile", pprof.Profile) mux.HandleFunc("/debug/pprof/symbol", pprof.Symbol) mux.HandleFunc("/debug/pprof/trace", pprof.Trace) + + // NewsBreak Custom Code: delta_heap (Go 1.20+ only) + dhp := godeltaprof.NewHeapProfiler() + mux.HandleFunc("/debug/pprof/delta_heap", func(w http.ResponseWriter, r *http.Request) { + // This calculates the delta since the last time this endpoint was called + dhp.Profile(w) + }) + // Register prebid-server defined admin handlers mux.HandleFunc("/currency/rates", endpoints.NewCurrencyRatesEndpoint(rateConverter, rateConverterFetchingInterval)) mux.HandleFunc("/version", endpoints.NewVersionEndpoint(version.Ver, version.Rev)) From 1904f47120cafa95d13ed5f4abb072a66dc7e1c9 Mon Sep 17 00:00:00 2001 From: zwl-williamzha Date: Mon, 12 Jan 2026 16:03:18 -0800 Subject: [PATCH 2/3] Go delta prof --- router/admin.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/admin.go b/router/admin.go index 54d79352afc..112808fd0c2 100644 --- a/router/admin.go +++ b/router/admin.go @@ -1,11 +1,11 @@ package router import ( - "github.com/grafana/pyroscope-go/godeltaprof" "net/http" "net/http/pprof" "time" + "github.com/grafana/pyroscope-go/godeltaprof" "github.com/prebid/prebid-server/v3/currency" "github.com/prebid/prebid-server/v3/endpoints" "github.com/prebid/prebid-server/v3/version" From 44c7bbab388d3c65dd3a2e8606eb20a5450c8518 Mon Sep 17 00:00:00 2001 From: zwl-williamzha Date: Mon, 12 Jan 2026 16:08:39 -0800 Subject: [PATCH 3/3] Go delta prof --- router/admin.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/router/admin.go b/router/admin.go index 112808fd0c2..3053cebe29d 100644 --- a/router/admin.go +++ b/router/admin.go @@ -5,7 +5,7 @@ import ( "net/http/pprof" "time" - "github.com/grafana/pyroscope-go/godeltaprof" + delta "github.com/grafana/pyroscope-go/godeltaprof/http/pprof" "github.com/prebid/prebid-server/v3/currency" "github.com/prebid/prebid-server/v3/endpoints" "github.com/prebid/prebid-server/v3/version" @@ -24,11 +24,9 @@ func Admin(rateConverter *currency.RateConverter, rateConverterFetchingInterval mux.HandleFunc("/debug/pprof/trace", pprof.Trace) // NewsBreak Custom Code: delta_heap (Go 1.20+ only) - dhp := godeltaprof.NewHeapProfiler() - mux.HandleFunc("/debug/pprof/delta_heap", func(w http.ResponseWriter, r *http.Request) { - // This calculates the delta since the last time this endpoint was called - dhp.Profile(w) - }) + mux.HandleFunc("/debug/pprof/delta_heap", delta.Heap) + mux.HandleFunc("/debug/pprof/delta_mutex", delta.Mutex) + mux.HandleFunc("/debug/pprof/delta_block", delta.Block) // Register prebid-server defined admin handlers mux.HandleFunc("/currency/rates", endpoints.NewCurrencyRatesEndpoint(rateConverter, rateConverterFetchingInterval))