Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report GCP profiles from zoekt-git-index #816

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/zoekt-git-index/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"runtime/pprof"
"strings"

"github.com/sourcegraph/zoekt/internal/profiler"
"go.uber.org/automaxprocs/maxprocs"

"github.com/sourcegraph/zoekt/cmd"
Expand Down Expand Up @@ -70,6 +71,7 @@ func run() int {
}
*repoCacheDir = dir
}

opts := cmd.OptionsFromFlags()
opts.IsDelta = *isDelta
opts.DocumentRanksPath = *offlineRanking
Expand Down Expand Up @@ -107,6 +109,7 @@ func run() int {
opts.LanguageMap[m[0]] = ctags.StringToParser(m[1])
}

profiler.Init("zoekt-git-index")
exitStatus := 0
for dir, name := range gitRepos {
opts.RepositoryDescription.Name = name
Expand Down
2 changes: 1 addition & 1 deletion cmd/zoekt-sourcegraph-indexserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ func startServer(conf rootConfig) error {
return err
}

profiler.Init("zoekt-sourcegraph-indexserver", zoekt.Version, conf.blockProfileRate)
profiler.Init("zoekt-sourcegraph-indexserver")
setCompoundShardCounter(s.IndexDir)

if conf.listen != "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zoekt-webserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func main() {
liblog := sglog.Init(resource)
defer liblog.Sync()
tracer.Init(resource)
profiler.Init("zoekt-webserver", zoekt.Version, -1)
profiler.Init("zoekt-webserver")

if *logDir != "" {
if fi, err := os.Lstat(*logDir); err != nil || !fi.IsDir() {
Expand Down
5 changes: 3 additions & 2 deletions internal/profiler/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"os"

"cloud.google.com/go/profiler"
"github.com/sourcegraph/zoekt"
)

// Init starts the supported profilers IFF the environment variable is set.
func Init(svcName, version string, blockProfileRate int) {
func Init(svcName string) {
if os.Getenv("GOOGLE_CLOUD_PROFILER_ENABLED") != "" {
err := profiler.Start(profiler.Config{
Service: svcName,
ServiceVersion: version,
ServiceVersion: zoekt.Version,
MutexProfiling: true,
AllocForceGC: true,
})
Expand Down
Loading