From 1f543752986686024896f8296ad3b61965e738b3 Mon Sep 17 00:00:00 2001 From: hiddenMedic <124312252+hiddenMedic@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:15:02 +0200 Subject: [PATCH 01/16] added cpu profiling --- src/cli.go | 17 +++++++++-------- src/main.go | 12 ++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/cli.go b/src/cli.go index 53d9d4d2..f073c8b6 100644 --- a/src/cli.go +++ b/src/cli.go @@ -18,14 +18,15 @@ var ( globals // flags - Query string `type:"string" default:"${query_string}" env:"BRZAGUZA_QUERY" help:"Query string used for search"` - MaxPages int `type:"counter" default:"1" env:"BRZAGUZA_MAX_PAGES" help:"Number of pages to search"` - Cli bool `type:"bool" default:"false" env:"BRZAGUZA_CLI" help:"Use CLI mode"` - Visit bool `type:"bool" default:"false" env:"BRZAGUZA_VISIT" help:"Should results be visited"` - Silent bool `type:"bool" default:"false" short:"s" env:"BRZAGUZA_SILENT" help:"Should results be printed"` - Config string `type:"path" default:"${config_path}" env:"BRZAGUZA_CONFIG" help:"Config folder path"` - Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` - Verbosity int `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` + Query string `type:"string" default:"${query_string}" env:"BRZAGUZA_QUERY" help:"Query string used for search"` + MaxPages int `type:"counter" default:"1" env:"BRZAGUZA_MAX_PAGES" help:"Number of pages to search"` + Cli bool `type:"bool" default:"false" env:"BRZAGUZA_CLI" help:"Use CLI mode"` + Visit bool `type:"bool" default:"false" env:"BRZAGUZA_VISIT" help:"Should results be visited"` + Silent bool `type:"bool" default:"false" short:"s" env:"BRZAGUZA_SILENT" help:"Should results be printed"` + Config string `type:"path" default:"${config_path}" env:"BRZAGUZA_CONFIG" help:"Config folder path"` + Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` + Verbosity int `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` + CPUProfile bool `type:"bool" default:"false" short:"p" env:"BRZAGUZA_CPUPROFILE" help:"Creates brzaguza.prof for go tool pprof"` } ) diff --git a/src/main.go b/src/main.go index d89ef40e..e27b6b76 100644 --- a/src/main.go +++ b/src/main.go @@ -2,6 +2,8 @@ package main import ( "fmt" + "os" + "runtime/pprof" "time" "github.com/rs/zerolog/log" @@ -36,6 +38,16 @@ func main() { // parse cli arguments setupCli() + // start profiler + if cli.CPUProfile { + f, err := os.Create("brzaguza.prof") + if err != nil { + log.Fatal().Err(err).Msgf("couldn't create cpuprofile.") + } + pprof.StartCPUProfile(f) + defer pprof.StopCPUProfile() + } + // configure logging logger.Setup(cli.Log, cli.Verbosity) From e2baf3df938ec1b36a35b0c4dd360c5ead4193c4 Mon Sep 17 00:00:00 2001 From: hiddenMedic <124312252+hiddenMedic@users.noreply.github.com> Date: Fri, 6 Oct 2023 01:20:27 +0200 Subject: [PATCH 02/16] working.. --- .gitignore | 1 + go.mod | 3 ++ go.sum | 11 +++++++ src/cli.go | 21 ++++++------ src/main.go | 93 +++++++++++++++++++++++++++++++++++++++++++++++------ 5 files changed, 111 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 473dcc93..694d7ead 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ src/engines/*/site/* logdump/*.html log/*.log database/ +profiling/ # go generate *_stringer.go diff --git a/go.mod b/go.mod index 0acb5e5d..ccafd7e6 100644 --- a/go.mod +++ b/go.mod @@ -15,6 +15,7 @@ require ( github.com/knadh/koanf/providers/structs v0.1.0 github.com/knadh/koanf/v2 v2.0.1 github.com/natefinch/lumberjack v2.0.0+incompatible + github.com/pkg/profile v1.7.0 github.com/redis/go-redis/v9 v9.2.1 github.com/robertkrimen/otto v0.2.1 github.com/rs/zerolog v1.31.0 @@ -35,6 +36,7 @@ require ( github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/fatih/structs v1.1.0 // indirect + github.com/felixge/fgprof v0.9.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/getsentry/sentry-go v0.25.0 // indirect @@ -45,6 +47,7 @@ require ( github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect + github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.0 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect diff --git a/go.sum b/go.sum index 12d046f7..ebe7b505 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,9 @@ github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA= github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo= github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4= github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= @@ -64,6 +67,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g= +github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fxamacker/cbor/v2 v2.5.0 h1:oHsG0V/Q6E/wqTS2O1Cozzsy69nqCiguo5Q1a1ADivE= @@ -113,7 +118,10 @@ github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= +github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/jawher/mow.cli v1.1.0/go.mod h1:aNaQlc7ozF3vw6IJ2dHjp2ZFiA4ozMIYY6PyuRJwlUg= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= @@ -182,6 +190,8 @@ github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/profile v1.7.0 h1:hnbDkaNWPCLMO9wGLdBFTIZvzDrDfBM2072E1S9gJkA= +github.com/pkg/profile v1.7.0/go.mod h1:8Uer0jas47ZQMJ7VD+OHknK4YDY07LPUC6dEvqDjvNo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= @@ -292,6 +302,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/src/cli.go b/src/cli.go index f073c8b6..be043651 100644 --- a/src/cli.go +++ b/src/cli.go @@ -18,15 +18,18 @@ var ( globals // flags - Query string `type:"string" default:"${query_string}" env:"BRZAGUZA_QUERY" help:"Query string used for search"` - MaxPages int `type:"counter" default:"1" env:"BRZAGUZA_MAX_PAGES" help:"Number of pages to search"` - Cli bool `type:"bool" default:"false" env:"BRZAGUZA_CLI" help:"Use CLI mode"` - Visit bool `type:"bool" default:"false" env:"BRZAGUZA_VISIT" help:"Should results be visited"` - Silent bool `type:"bool" default:"false" short:"s" env:"BRZAGUZA_SILENT" help:"Should results be printed"` - Config string `type:"path" default:"${config_path}" env:"BRZAGUZA_CONFIG" help:"Config folder path"` - Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` - Verbosity int `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` - CPUProfile bool `type:"bool" default:"false" short:"p" env:"BRZAGUZA_CPUPROFILE" help:"Creates brzaguza.prof for go tool pprof"` + Query string `type:"string" default:"${query_string}" env:"BRZAGUZA_QUERY" help:"Query string used for search"` + MaxPages int `type:"counter" default:"1" env:"BRZAGUZA_MAX_PAGES" help:"Number of pages to search"` + Cli bool `type:"bool" default:"false" env:"BRZAGUZA_CLI" help:"Use CLI mode"` + Visit bool `type:"bool" default:"false" env:"BRZAGUZA_VISIT" help:"Should results be visited"` + Silent bool `type:"bool" default:"false" short:"s" env:"BRZAGUZA_SILENT" help:"Should results be printed"` + Config string `type:"path" default:"${config_path}" env:"BRZAGUZA_CONFIG" help:"Config folder path"` + Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` + Verbosity int `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` + CPUProfile string `type:"string" default:"" env:"BRZAGUZA_CPUPROFILE" help:"Filename for the cpu profile. Saved in profiling/ . If not specified, program is not cpu profiled."` + MEMProfile string `type:"string" default:"" env:"BRZAGUZA_MEMPROFILE" help:"Filename for the memory profile. Saved in profiling/ . If not specified, program is not memory profiled."` + GORProfile string `type:"string" default:"" env:"BRZAGUZA_GORPROFILE" help:"Filename for the goroutine profile. Saved in profiling/ . If not specified, program is not goroutine profiled."` + ThreadProfile string `type:"string" default:"" env:"BRZAGUZA_THREADPROFILE" help:"Filename for the threadcreate profile. Saved in profiling/ . If not specified, program is not threadcreate profiled."` } ) diff --git a/src/main.go b/src/main.go index e27b6b76..615cecab 100644 --- a/src/main.go +++ b/src/main.go @@ -3,9 +3,11 @@ package main import ( "fmt" "os" + "runtime" "runtime/pprof" "time" + "github.com/pkg/profile" "github.com/rs/zerolog/log" "github.com/tminaorg/brzaguza/src/bucket/result" "github.com/tminaorg/brzaguza/src/cache" @@ -32,21 +34,93 @@ func printResults(results []result.Result) { } } +func runProfiler() func() { + /* + goroutine — stack traces of all current goroutines + heap — a sampling of memory allocations of live objects + allocs — a sampling of all past memory allocations + threadcreate — stack traces that led to the creation of new OS threads + block — stack traces that led to blocking on synchronization primitives + mutex — stack traces of holders of contended mutexes + */ + + var cpup interface{} + var gorp interface{} + var blockp interface{} + var threadp interface{} + var heapp interface{} + var allocp interface{} + var mutexp interface{} + + cpup = profile.Start(profile.CPUProfile) + gorp = profile.Start(profile.GoroutineProfile) + blockp = profile.Start(profile.BlockProfile) + threadp = profile.Start(profile.ThreadcreationProfile) + heapp = profile.Start(profile.MemProfileHeap) + allocp = profile.Start(profile.MemProfileAllocs) + mutexp = profile.Start(profile.MutexProfile) + + var cpuFile *os.File + if cli.CPUProfile != "" { + cpuFile, err := os.Create("profiling/" + cli.CPUProfile) + if err != nil { + log.Fatal().Err(err).Msgf("couldn't create cpu profile. couldn't create file.") + } + if err := pprof.StartCPUProfile(cpuFile); err != nil { + log.Fatal().Err(err).Msgf("couldn't create cpu profile. couldn't run StartCPUProfile") + } + } + + profile.Start(profile.CPUProfile) + + return func() { + if cli.CPUProfile != "" { + pprof.StopCPUProfile() + if err := cpuFile.Close(); err != nil { + log.Fatal().Err(err).Msgf("couldn't create cpu profile. couldn't close file.") + } + } + + if cli.MEMProfile != "" { + f, err := os.Create("profiling/" + cli.MEMProfile) + if err != nil { + log.Fatal().Err(err).Msgf("couldn't create memory profile. couldn't create file.") + } + runtime.GC() + if err := pprof.WriteHeapProfile(f); err != nil { + log.Fatal().Err(err).Msgf("couldn't create memory profile. couldn't WriteHeapProfile.") + } + if err := f.Close(); err != nil { + log.Fatal().Err(err).Msgf("couldn't create memory profile. couldn't close file.") + } + } + + if cli.GORProfile != "" { + f, err := os.Create("profiling/" + cli.MEMProfile) + if err != nil { + log.Fatal().Err(err).Msgf("couldn't create goroutine profile. couldn't create file.") + } + if err := pprof.Lookup("goroutine").WriteTo(f, 0); err != nil { + log.Fatal().Err(err).Msgf("couldn't create goroutine profile. failed profile write.") + } + if err := f.Close(); err != nil { + log.Fatal().Err(err).Msgf("couldn't create goroutine profile. couldn't close file.") + } + } + + if cli.ThreadProfile != "" { + + } + } +} + func main() { mainTimer := time.Now() // parse cli arguments setupCli() - // start profiler - if cli.CPUProfile { - f, err := os.Create("brzaguza.prof") - if err != nil { - log.Fatal().Err(err).Msgf("couldn't create cpuprofile.") - } - pprof.StartCPUProfile(f) - defer pprof.StopCPUProfile() - } + defer runProfiler()() //runs the profiler, and defers the closing // configure logging logger.Setup(cli.Log, cli.Verbosity) @@ -107,5 +181,6 @@ func main() { db.Close() } + //closeProfiler(cli.CPUProfile, cli.MEMProfile) log.Debug().Msgf("Program finished in %vms", time.Since(mainTimer).Milliseconds()) } From a5c00a856c636fe9d2cd8e5b75edaa6d71860aea Mon Sep 17 00:00:00 2001 From: hiddenMedic <124312252+hiddenMedic@users.noreply.github.com> Date: Fri, 6 Oct 2023 01:29:27 +0200 Subject: [PATCH 03/16] added all profiles --- src/cli.go | 5 ++- src/main.go | 100 +++++++++++++++++++++------------------------------- 2 files changed, 45 insertions(+), 60 deletions(-) diff --git a/src/cli.go b/src/cli.go index be043651..7cdfdffa 100644 --- a/src/cli.go +++ b/src/cli.go @@ -27,9 +27,12 @@ var ( Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` Verbosity int `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` CPUProfile string `type:"string" default:"" env:"BRZAGUZA_CPUPROFILE" help:"Filename for the cpu profile. Saved in profiling/ . If not specified, program is not cpu profiled."` - MEMProfile string `type:"string" default:"" env:"BRZAGUZA_MEMPROFILE" help:"Filename for the memory profile. Saved in profiling/ . If not specified, program is not memory profiled."` + HeapProfile string `type:"string" default:"" env:"BRZAGUZA_HEAPPROFILE" help:"Filename for the heap profile. Saved in profiling/ . If not specified, program is not heap profiled."` GORProfile string `type:"string" default:"" env:"BRZAGUZA_GORPROFILE" help:"Filename for the goroutine profile. Saved in profiling/ . If not specified, program is not goroutine profiled."` ThreadProfile string `type:"string" default:"" env:"BRZAGUZA_THREADPROFILE" help:"Filename for the threadcreate profile. Saved in profiling/ . If not specified, program is not threadcreate profiled."` + AllocProfile string `type:"string" default:"" env:"BRZAGUZA_MEMALLOCPROFILE" help:"Filename for the alloc profile. Saved in profiling/ . If not specified, program is not alloc profiled."` + BlockProfile string `type:"string" default:"" env:"BRZAGUZA_BLOCKPROFILE" help:"Filename for the block profile. Saved in profiling/ . If not specified, program is not block profiled."` + MutexProfile string `type:"string" default:"" env:"BRZAGUZA_MUTEXPROFILE" help:"Filename for the mutex profile. Saved in profiling/ . If not specified, program is not mutex profiled."` } ) diff --git a/src/main.go b/src/main.go index 615cecab..3e044921 100644 --- a/src/main.go +++ b/src/main.go @@ -2,9 +2,6 @@ package main import ( "fmt" - "os" - "runtime" - "runtime/pprof" "time" "github.com/pkg/profile" @@ -44,72 +41,57 @@ func runProfiler() func() { mutex — stack traces of holders of contended mutexes */ - var cpup interface{} - var gorp interface{} - var blockp interface{} - var threadp interface{} - var heapp interface{} - var allocp interface{} - var mutexp interface{} - - cpup = profile.Start(profile.CPUProfile) - gorp = profile.Start(profile.GoroutineProfile) - blockp = profile.Start(profile.BlockProfile) - threadp = profile.Start(profile.ThreadcreationProfile) - heapp = profile.Start(profile.MemProfileHeap) - allocp = profile.Start(profile.MemProfileAllocs) - mutexp = profile.Start(profile.MutexProfile) - - var cpuFile *os.File + var cpup interface{ Stop() } + var gorp interface{ Stop() } + var blockp interface{ Stop() } + var threadp interface{ Stop() } + var heapp interface{ Stop() } + var allocp interface{ Stop() } + var mutexp interface{ Stop() } + if cli.CPUProfile != "" { - cpuFile, err := os.Create("profiling/" + cli.CPUProfile) - if err != nil { - log.Fatal().Err(err).Msgf("couldn't create cpu profile. couldn't create file.") - } - if err := pprof.StartCPUProfile(cpuFile); err != nil { - log.Fatal().Err(err).Msgf("couldn't create cpu profile. couldn't run StartCPUProfile") - } + cpup = profile.Start(profile.CPUProfile, profile.ProfilePath("./profiling/"+cli.CPUProfile)) + } + if cli.HeapProfile != "" { + heapp = profile.Start(profile.MemProfileHeap, profile.ProfilePath("./profiling/"+cli.HeapProfile)) + } + if cli.GORProfile != "" { + gorp = profile.Start(profile.GoroutineProfile, profile.ProfilePath("./profiling/"+cli.GORProfile)) + } + if cli.ThreadProfile != "" { + threadp = profile.Start(profile.ThreadcreationProfile, profile.ProfilePath("./profiling/"+cli.ThreadProfile)) + } + if cli.BlockProfile != "" { + blockp = profile.Start(profile.BlockProfile, profile.ProfilePath("./profiling/"+cli.BlockProfile)) + } + if cli.AllocProfile != "" { + allocp = profile.Start(profile.MemProfileAllocs, profile.ProfilePath("./profiling/"+cli.AllocProfile)) + } + if cli.MutexProfile != "" { + mutexp = profile.Start(profile.MutexProfile, profile.ProfilePath("./profiling/"+cli.MutexProfile)) } - - profile.Start(profile.CPUProfile) return func() { if cli.CPUProfile != "" { - pprof.StopCPUProfile() - if err := cpuFile.Close(); err != nil { - log.Fatal().Err(err).Msgf("couldn't create cpu profile. couldn't close file.") - } + cpup.Stop() } - - if cli.MEMProfile != "" { - f, err := os.Create("profiling/" + cli.MEMProfile) - if err != nil { - log.Fatal().Err(err).Msgf("couldn't create memory profile. couldn't create file.") - } - runtime.GC() - if err := pprof.WriteHeapProfile(f); err != nil { - log.Fatal().Err(err).Msgf("couldn't create memory profile. couldn't WriteHeapProfile.") - } - if err := f.Close(); err != nil { - log.Fatal().Err(err).Msgf("couldn't create memory profile. couldn't close file.") - } + if cli.HeapProfile != "" { + heapp.Stop() } - if cli.GORProfile != "" { - f, err := os.Create("profiling/" + cli.MEMProfile) - if err != nil { - log.Fatal().Err(err).Msgf("couldn't create goroutine profile. couldn't create file.") - } - if err := pprof.Lookup("goroutine").WriteTo(f, 0); err != nil { - log.Fatal().Err(err).Msgf("couldn't create goroutine profile. failed profile write.") - } - if err := f.Close(); err != nil { - log.Fatal().Err(err).Msgf("couldn't create goroutine profile. couldn't close file.") - } + gorp.Stop() } - if cli.ThreadProfile != "" { - + threadp.Stop() + } + if cli.BlockProfile != "" { + blockp.Stop() + } + if cli.AllocProfile != "" { + allocp.Stop() + } + if cli.MutexProfile != "" { + mutexp.Stop() } } } From 37f1534179ed6988ae030eac91e3c88c4211d52a Mon Sep 17 00:00:00 2001 From: hiddenMedic <124312252+hiddenMedic@users.noreply.github.com> Date: Fri, 6 Oct 2023 02:49:46 +0200 Subject: [PATCH 04/16] finals --- go.mod | 1 + go.sum | 2 + src/cli.go | 17 +++-- src/main.go | 76 ++-------------------- src/profiling.go | 123 +++++++++++++++++++++++++++++++++++ src/router/router.go | 7 +- src/router/search.go | 8 ++- src/sedefaults/sedefaults.go | 2 +- 8 files changed, 154 insertions(+), 82 deletions(-) create mode 100644 src/profiling.go diff --git a/go.mod b/go.mod index ccafd7e6..ff5e986e 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/cockroachdb/pebble v0.0.0-20231004191855-d4bf20c546d3 github.com/fxamacker/cbor/v2 v2.5.0 github.com/gin-contrib/cors v1.4.0 + github.com/gin-contrib/pprof v1.4.0 github.com/gin-gonic/gin v1.9.1 github.com/gocolly/colly/v2 v2.1.0 github.com/knadh/koanf/parsers/yaml v0.1.0 diff --git a/go.sum b/go.sum index ebe7b505..582f9fbf 100644 --- a/go.sum +++ b/go.sum @@ -79,6 +79,8 @@ github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= +github.com/gin-contrib/pprof v1.4.0 h1:XxiBSf5jWZ5i16lNOPbMTVdgHBdhfGRD5PZ1LWazzvg= +github.com/gin-contrib/pprof v1.4.0/go.mod h1:RrehPJasUVBPK6yTUwOl8/NP6i0vbUgmxtis+Z5KE90= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= diff --git a/src/cli.go b/src/cli.go index 7cdfdffa..a44520e8 100644 --- a/src/cli.go +++ b/src/cli.go @@ -26,13 +26,16 @@ var ( Config string `type:"path" default:"${config_path}" env:"BRZAGUZA_CONFIG" help:"Config folder path"` Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` Verbosity int `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` - CPUProfile string `type:"string" default:"" env:"BRZAGUZA_CPUPROFILE" help:"Filename for the cpu profile. Saved in profiling/ . If not specified, program is not cpu profiled."` - HeapProfile string `type:"string" default:"" env:"BRZAGUZA_HEAPPROFILE" help:"Filename for the heap profile. Saved in profiling/ . If not specified, program is not heap profiled."` - GORProfile string `type:"string" default:"" env:"BRZAGUZA_GORPROFILE" help:"Filename for the goroutine profile. Saved in profiling/ . If not specified, program is not goroutine profiled."` - ThreadProfile string `type:"string" default:"" env:"BRZAGUZA_THREADPROFILE" help:"Filename for the threadcreate profile. Saved in profiling/ . If not specified, program is not threadcreate profiled."` - AllocProfile string `type:"string" default:"" env:"BRZAGUZA_MEMALLOCPROFILE" help:"Filename for the alloc profile. Saved in profiling/ . If not specified, program is not alloc profiled."` - BlockProfile string `type:"string" default:"" env:"BRZAGUZA_BLOCKPROFILE" help:"Filename for the block profile. Saved in profiling/ . If not specified, program is not block profiled."` - MutexProfile string `type:"string" default:"" env:"BRZAGUZA_MUTEXPROFILE" help:"Filename for the mutex profile. Saved in profiling/ . If not specified, program is not mutex profiled."` + CPUProfile bool `type:"bool" default:"false" env:"BRZAGUZA_CPUPROFILE" help:"Use cpu profiling"` + HeapProfile bool `type:"bool" default:"false" env:"BRZAGUZA_HEAPPROFILE" help:"Use heap profiling"` + GORProfile bool `type:"bool" default:"false" env:"BRZAGUZA_GORPROFILE" help:"Use goroutine profiling"` + ThreadProfile bool `type:"bool" default:"false" env:"BRZAGUZA_THREADPROFILE" help:"Use threadcreate profiling"` + AllocProfile bool `type:"bool" default:"false" env:"BRZAGUZA_MEMALLOCPROFILE" help:"Use alloc profiling"` + BlockProfile bool `type:"bool" default:"false" env:"BRZAGUZA_BLOCKPROFILE" help:"Use block profiling"` + MutexProfile bool `type:"bool" default:"false" env:"BRZAGUZA_MUTEXPROFILE" help:"Use mutex profiling"` + ClockProfile bool `type:"bool" default:"false" env:"BRZAGUZA_CLOCKPROFILE" help:"Use clock profiling"` + TraceProfile bool `type:"bool" default:"false" env:"BRZAGUZA_TRACEPROFILE" help:"Use trace profiling"` + ServeProfiler bool `type:"bool" default:"false" env:"BRZAGUZA_SERVEPROFILER" help:"Run the profiler and serve at /debug/pprof/ http endpoint"` } ) diff --git a/src/main.go b/src/main.go index 3e044921..34c48e2e 100644 --- a/src/main.go +++ b/src/main.go @@ -4,7 +4,6 @@ import ( "fmt" "time" - "github.com/pkg/profile" "github.com/rs/zerolog/log" "github.com/tminaorg/brzaguza/src/bucket/result" "github.com/tminaorg/brzaguza/src/cache" @@ -31,78 +30,14 @@ func printResults(results []result.Result) { } } -func runProfiler() func() { - /* - goroutine — stack traces of all current goroutines - heap — a sampling of memory allocations of live objects - allocs — a sampling of all past memory allocations - threadcreate — stack traces that led to the creation of new OS threads - block — stack traces that led to blocking on synchronization primitives - mutex — stack traces of holders of contended mutexes - */ - - var cpup interface{ Stop() } - var gorp interface{ Stop() } - var blockp interface{ Stop() } - var threadp interface{ Stop() } - var heapp interface{ Stop() } - var allocp interface{ Stop() } - var mutexp interface{ Stop() } - - if cli.CPUProfile != "" { - cpup = profile.Start(profile.CPUProfile, profile.ProfilePath("./profiling/"+cli.CPUProfile)) - } - if cli.HeapProfile != "" { - heapp = profile.Start(profile.MemProfileHeap, profile.ProfilePath("./profiling/"+cli.HeapProfile)) - } - if cli.GORProfile != "" { - gorp = profile.Start(profile.GoroutineProfile, profile.ProfilePath("./profiling/"+cli.GORProfile)) - } - if cli.ThreadProfile != "" { - threadp = profile.Start(profile.ThreadcreationProfile, profile.ProfilePath("./profiling/"+cli.ThreadProfile)) - } - if cli.BlockProfile != "" { - blockp = profile.Start(profile.BlockProfile, profile.ProfilePath("./profiling/"+cli.BlockProfile)) - } - if cli.AllocProfile != "" { - allocp = profile.Start(profile.MemProfileAllocs, profile.ProfilePath("./profiling/"+cli.AllocProfile)) - } - if cli.MutexProfile != "" { - mutexp = profile.Start(profile.MutexProfile, profile.ProfilePath("./profiling/"+cli.MutexProfile)) - } - - return func() { - if cli.CPUProfile != "" { - cpup.Stop() - } - if cli.HeapProfile != "" { - heapp.Stop() - } - if cli.GORProfile != "" { - gorp.Stop() - } - if cli.ThreadProfile != "" { - threadp.Stop() - } - if cli.BlockProfile != "" { - blockp.Stop() - } - if cli.AllocProfile != "" { - allocp.Stop() - } - if cli.MutexProfile != "" { - mutexp.Stop() - } - } -} - func main() { mainTimer := time.Now() // parse cli arguments setupCli() - defer runProfiler()() //runs the profiler, and defers the closing + amProfiling := false // not used currently + defer runProfiler(&amProfiling)() //runs the profiler, and defers the closing // configure logging logger.Setup(cli.Log, cli.Verbosity) @@ -146,7 +81,9 @@ func main() { } else { log.Debug().Msg("Nothing found in cache, doing a clean search") results = search.PerformSearch(cli.Query, options, config) - cache.Save(db, cli.Query, results) + if db != nil { + cache.Save(db, cli.Query, results) + } } duration := time.Since(start) @@ -156,13 +93,12 @@ func main() { } log.Info().Msgf("Found %v results in %vms", len(results), duration.Milliseconds()) } else { - router.Setup(config, db) + router.Setup(config, db, cli.ServeProfiler) } if db != nil { db.Close() } - //closeProfiler(cli.CPUProfile, cli.MEMProfile) log.Debug().Msgf("Program finished in %vms", time.Since(mainTimer).Milliseconds()) } diff --git a/src/profiling.go b/src/profiling.go new file mode 100644 index 00000000..9a6b2305 --- /dev/null +++ b/src/profiling.go @@ -0,0 +1,123 @@ +package main + +import ( + "github.com/pkg/profile" + "github.com/rs/zerolog/log" +) + +func runProfiler(amProfiling *bool) func() { + /* + goroutine — stack traces of all current goroutines + heap — a sampling of memory allocations of live objects + allocs — a sampling of all past memory allocations + threadcreate — stack traces that led to the creation of new OS threads + block — stack traces that led to blocking on synchronization primitives + mutex — stack traces of holders of contended mutexes + */ + + var cpup interface{ Stop() } + var gorp interface{ Stop() } + var blockp interface{ Stop() } + var threadp interface{ Stop() } + var heapp interface{ Stop() } + var allocp interface{ Stop() } + var mutexp interface{ Stop() } + var tracep interface{ Stop() } + var clockp interface{ Stop() } + + profileCnt := uint(0) + if cli.CPUProfile { + profileCnt += 1 + } + if cli.HeapProfile { + profileCnt += 1 + } + if cli.GORProfile { + profileCnt += 1 + } + if cli.ThreadProfile { + profileCnt += 1 + } + if cli.BlockProfile { + profileCnt += 1 + } + if cli.AllocProfile { + profileCnt += 1 + } + if cli.MutexProfile { + profileCnt += 1 + } + if cli.ClockProfile { + profileCnt += 1 + } + if cli.TraceProfile { + profileCnt += 1 + } + + if profileCnt > 1 { + log.Fatal().Msg("only one profiler can be run at a time.") + return func() {} + } + + if cli.CPUProfile { + cpup = profile.Start(profile.CPUProfile, profile.ProfilePath("./profiling/")) + } + if cli.HeapProfile { + heapp = profile.Start(profile.MemProfileHeap, profile.ProfilePath("./profiling/")) + } + if cli.GORProfile { + gorp = profile.Start(profile.GoroutineProfile, profile.ProfilePath("./profiling/")) + } + if cli.ThreadProfile { + threadp = profile.Start(profile.ThreadcreationProfile, profile.ProfilePath("./profiling/")) + } + if cli.BlockProfile { + blockp = profile.Start(profile.BlockProfile, profile.ProfilePath("./profiling/")) + } + if cli.AllocProfile { + allocp = profile.Start(profile.MemProfileAllocs, profile.ProfilePath("./profiling/")) + } + if cli.MutexProfile { + mutexp = profile.Start(profile.MutexProfile, profile.ProfilePath("./profiling/")) + } + if cli.ClockProfile { + clockp = profile.Start(profile.ClockProfile, profile.ProfilePath("./profiling/")) + } + if cli.TraceProfile { + tracep = profile.Start(profile.TraceProfile, profile.ProfilePath("./profiling/")) + } + + if profileCnt == 1 { + *amProfiling = true + } + + return func() { + if cli.CPUProfile { + cpup.Stop() + } + if cli.HeapProfile { + heapp.Stop() + } + if cli.GORProfile { + gorp.Stop() + } + if cli.ThreadProfile { + threadp.Stop() + } + if cli.BlockProfile { + blockp.Stop() + } + if cli.AllocProfile { + allocp.Stop() + } + if cli.MutexProfile { + mutexp.Stop() + } + if cli.ClockProfile { + clockp.Stop() + } + if cli.TraceProfile { + tracep.Stop() + } + } +} diff --git a/src/router/router.go b/src/router/router.go index 388cf006..62f81b18 100644 --- a/src/router/router.go +++ b/src/router/router.go @@ -5,6 +5,7 @@ import ( "time" "github.com/gin-contrib/cors" + "github.com/gin-contrib/pprof" "github.com/gin-gonic/gin" "github.com/tminaorg/brzaguza/src/cache" "github.com/tminaorg/brzaguza/src/config" @@ -12,7 +13,7 @@ import ( var router = gin.Default() -func Setup(config *config.Config, db cache.DB) { +func Setup(config *config.Config, db cache.DB, serveProfiler bool) { // CORS router.Use(cors.New(cors.Config{ AllowOrigins: config.Server.FrontendUrls, @@ -33,6 +34,8 @@ func Setup(config *config.Config, db cache.DB) { Search(c, config, db) }) - // startup + if serveProfiler { + pprof.Register(router) + } router.Run(fmt.Sprintf(":%v", config.Server.Port)) } diff --git a/src/router/search.go b/src/router/search.go index 0658b65a..f7505c7d 100644 --- a/src/router/search.go +++ b/src/router/search.go @@ -50,13 +50,17 @@ func Search(c *gin.Context, config *config.Config, db cache.DB) { } var results []result.Result - db.Get(query, &results) + if db != nil { + db.Get(query, &results) + } if results != nil { log.Debug().Msgf("Found results for query (%v) in cache", query) } else { log.Debug().Msg("Nothing found in cache, doing a clean search") results = search.PerformSearch(query, options, config) - defer cache.Save(db, query, results) + if db != nil { + defer cache.Save(db, query, results) + } } if resultsJson, err := json.Marshal(results); err != nil { diff --git a/src/sedefaults/sedefaults.go b/src/sedefaults/sedefaults.go index 864e31d5..1432399f 100644 --- a/src/sedefaults/sedefaults.go +++ b/src/sedefaults/sedefaults.go @@ -51,7 +51,7 @@ func ColRequest(seName engines.Name, col *colly.Collector, ctx *context.Context, func ColError(seName engines.Name, col *colly.Collector, retError *error) { col.OnError(func(r *colly.Response, err error) { log.Error().Msgf("%v: SE Collector - OnError.\nURL: %v\nError: %v", seName, r.Request.URL.String(), err) - log.Error().Msgf("%v: HTML Response written to %v%v_col.log.html", seName, config.LogDumpLocation, seName) + log.Debug().Msgf("%v: HTML Response written to %v%v_col.log.html", seName, config.LogDumpLocation, seName) writeErr := os.WriteFile(config.LogDumpLocation+string(seName)+"_col.log.html", r.Body, 0644) if writeErr != nil { log.Error().Err(writeErr) From a17d0c02f15062d730678774305a64f9a658b86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:23:30 +0200 Subject: [PATCH 05/16] removed cache fix, refactored profiling --- src/cache/funcs.go | 4 +- src/cli.go | 37 ++++++------ src/main.go | 7 ++- src/profiling.go | 145 ++++++++++++++------------------------------- 4 files changed, 69 insertions(+), 124 deletions(-) diff --git a/src/cache/funcs.go b/src/cache/funcs.go index 1c96b508..b45ea35a 100644 --- a/src/cache/funcs.go +++ b/src/cache/funcs.go @@ -10,8 +10,6 @@ import ( func Save(db DB, query string, results []result.Result) { log.Debug().Msg("Caching...") cacheTimer := time.Now() - if db != nil { - db.Set(query, results) - } + db.Set(query, results) log.Debug().Msgf("Cached results in %vns", time.Since(cacheTimer).Nanoseconds()) } diff --git a/src/cli.go b/src/cli.go index 1cfb705e..364bd0a1 100644 --- a/src/cli.go +++ b/src/cli.go @@ -18,24 +18,25 @@ var ( globals // flags - Query string `type:"string" default:"${query_string}" env:"BRZAGUZA_QUERY" help:"Query string used for search"` - MaxPages int `type:"counter" default:"1" env:"BRZAGUZA_MAX_PAGES" help:"Number of pages to search"` - Cli bool `type:"bool" default:"false" env:"BRZAGUZA_CLI" help:"Use CLI mode"` - Visit bool `type:"bool" default:"false" env:"BRZAGUZA_VISIT" help:"Should results be visited"` - Silent bool `type:"bool" default:"false" short:"s" env:"BRZAGUZA_SILENT" help:"Should results be printed"` - Config string `type:"path" default:"${config_path}" env:"BRZAGUZA_CONFIG" help:"Config folder path"` - Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` - Verbosity int8 `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` - CPUProfile bool `type:"bool" default:"false" env:"BRZAGUZA_CPUPROFILE" help:"Use cpu profiling"` - HeapProfile bool `type:"bool" default:"false" env:"BRZAGUZA_HEAPPROFILE" help:"Use heap profiling"` - GORProfile bool `type:"bool" default:"false" env:"BRZAGUZA_GORPROFILE" help:"Use goroutine profiling"` - ThreadProfile bool `type:"bool" default:"false" env:"BRZAGUZA_THREADPROFILE" help:"Use threadcreate profiling"` - AllocProfile bool `type:"bool" default:"false" env:"BRZAGUZA_MEMALLOCPROFILE" help:"Use alloc profiling"` - BlockProfile bool `type:"bool" default:"false" env:"BRZAGUZA_BLOCKPROFILE" help:"Use block profiling"` - MutexProfile bool `type:"bool" default:"false" env:"BRZAGUZA_MUTEXPROFILE" help:"Use mutex profiling"` - ClockProfile bool `type:"bool" default:"false" env:"BRZAGUZA_CLOCKPROFILE" help:"Use clock profiling"` - TraceProfile bool `type:"bool" default:"false" env:"BRZAGUZA_TRACEPROFILE" help:"Use trace profiling"` - ServeProfiler bool `type:"bool" default:"false" env:"BRZAGUZA_SERVEPROFILER" help:"Run the profiler and serve at /debug/pprof/ http endpoint"` + Query string `type:"string" default:"${query_string}" env:"BRZAGUZA_QUERY" help:"Query string used for search"` + MaxPages int `type:"counter" default:"1" env:"BRZAGUZA_MAX_PAGES" help:"Number of pages to search"` + Cli bool `type:"bool" default:"false" env:"BRZAGUZA_CLI" help:"Use CLI mode"` + Visit bool `type:"bool" default:"false" env:"BRZAGUZA_VISIT" help:"Should results be visited"` + Silent bool `type:"bool" default:"false" short:"s" env:"BRZAGUZA_SILENT" help:"Should results be printed"` + Config string `type:"path" default:"${config_path}" env:"BRZAGUZA_CONFIG" help:"Config folder path"` + Log string `type:"path" default:"${log_path}" env:"BRZAGUZA_LOG" help:"Log file path"` + Verbosity int8 `type:"counter" default:"0" short:"v" env:"BRZAGUZA_VERBOSITY" help:"Log level verbosity"` + // profiler + CPUProfile bool `type:"bool" default:"false" env:"BRZAGUZA_CPUPROFILE" help:"Use cpu profiling"` + HeapProfile bool `type:"bool" default:"false" env:"BRZAGUZA_HEAPPROFILE" help:"Use heap profiling"` + GORProfile bool `type:"bool" default:"false" env:"BRZAGUZA_GORPROFILE" help:"Use goroutine profiling"` + ThreadProfile bool `type:"bool" default:"false" env:"BRZAGUZA_THREADPROFILE" help:"Use threadcreate profiling"` + AllocProfile bool `type:"bool" default:"false" env:"BRZAGUZA_MEMALLOCPROFILE" help:"Use alloc profiling"` + BlockProfile bool `type:"bool" default:"false" env:"BRZAGUZA_BLOCKPROFILE" help:"Use block profiling"` + MutexProfile bool `type:"bool" default:"false" env:"BRZAGUZA_MUTEXPROFILE" help:"Use mutex profiling"` + ClockProfile bool `type:"bool" default:"false" env:"BRZAGUZA_CLOCKPROFILE" help:"Use clock profiling"` + TraceProfile bool `type:"bool" default:"false" env:"BRZAGUZA_TRACEPROFILE" help:"Use trace profiling"` + ServeProfiler bool `type:"bool" default:"false" env:"BRZAGUZA_SERVEPROFILER" help:"Run the profiler and serve at /debug/pprof/ http endpoint"` } ) diff --git a/src/main.go b/src/main.go index 92f6e1fc..b2fe0122 100644 --- a/src/main.go +++ b/src/main.go @@ -24,9 +24,6 @@ func main() { // parse cli arguments setupCli() - amProfiling := false // not used currently - defer runProfiler(&amProfiling)() //runs the profiler, and defers the closing - // configure logging logger.Setup(cli.Log, cli.Verbosity) @@ -37,6 +34,10 @@ func main() { // signal interrupt (CTRL+C) ctx, stopCtx := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) + // profiler + amProfiling := false // not used currently + defer runProfiler(&amProfiling)() // runs the profiler, and defers the closing + // cache database var db cache.DB switch conf.Server.Cache.Type { diff --git a/src/profiling.go b/src/profiling.go index 9a6b2305..de8e4d37 100644 --- a/src/profiling.go +++ b/src/profiling.go @@ -5,6 +5,11 @@ import ( "github.com/rs/zerolog/log" ) +type profiler struct { + enabled bool + profile func(p *profile.Profile) +} + func runProfiler(amProfiling *bool) func() { /* goroutine — stack traces of all current goroutines @@ -15,109 +20,49 @@ func runProfiler(amProfiling *bool) func() { mutex — stack traces of holders of contended mutexes */ - var cpup interface{ Stop() } - var gorp interface{ Stop() } - var blockp interface{ Stop() } - var threadp interface{ Stop() } - var heapp interface{ Stop() } - var allocp interface{ Stop() } - var mutexp interface{ Stop() } - var tracep interface{ Stop() } - var clockp interface{ Stop() } - - profileCnt := uint(0) - if cli.CPUProfile { - profileCnt += 1 - } - if cli.HeapProfile { - profileCnt += 1 - } - if cli.GORProfile { - profileCnt += 1 - } - if cli.ThreadProfile { - profileCnt += 1 - } - if cli.BlockProfile { - profileCnt += 1 - } - if cli.AllocProfile { - profileCnt += 1 - } - if cli.MutexProfile { - profileCnt += 1 - } - if cli.ClockProfile { - profileCnt += 1 - } - if cli.TraceProfile { - profileCnt += 1 - } - - if profileCnt > 1 { - log.Fatal().Msg("only one profiler can be run at a time.") - return func() {} - } - - if cli.CPUProfile { - cpup = profile.Start(profile.CPUProfile, profile.ProfilePath("./profiling/")) - } - if cli.HeapProfile { - heapp = profile.Start(profile.MemProfileHeap, profile.ProfilePath("./profiling/")) - } - if cli.GORProfile { - gorp = profile.Start(profile.GoroutineProfile, profile.ProfilePath("./profiling/")) - } - if cli.ThreadProfile { - threadp = profile.Start(profile.ThreadcreationProfile, profile.ProfilePath("./profiling/")) - } - if cli.BlockProfile { - blockp = profile.Start(profile.BlockProfile, profile.ProfilePath("./profiling/")) - } - if cli.AllocProfile { - allocp = profile.Start(profile.MemProfileAllocs, profile.ProfilePath("./profiling/")) - } - if cli.MutexProfile { - mutexp = profile.Start(profile.MutexProfile, profile.ProfilePath("./profiling/")) - } - if cli.ClockProfile { - clockp = profile.Start(profile.ClockProfile, profile.ProfilePath("./profiling/")) - } - if cli.TraceProfile { - tracep = profile.Start(profile.TraceProfile, profile.ProfilePath("./profiling/")) - } + profilers := [...]profiler{{ + enabled: cli.CPUProfile, + profile: profile.CPUProfile, + }, { + enabled: cli.HeapProfile, + profile: profile.MemProfileHeap, + }, { + enabled: cli.GORProfile, + profile: profile.GoroutineProfile, + }, { + enabled: cli.ThreadProfile, + profile: profile.ThreadcreationProfile, + }, { + enabled: cli.BlockProfile, + profile: profile.BlockProfile, + }, { + enabled: cli.AllocProfile, + profile: profile.MemProfileAllocs, + }, { + enabled: cli.MutexProfile, + profile: profile.MutexProfile, + }, { + enabled: cli.ClockProfile, + profile: profile.ClockProfile, + }, { + enabled: cli.TraceProfile, + profile: profile.TraceProfile, + }} - if profileCnt == 1 { - *amProfiling = true + profilerToRun := profiler{ + enabled: false, + } + for _, p := range profilers { + if profilerToRun.enabled && p.enabled { + log.Fatal().Msg("Only one profiler can be run at a time.") + return func() {} + } else if p.enabled { + profilerToRun = p + } } + *amProfiling = true return func() { - if cli.CPUProfile { - cpup.Stop() - } - if cli.HeapProfile { - heapp.Stop() - } - if cli.GORProfile { - gorp.Stop() - } - if cli.ThreadProfile { - threadp.Stop() - } - if cli.BlockProfile { - blockp.Stop() - } - if cli.AllocProfile { - allocp.Stop() - } - if cli.MutexProfile { - mutexp.Stop() - } - if cli.ClockProfile { - clockp.Stop() - } - if cli.TraceProfile { - tracep.Stop() - } + profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/")).Stop() } } From fd8f144124ecef044db3eec35d9dc927faf000f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:27:23 +0200 Subject: [PATCH 06/16] removed cache fix --- src/cache/funcs.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cache/funcs.go b/src/cache/funcs.go index b45ea35a..1c96b508 100644 --- a/src/cache/funcs.go +++ b/src/cache/funcs.go @@ -10,6 +10,8 @@ import ( func Save(db DB, query string, results []result.Result) { log.Debug().Msg("Caching...") cacheTimer := time.Now() - db.Set(query, results) + if db != nil { + db.Set(query, results) + } log.Debug().Msgf("Cached results in %vns", time.Since(cacheTimer).Nanoseconds()) } From 6d17cf4fa3daf66f4c22c6c51de5dbf811b1a816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:32:07 +0200 Subject: [PATCH 07/16] bugfix: no enabled profilers --- src/profiling.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/profiling.go b/src/profiling.go index de8e4d37..2ffe7f5c 100644 --- a/src/profiling.go +++ b/src/profiling.go @@ -60,7 +60,12 @@ func runProfiler(amProfiling *bool) func() { profilerToRun = p } } - *amProfiling = true + + if profilerToRun.enabled { + *amProfiling = true + } else { + return func() {} + } return func() { profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/")).Stop() From 5ee590df203bbd41d3efe14712da254818fbf579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:43:08 +0200 Subject: [PATCH 08/16] bugfix: possible not 1-1 refactor --- src/profiling.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/profiling.go b/src/profiling.go index 2ffe7f5c..78b92dbb 100644 --- a/src/profiling.go +++ b/src/profiling.go @@ -61,6 +61,7 @@ func runProfiler(amProfiling *bool) func() { } } + p := profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/")) if profilerToRun.enabled { *amProfiling = true } else { @@ -68,6 +69,6 @@ func runProfiler(amProfiling *bool) func() { } return func() { - profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/")).Stop() + p.Stop() } } From 369345e8a22c2d4bdab75a18cfd7d15d6a4860f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:43:37 +0200 Subject: [PATCH 09/16] format --- src/profiling.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/profiling.go b/src/profiling.go index 78b92dbb..06ccffea 100644 --- a/src/profiling.go +++ b/src/profiling.go @@ -49,9 +49,7 @@ func runProfiler(amProfiling *bool) func() { profile: profile.TraceProfile, }} - profilerToRun := profiler{ - enabled: false, - } + profilerToRun := profiler{enabled: false} for _, p := range profilers { if profilerToRun.enabled && p.enabled { log.Fatal().Msg("Only one profiler can be run at a time.") From e728952d5d2810f2589de058be2efe79ce5c105b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:46:40 +0200 Subject: [PATCH 10/16] emptyFunc --- src/profiling.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/profiling.go b/src/profiling.go index 06ccffea..0c209b1a 100644 --- a/src/profiling.go +++ b/src/profiling.go @@ -10,6 +10,8 @@ type profiler struct { profile func(p *profile.Profile) } +var emptyFunc = func() {} + func runProfiler(amProfiling *bool) func() { /* goroutine — stack traces of all current goroutines @@ -53,7 +55,7 @@ func runProfiler(amProfiling *bool) func() { for _, p := range profilers { if profilerToRun.enabled && p.enabled { log.Fatal().Msg("Only one profiler can be run at a time.") - return func() {} + return emptyFunc } else if p.enabled { profilerToRun = p } @@ -63,7 +65,7 @@ func runProfiler(amProfiling *bool) func() { if profilerToRun.enabled { *amProfiling = true } else { - return func() {} + return emptyFunc } return func() { From 9382074ffecde56a1cfa23458fc22dcd56a1c31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:56:45 +0200 Subject: [PATCH 11/16] amProfiler refactor --- src/main.go | 4 ++-- src/profiling.go | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main.go b/src/main.go index b2fe0122..e1cc7fee 100644 --- a/src/main.go +++ b/src/main.go @@ -35,8 +35,7 @@ func main() { ctx, stopCtx := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) // profiler - amProfiling := false // not used currently - defer runProfiler(&amProfiling)() // runs the profiler, and defers the closing + amProfiling, stopProfiler := runProfiler() // not used currently // cache database var db cache.DB @@ -64,6 +63,7 @@ func main() { // program cleanup db.Close() stopCtx() + stopProfiler() log.Debug().Msgf("Program finished in %vms", time.Since(mainTimer).Milliseconds()) } diff --git a/src/profiling.go b/src/profiling.go index 0c209b1a..51011d7b 100644 --- a/src/profiling.go +++ b/src/profiling.go @@ -12,7 +12,7 @@ type profiler struct { var emptyFunc = func() {} -func runProfiler(amProfiling *bool) func() { +func runProfiler() (bool, func()) { /* goroutine — stack traces of all current goroutines heap — a sampling of memory allocations of live objects @@ -55,20 +55,17 @@ func runProfiler(amProfiling *bool) func() { for _, p := range profilers { if profilerToRun.enabled && p.enabled { log.Fatal().Msg("Only one profiler can be run at a time.") - return emptyFunc + return false, emptyFunc } else if p.enabled { profilerToRun = p } } - - p := profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/")) - if profilerToRun.enabled { - *amProfiling = true - } else { - return emptyFunc + if !profilerToRun.enabled { + return false, emptyFunc } - return func() { + p := profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/")) + return true, func() { p.Stop() } } From 2b6137c940f8817c48b4f1cc7c2a99a9c68eae75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 20:57:25 +0200 Subject: [PATCH 12/16] bugfix: unused var --- src/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.go b/src/main.go index e1cc7fee..8723915a 100644 --- a/src/main.go +++ b/src/main.go @@ -35,7 +35,7 @@ func main() { ctx, stopCtx := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) // profiler - amProfiling, stopProfiler := runProfiler() // not used currently + _, stopProfiler := runProfiler() // not used currently // cache database var db cache.DB From e785605e848b3fed460425206041d44a81174603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sun, 8 Oct 2023 21:00:04 +0200 Subject: [PATCH 13/16] moved profiler to highest position --- src/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.go b/src/main.go index 8723915a..51027bae 100644 --- a/src/main.go +++ b/src/main.go @@ -27,6 +27,9 @@ func main() { // configure logging logger.Setup(cli.Log, cli.Verbosity) + // profiler (needs cli and log) + _, stopProfiler := runProfiler() // not used currently + // load config file conf := config.New() conf.Load(cli.Config, cli.Log) @@ -34,9 +37,6 @@ func main() { // signal interrupt (CTRL+C) ctx, stopCtx := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) - // profiler - _, stopProfiler := runProfiler() // not used currently - // cache database var db cache.DB switch conf.Server.Cache.Type { From 5c63657cfa934be8fa2a6d525823ba2d417eb58e Mon Sep 17 00:00:00 2001 From: hiddenMedic <124312252+hiddenMedic@users.noreply.github.com> Date: Sun, 8 Oct 2023 22:42:04 +0200 Subject: [PATCH 14/16] good --- src/main.go | 14 ++++++-------- src/profiling.go | 13 ++++++------- src/router/router.go | 4 ++-- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/main.go b/src/main.go index 51027bae..f847333c 100644 --- a/src/main.go +++ b/src/main.go @@ -24,19 +24,19 @@ func main() { // parse cli arguments setupCli() + _, stopProfiler := runProfiler() + defer stopProfiler() + + // signal interrupt (CTRL+C) + ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) + // configure logging logger.Setup(cli.Log, cli.Verbosity) - // profiler (needs cli and log) - _, stopProfiler := runProfiler() // not used currently - // load config file conf := config.New() conf.Load(cli.Config, cli.Log) - // signal interrupt (CTRL+C) - ctx, stopCtx := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGINT, syscall.SIGTERM) - // cache database var db cache.DB switch conf.Server.Cache.Type { @@ -62,8 +62,6 @@ func main() { // program cleanup db.Close() - stopCtx() - stopProfiler() log.Debug().Msgf("Program finished in %vms", time.Since(mainTimer).Milliseconds()) } diff --git a/src/profiling.go b/src/profiling.go index 51011d7b..7826e5f0 100644 --- a/src/profiling.go +++ b/src/profiling.go @@ -1,8 +1,9 @@ package main import ( + "log" + "github.com/pkg/profile" - "github.com/rs/zerolog/log" ) type profiler struct { @@ -10,8 +11,6 @@ type profiler struct { profile func(p *profile.Profile) } -var emptyFunc = func() {} - func runProfiler() (bool, func()) { /* goroutine — stack traces of all current goroutines @@ -54,17 +53,17 @@ func runProfiler() (bool, func()) { profilerToRun := profiler{enabled: false} for _, p := range profilers { if profilerToRun.enabled && p.enabled { - log.Fatal().Msg("Only one profiler can be run at a time.") - return false, emptyFunc + log.Fatal("Only one profiler can be run at a time.") + return false, func() {} } else if p.enabled { profilerToRun = p } } if !profilerToRun.enabled { - return false, emptyFunc + return false, func() {} } - p := profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/")) + p := profile.Start(profilerToRun.profile, profile.ProfilePath("./profiling/"), profile.NoShutdownHook) return true, func() { p.Stop() } diff --git a/src/router/router.go b/src/router/router.go index a8a09c8b..958eff42 100644 --- a/src/router/router.go +++ b/src/router/router.go @@ -2,7 +2,7 @@ package router import ( "context" - "fmt" + "strconv" "time" "github.com/gin-contrib/cors" @@ -24,7 +24,7 @@ func New(config *config.Config, verbosity int8) (*RouterWrapper, error) { if verbosity == 0 { gin.SetMode(gin.ReleaseMode) } - router, err := graceful.Default(graceful.WithAddr(fmt.Sprintf(":%v", config.Server.Port))) + router, err := graceful.Default(graceful.WithAddr(":" + strconv.Itoa(config.Server.Port))) return &RouterWrapper{router: router, config: config}, err } From 3222a26d96f0f455473267fdf58c0df13f398104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Mon, 9 Oct 2023 18:05:51 +0200 Subject: [PATCH 15/16] reverted fix for db nil, since it was fixed in nocache pr --- src/router/search.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/router/search.go b/src/router/search.go index 0c6cc8ac..3e9b96a3 100644 --- a/src/router/search.go +++ b/src/router/search.go @@ -51,9 +51,7 @@ func Search(c *gin.Context, config *config.Config, db cache.DB) { } var results []result.Result - if db != nil { - db.Get(query, &results) - } + db.Get(query, &results) if results != nil { log.Debug().Msgf("Found results for query (%v) in cache", query) } else { From bfc3bea3b54d498a4bd12a09a3e3c7b7bc72a39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Mon, 9 Oct 2023 18:08:08 +0200 Subject: [PATCH 16/16] go.mod --- go.mod | 8 ++++---- go.sum | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 96113aea..08dc8849 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/alecthomas/kong v0.8.0 - github.com/cockroachdb/pebble v0.0.0-20231004191855-d4bf20c546d3 + github.com/cockroachdb/pebble v0.0.0-20231009150004-a678d0968383 github.com/fxamacker/cbor/v2 v2.5.0 github.com/gin-contrib/cors v1.4.0 github.com/gin-contrib/graceful v0.0.0-20230904152018-e56ed94cd808 @@ -29,7 +29,7 @@ require ( github.com/DataDog/zstd v1.5.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.9.0 // indirect - github.com/bytedance/sonic v1.10.1 // indirect + github.com/bytedance/sonic v1.10.2 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.0 // indirect @@ -49,7 +49,7 @@ require ( github.com/go-playground/validator/v10 v10.15.5 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect - github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect + github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.0 // indirect github.com/klauspost/cpuid/v2 v2.2.5 // indirect @@ -76,7 +76,7 @@ require ( github.com/x448/float16 v0.8.4 // indirect golang.org/x/arch v0.5.0 // indirect golang.org/x/crypto v0.14.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/mod v0.13.0 // indirect gopkg.in/sourcemap.v1 v1.0.5 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 93b9c081..290be971 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= -github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc= -github.com/bytedance/sonic v1.10.1/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= +github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE= +github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= @@ -52,8 +52,8 @@ github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZ github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v0.0.0-20231004191855-d4bf20c546d3 h1:mrKmxwfU6K40vjmwBiU4UqKhN8tAZJfQOciaK+Ycbgc= -github.com/cockroachdb/pebble v0.0.0-20231004191855-d4bf20c546d3/go.mod h1:6hk1eMY/u5t+Cf18q5lFMUA1Rc+Sm5I6Ra1QuPyxXCo= +github.com/cockroachdb/pebble v0.0.0-20231009150004-a678d0968383 h1:98LmGECk4ksnbvBVr0DgssnH0Mfwkd6+L6D/JHVd144= +github.com/cockroachdb/pebble v0.0.0-20231009150004-a678d0968383/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= @@ -79,10 +79,10 @@ github.com/getsentry/sentry-go v0.25.0 h1:q6Eo+hS+yoJlTO3uu/azhQadsD8V+jQn2D8VvX github.com/getsentry/sentry-go v0.25.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= -github.com/gin-contrib/pprof v1.4.0 h1:XxiBSf5jWZ5i16lNOPbMTVdgHBdhfGRD5PZ1LWazzvg= -github.com/gin-contrib/pprof v1.4.0/go.mod h1:RrehPJasUVBPK6yTUwOl8/NP6i0vbUgmxtis+Z5KE90= github.com/gin-contrib/graceful v0.0.0-20230904152018-e56ed94cd808 h1:FWLRw/61ras/SCc7OdLlg/MyS+MDx6syQhIBfkfznUc= github.com/gin-contrib/graceful v0.0.0-20230904152018-e56ed94cd808/go.mod h1:eRZFrgWTLneuj4V0sNAN5+eNRcnZNSTsAFC+69voi78= +github.com/gin-contrib/pprof v1.4.0 h1:XxiBSf5jWZ5i16lNOPbMTVdgHBdhfGRD5PZ1LWazzvg= +github.com/gin-contrib/pprof v1.4.0/go.mod h1:RrehPJasUVBPK6yTUwOl8/NP6i0vbUgmxtis+Z5KE90= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= @@ -122,8 +122,9 @@ github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEW github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20211214055906-6f57359322fd h1:1FjCyPC+syAzJ5/2S8fqdZK1R22vvA0J7JZKcuOIQ7Y= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= +github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 h1:pUa4ghanp6q4IJHwE9RwLgmVFfReJN+KbQ8ExNEUUoQ= +github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= github.com/jawher/mow.cli v1.1.0/go.mod h1:aNaQlc7ozF3vw6IJ2dHjp2ZFiA4ozMIYY6PyuRJwlUg= @@ -262,8 +263,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= +golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=