From b4af9d4572707718514e66b7e537bc51216b60f6 Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Wed, 9 Dec 2020 13:49:41 -0800 Subject: Add network benchmarks jobs Add httpd, nginx, node, and ruby benchmarks to continuous jobs. PiperOrigin-RevId: 346629115 --- test/benchmarks/network/httpd_test.go | 63 ++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'test/benchmarks/network/httpd_test.go') diff --git a/test/benchmarks/network/httpd_test.go b/test/benchmarks/network/httpd_test.go index 8d7d5f750..aa300dabd 100644 --- a/test/benchmarks/network/httpd_test.go +++ b/test/benchmarks/network/httpd_test.go @@ -14,13 +14,17 @@ package network import ( + "os" "strconv" "testing" "gvisor.dev/gvisor/pkg/test/dockerutil" + "gvisor.dev/gvisor/test/benchmarks/harness" "gvisor.dev/gvisor/test/benchmarks/tools" ) +var h harness.Harness + // see Dockerfile '//images/benchmarks/httpd'. var httpdDocs = map[string]string{ "notfound": "notfound", @@ -43,6 +47,22 @@ func BenchmarkReverseHttpd(b *testing.B) { benchmarkHttpdDocSize(b, true /* reverse */) } +// BenchmarkContinuousHttpd runs specific benchmarks for continous jobs. +// The runtime under test is the server serving a runc client. +func BenchmarkContinuousHttpd(b *testing.B) { + sizes := []string{"10Kb", "100Kb", "1Mb"} + threads := []int{1, 25, 100, 1000} + benchmarkHttpdContinuous(b, threads, sizes, false /*reverse*/) +} + +// BenchmarkContinuousHttpdReverse runs specific benchmarks for continous jobs. +// The runtime under test is the client downloading from a runc server. +func BenchmarkContinuousHttpdReverse(b *testing.B) { + sizes := []string{"10Kb", "100Kb", "1Mb"} + threads := []int{1, 25, 100, 1000} + benchmarkHttpdContinuous(b, threads, sizes, true /*reverse*/) +} + // benchmarkHttpdDocSize iterates through all doc sizes, running subbenchmarks // for each size. func benchmarkHttpdDocSize(b *testing.B, reverse bool) { @@ -74,6 +94,42 @@ func benchmarkHttpdDocSize(b *testing.B, reverse bool) { } } +// benchmarkHttpdContinuous iterates through given sizes and concurrencies. +func benchmarkHttpdContinuous(b *testing.B, concurrency []int, sizes []string, reverse bool) { + for _, size := range sizes { + filename := httpdDocs[size] + for _, c := range concurrency { + fsize := tools.Parameter{ + Name: "filesize", + Value: size, + } + + threads := tools.Parameter{ + Name: "concurrency", + Value: strconv.Itoa(c), + } + + name, err := tools.ParametersToName(fsize, threads) + if err != nil { + b.Fatalf("Failed to parse parameters: %v", err) + } + + requests := b.N + if requests < c { + requests = c + } + b.Run(name, func(b *testing.B) { + hey := &tools.Hey{ + Requests: requests, + Concurrency: c, + Doc: filename, + } + runHttpd(b, hey, reverse) + }) + } + } +} + // runHttpd configures the static serving methods to run httpd. func runHttpd(b *testing.B, hey *tools.Hey, reverse bool) { // httpd runs on port 80. @@ -91,5 +147,10 @@ func runHttpd(b *testing.B, hey *tools.Hey, reverse bool) { }, } httpdCmd := []string{"sh", "-c", "mkdir -p /tmp/html; cp -r /local/* /tmp/html/.; apache2 -X"} - runStaticServer(b, httpdRunOpts, httpdCmd, port, hey, reverse) + runStaticServer(b, h, httpdRunOpts, httpdCmd, port, hey, reverse) +} + +func TestMain(m *testing.M) { + h.Init() + os.Exit(m.Run()) } -- cgit v1.2.3