Stop profiling metrics in the same step as other profiles in runsc.

This is part of a series of changes to add metric charts in performance
benchmarks.

This change stops profiling metrics whenever we also stop CPU/heap/mutex
profiles, rather than at `runsc boot` exit. This helps flushing the metrics
data at the right time.

PiperOrigin-RevId: 633287428
This commit is contained in:
Etienne Perot
2024-05-13 12:04:17 -07:00
committed by gVisor bot
parent a67dd10623
commit 222de612f4
2 changed files with 7 additions and 1 deletions
+1
View File
@@ -50,6 +50,7 @@ go_library(
"//pkg/hostos",
"//pkg/log",
"//pkg/memutil",
"//pkg/metric",
"//pkg/rand",
"//pkg/refs",
"//pkg/sentry/arch",
+6 -1
View File
@@ -36,6 +36,7 @@ import (
"gvisor.dev/gvisor/pkg/fd"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/memutil"
"gvisor.dev/gvisor/pkg/metric"
"gvisor.dev/gvisor/pkg/rand"
"gvisor.dev/gvisor/pkg/refs"
"gvisor.dev/gvisor/pkg/sentry/control"
@@ -372,7 +373,11 @@ func getRootCredentials(spec *specs.Spec, conf *config.Config, userNs *auth.User
// New initializes a new kernel loader configured by spec.
// New also handles setting up a kernel for restoring a container.
func New(args Args) (*Loader, error) {
stopProfiling := profile.Start(args.ProfileOpts)
stopProfilingRuntime := profile.Start(args.ProfileOpts)
stopProfiling := func() {
stopProfilingRuntime()
metric.StopProfilingMetrics()
}
// Initialize seccheck points.
seccheck.Initialize()