Skip to content
Open
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
51 changes: 47 additions & 4 deletions cmd/talemu-infra-provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"context"
_ "embed"
"errors"
"net"
"net/http"
"net/http/pprof"
"os"
"os/signal"
"syscall"
Expand Down Expand Up @@ -133,10 +136,38 @@ var rootCmd = &cobra.Command{
eg, ctx := panichandler.ErrGroupWithContext(cmd.Context())

eg.Go(func() error {
return ip.Run(ctx, logger, infra.WithOmniEndpoint(cfg.omniAPIEndpoint), infra.WithClientOptions(
client.WithServiceAccount(cfg.serviceAccountKey),
client.WithInsecureSkipTLSVerify(true),
))
return ip.Run(ctx, logger, infra.WithOmniEndpoint(cfg.omniAPIEndpoint),
infra.WithClientOptions(
client.WithServiceAccount(cfg.serviceAccountKey),
client.WithInsecureSkipTLSVerify(true),
),
)
})

pprofAddr := "0.0.0.0:2135"

pprofServer := http.Server{
Addr: pprofAddr,
Handler: cratePprofMux(),
}

eg.Go(func() error {
ln, err := net.Listen("tcp", pprofAddr)
if err != nil {
return err
}

defer ln.Close() //nolint:errcheck

logger.Info("starting pprof server", zap.String("address", pprofAddr))

return pprofServer.Serve(ln)
})

eg.Go(func() error {
<-ctx.Done()

return pprofServer.Close()
})

eg.Go(func() error {
Expand All @@ -147,6 +178,18 @@ var rootCmd = &cobra.Command{
},
}

func cratePprofMux() http.Handler {
mux := &http.ServeMux{}

mux.HandleFunc("/debug/pprof/", pprof.Index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see

Copy link
Member Author

@Unix4ever Unix4ever Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that enables it only for debug builds.
Or running it without debug doesn't make much sense?

I wanted to see what's taking 64GB of ram when Talemu runs with 1000 machines. Not sure if running load tests in debug mode is a good idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, but I think with go-debug it's a single liner, but yes, requires debug mode

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)

return mux
}

func createServiceAccount(ctx context.Context, logger *zap.Logger) error {
config := clientconfig.New(cfg.omniAPIEndpoint)

Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ require (
github.com/ProtonMail/gopenpgp/v2 v2.9.0 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
Expand Down Expand Up @@ -163,12 +162,10 @@ require (
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jonboulle/clockwork v0.5.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v1.1.0 // indirect
github.com/jsimonetti/rtnetlink/v2 v2.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mailru/easyjson v0.9.1 // indirect
github.com/mdlayher/ethernet v0.0.0-20220221185849-529eae5b6118 // indirect
github.com/mdlayher/packet v1.1.2 // indirect
github.com/mdlayher/socket v0.5.1 // indirect
Expand Down
Loading