From 868ed0e807239635bd3aa6b964bb4fc0913916be Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Fri, 13 Aug 2021 15:26:44 -0700 Subject: [benchmarks] Update BenchmarkStartEmpty benchmark. Update the start benchmark on empty to only "Start" a container, not wait for its completion. TL:DR only measure the actual start call for the empty container. Previously, we were measuring the completion of /bin/true in container alpine AND the cleanup. This was fine until profiling started failing all the time on ptrace. This is a cost that runc is not paying. These changes will reduce the over all timing of the benchmark, but it will give more sane results. Instead, use "Spawn" which is similar to `docker run --detach alpine /bin/sleep 100`. Call sleep so containers stick around long enough for the profiler to read profile data from them. PiperOrigin-RevId: 390705431 --- test/benchmarks/base/startup_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test/benchmarks/base') diff --git a/test/benchmarks/base/startup_test.go b/test/benchmarks/base/startup_test.go index 05a43ad17..197241622 100644 --- a/test/benchmarks/base/startup_test.go +++ b/test/benchmarks/base/startup_test.go @@ -34,15 +34,19 @@ func BenchmarkStartupEmpty(b *testing.B) { defer machine.CleanUp() ctx := context.Background() + b.StopTimer() + b.ResetTimer() for i := 0; i < b.N; i++ { harness.DebugLog(b, "Running container: %d", i) container := machine.GetContainer(ctx, b) - defer container.CleanUp(ctx) - if _, err := container.Run(ctx, dockerutil.RunOpts{ + b.StartTimer() + if err := container.Spawn(ctx, dockerutil.RunOpts{ Image: "benchmarks/alpine", - }, "true"); err != nil { - b.Fatalf("failed to run container: %v", err) + }, "sleep", "100"); err != nil { + b.Fatalf("failed to start container: %v", err) } + b.StopTimer() + container.CleanUp(ctx) harness.DebugLog(b, "Ran container: %d", i) } } -- cgit v1.2.3