summaryrefslogtreecommitdiffhomepage
path: root/test/benchmarks/base
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2020-12-29 18:26:46 -0800
committergVisor bot <gvisor-bot@google.com>2020-12-29 18:29:12 -0800
commitffa9a715aaf4ebc4c8d8bef948649af358e4f4e4 (patch)
tree47e16fdc85a56d00f8c8e5380cfc28a44957f877 /test/benchmarks/base
parent3c58405a544dcd599bd84406b5d52848941675f7 (diff)
Simplify profiling and benchmarks.
- Tweak the benchmarks to work with b.N where appropriate. In many cases, b.N was simply being ignored. This creates an implicit dependency in the user passing a reasonable benchtime (less than or equal to the actual runtime of the test, or using the X syntax) otherwise the test runs forever. - In cases where the above is impossible, explicitly set benchtime from the test wrapper, to prevent the above behavior (tensorflow). - Drop the *Reverse variants, which are simply hey benchmarks. We should just add a hey benchmark. The platforms benchmarks already include a native platform, and thus these benchmarks are incredibly confusing. (In other words, BenchmarkNginxReverse has nothing to do with an nginx benchmark for runsc.) - Remove the redunant Harness object, which contains no state, in order to slightly simplify the code. - Make Block and Heap profiling actually work, but setting appropriate runtime parameters (and plumbing them through the config). - Split the profiling into two phases: start and stop, since some will need to be started early, and others will need to happen at the end. PiperOrigin-RevId: 349495377
Diffstat (limited to 'test/benchmarks/base')
-rw-r--r--test/benchmarks/base/size_test.go10
-rw-r--r--test/benchmarks/base/startup_test.go12
-rw-r--r--test/benchmarks/base/sysbench_test.go23
3 files changed, 17 insertions, 28 deletions
diff --git a/test/benchmarks/base/size_test.go b/test/benchmarks/base/size_test.go
index acc49cc7c..452926e5f 100644
--- a/test/benchmarks/base/size_test.go
+++ b/test/benchmarks/base/size_test.go
@@ -26,12 +26,10 @@ import (
"gvisor.dev/gvisor/test/benchmarks/tools"
)
-var testHarness harness.Harness
-
// BenchmarkSizeEmpty creates N empty containers and reads memory usage from
// /proc/meminfo.
func BenchmarkSizeEmpty(b *testing.B) {
- machine, err := testHarness.GetMachine()
+ machine, err := harness.GetMachine()
if err != nil {
b.Fatalf("failed to get machine: %v", err)
}
@@ -81,7 +79,7 @@ func BenchmarkSizeEmpty(b *testing.B) {
// BenchmarkSizeNginx starts N containers running Nginx, checks that they're
// serving, and checks memory used based on /proc/meminfo.
func BenchmarkSizeNginx(b *testing.B) {
- machine, err := testHarness.GetMachine()
+ machine, err := harness.GetMachine()
if err != nil {
b.Fatalf("failed to get machine with: %v", err)
}
@@ -126,7 +124,7 @@ func BenchmarkSizeNginx(b *testing.B) {
// BenchmarkSizeNode starts N containers running a Node app, checks that
// they're serving, and checks memory used based on /proc/meminfo.
func BenchmarkSizeNode(b *testing.B) {
- machine, err := testHarness.GetMachine()
+ machine, err := harness.GetMachine()
if err != nil {
b.Fatalf("failed to get machine with: %v", err)
}
@@ -178,6 +176,6 @@ func BenchmarkSizeNode(b *testing.B) {
// TestMain is the main method for package network.
func TestMain(m *testing.M) {
- testHarness.Init()
+ harness.Init()
os.Exit(m.Run())
}
diff --git a/test/benchmarks/base/startup_test.go b/test/benchmarks/base/startup_test.go
index 8ef9f99c4..05a43ad17 100644
--- a/test/benchmarks/base/startup_test.go
+++ b/test/benchmarks/base/startup_test.go
@@ -25,11 +25,9 @@ import (
"gvisor.dev/gvisor/test/benchmarks/harness"
)
-var testHarness harness.Harness
-
// BenchmarkStartEmpty times startup time for an empty container.
func BenchmarkStartupEmpty(b *testing.B) {
- machine, err := testHarness.GetMachine()
+ machine, err := harness.GetMachine()
if err != nil {
b.Fatalf("failed to get machine: %v", err)
}
@@ -53,7 +51,7 @@ func BenchmarkStartupEmpty(b *testing.B) {
// Time is measured from start until the first request is served.
func BenchmarkStartupNginx(b *testing.B) {
// The machine to hold Nginx and the Node Server.
- machine, err := testHarness.GetMachine()
+ machine, err := harness.GetMachine()
if err != nil {
b.Fatalf("failed to get machine with: %v", err)
}
@@ -76,7 +74,7 @@ func BenchmarkStartupNginx(b *testing.B) {
// Time is measured from start until the first request is served.
// Note that the Node app connects to a Redis instance before serving.
func BenchmarkStartupNode(b *testing.B) {
- machine, err := testHarness.GetMachine()
+ machine, err := harness.GetMachine()
if err != nil {
b.Fatalf("failed to get machine with: %v", err)
}
@@ -126,8 +124,8 @@ func runServerWorkload(ctx context.Context, b *testing.B, args base.ServerArgs)
return fmt.Errorf("failed to get ip from server: %v", err)
}
- harness.DebugLog(b, "Waiting for container to start.")
// Wait until the Client sees the server as up.
+ harness.DebugLog(b, "Waiting for container to start.")
if err := harness.WaitUntilServing(ctx, args.Machine, servingIP, args.Port); err != nil {
return fmt.Errorf("failed to wait for serving: %v", err)
}
@@ -141,6 +139,6 @@ func runServerWorkload(ctx context.Context, b *testing.B, args base.ServerArgs)
// TestMain is the main method for package network.
func TestMain(m *testing.M) {
- testHarness.Init()
+ harness.Init()
os.Exit(m.Run())
}
diff --git a/test/benchmarks/base/sysbench_test.go b/test/benchmarks/base/sysbench_test.go
index bbb797e14..80569687c 100644
--- a/test/benchmarks/base/sysbench_test.go
+++ b/test/benchmarks/base/sysbench_test.go
@@ -23,8 +23,6 @@ import (
"gvisor.dev/gvisor/test/benchmarks/tools"
)
-var testHarness harness.Harness
-
type testCase struct {
name string
test tools.Sysbench
@@ -32,42 +30,34 @@ type testCase struct {
// BenchmarSysbench runs sysbench on the runtime.
func BenchmarkSysbench(b *testing.B) {
-
testCases := []testCase{
testCase{
name: "CPU",
test: &tools.SysbenchCPU{
- Base: tools.SysbenchBase{
+ SysbenchBase: tools.SysbenchBase{
Threads: 1,
- Time: 5,
},
- MaxPrime: 50000,
},
},
testCase{
name: "Memory",
test: &tools.SysbenchMemory{
- Base: tools.SysbenchBase{
+ SysbenchBase: tools.SysbenchBase{
Threads: 1,
},
- BlockSize: "1M",
- TotalSize: "500G",
},
},
testCase{
name: "Mutex",
test: &tools.SysbenchMutex{
- Base: tools.SysbenchBase{
+ SysbenchBase: tools.SysbenchBase{
Threads: 8,
},
- Loops: 1,
- Locks: 10000000,
- Num: 4,
},
},
}
- machine, err := testHarness.GetMachine()
+ machine, err := harness.GetMachine()
if err != nil {
b.Fatalf("failed to get machine: %v", err)
}
@@ -87,12 +77,15 @@ func BenchmarkSysbench(b *testing.B) {
sysbench := machine.GetContainer(ctx, b)
defer sysbench.CleanUp(ctx)
+ cmd := tc.test.MakeCmd(b)
+ b.ResetTimer()
out, err := sysbench.Run(ctx, dockerutil.RunOpts{
Image: "benchmarks/sysbench",
- }, tc.test.MakeCmd()...)
+ }, cmd...)
if err != nil {
b.Fatalf("failed to run sysbench: %v: logs:%s", err, out)
}
+ b.StopTimer()
tc.test.Report(b, out)
})
}