mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Simplify iperf benchmarks.
This change makes iperf benchmarks quicker and simpler. Before this running the full benchmark took an unreasonable amount of time. This benchmark shouldn't need to vary the length parameter since user provides input length through `test.benchtime`. The parallel tests were also taking much longer than the single connection ones, so now we divide the user supplied N by the parallelism parameter to ensure the parallel benchmarks take roughly the same amount of time as single connection benchmarks for the same N. PiperOrigin-RevId: 625458044
This commit is contained in:
committed by
gVisor bot
parent
2a5cfd87cd
commit
cd6f5a3c50
@@ -634,7 +634,7 @@ steps:
|
||||
command: make -i benchmark-platforms BENCHMARKS_FILTER="Continuous" BENCHMARKS_SUITE=httpd BENCHMARKS_TARGETS=test/benchmarks/network:httpd_test
|
||||
- <<: *benchmarks
|
||||
label: ":piedpiper: iperf benchmarks"
|
||||
command: make -i benchmark-platforms BENCHMARKS_SUITE=iperf BENCHMARKS_TARGETS=test/benchmarks/network:iperf_test BENCHMARKS_FILTER=BenchmarkIperf$
|
||||
command: make -i benchmark-platforms BENCHMARKS_SUITE=iperf BENCHMARKS_TARGETS=test/benchmarks/network:iperf_test BENCHMARKS_FILTER=BenchmarkIperfOneConnection
|
||||
- <<: *benchmarks
|
||||
label: ":nginx: nginx benchmarks"
|
||||
command: make -i benchmark-platforms BENCHMARKS_FILTER="Continuous" BENCHMARKS_SUITE=nginx BENCHMARKS_TARGETS=test/benchmarks/network:nginx_test
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
"gvisor.dev/gvisor/test/benchmarks/tools"
|
||||
)
|
||||
|
||||
func BenchmarkIperf(b *testing.B) {
|
||||
func BenchmarkIperfOneConnection(b *testing.B) {
|
||||
clientMachine, err := harness.GetMachine()
|
||||
if err != nil {
|
||||
b.Fatalf("failed to get machine: %v", err)
|
||||
@@ -106,7 +106,7 @@ func BenchmarkIperf(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIperfParameterized(b *testing.B) {
|
||||
func BenchmarkIperfManyConnections(b *testing.B) {
|
||||
clientMachine, err := harness.GetMachine()
|
||||
if err != nil {
|
||||
b.Fatalf("failed to get machine: %v", err)
|
||||
@@ -131,85 +131,37 @@ func BenchmarkIperfParameterized(b *testing.B) {
|
||||
// server.
|
||||
{
|
||||
name: "Upload",
|
||||
length: 4,
|
||||
parallel: 1,
|
||||
parallel: 4,
|
||||
clientFunc: clientMachine.GetContainer,
|
||||
serverFunc: serverMachine.GetNativeContainer,
|
||||
},
|
||||
{
|
||||
name: "Upload",
|
||||
length: 64,
|
||||
parallel: 1,
|
||||
clientFunc: clientMachine.GetContainer,
|
||||
serverFunc: serverMachine.GetNativeContainer,
|
||||
name: "Download",
|
||||
parallel: 4,
|
||||
clientFunc: clientMachine.GetNativeContainer,
|
||||
serverFunc: serverMachine.GetContainer,
|
||||
},
|
||||
{
|
||||
name: "Upload",
|
||||
length: 1024,
|
||||
parallel: 1,
|
||||
clientFunc: clientMachine.GetContainer,
|
||||
serverFunc: serverMachine.GetNativeContainer,
|
||||
},
|
||||
{
|
||||
name: "Upload",
|
||||
length: 4,
|
||||
parallel: 16,
|
||||
clientFunc: clientMachine.GetContainer,
|
||||
serverFunc: serverMachine.GetNativeContainer,
|
||||
},
|
||||
{
|
||||
name: "Upload",
|
||||
length: 64,
|
||||
parallel: 16,
|
||||
clientFunc: clientMachine.GetContainer,
|
||||
serverFunc: serverMachine.GetNativeContainer,
|
||||
},
|
||||
{
|
||||
name: "Upload",
|
||||
length: 1024,
|
||||
parallel: 16,
|
||||
clientFunc: clientMachine.GetContainer,
|
||||
serverFunc: serverMachine.GetNativeContainer,
|
||||
},
|
||||
{
|
||||
name: "Download",
|
||||
length: 4,
|
||||
parallel: 1,
|
||||
clientFunc: clientMachine.GetNativeContainer,
|
||||
serverFunc: serverMachine.GetContainer,
|
||||
},
|
||||
{
|
||||
name: "Download",
|
||||
length: 64,
|
||||
parallel: 1,
|
||||
clientFunc: clientMachine.GetNativeContainer,
|
||||
serverFunc: serverMachine.GetContainer,
|
||||
},
|
||||
{
|
||||
name: "Download",
|
||||
length: 1024,
|
||||
parallel: 1,
|
||||
clientFunc: clientMachine.GetNativeContainer,
|
||||
serverFunc: serverMachine.GetContainer,
|
||||
},
|
||||
{
|
||||
name: "Download",
|
||||
length: 4,
|
||||
parallel: 16,
|
||||
clientFunc: clientMachine.GetNativeContainer,
|
||||
serverFunc: serverMachine.GetContainer,
|
||||
},
|
||||
{
|
||||
name: "Download",
|
||||
length: 64,
|
||||
parallel: 16,
|
||||
clientFunc: clientMachine.GetNativeContainer,
|
||||
serverFunc: serverMachine.GetContainer,
|
||||
name: "Upload",
|
||||
parallel: 64,
|
||||
clientFunc: clientMachine.GetContainer,
|
||||
serverFunc: serverMachine.GetNativeContainer,
|
||||
},
|
||||
{
|
||||
name: "Download",
|
||||
length: 1024,
|
||||
parallel: 16,
|
||||
parallel: 64,
|
||||
clientFunc: clientMachine.GetNativeContainer,
|
||||
serverFunc: serverMachine.GetContainer,
|
||||
},
|
||||
@@ -217,9 +169,6 @@ func BenchmarkIperfParameterized(b *testing.B) {
|
||||
name, err := tools.ParametersToName(tools.Parameter{
|
||||
Name: "operation",
|
||||
Value: bm.name,
|
||||
}, tools.Parameter{
|
||||
Name: "length",
|
||||
Value: fmt.Sprintf("%dK", bm.length),
|
||||
}, tools.Parameter{
|
||||
Name: "parallel",
|
||||
Value: fmt.Sprintf("%d", bm.parallel),
|
||||
@@ -249,8 +198,7 @@ func BenchmarkIperfParameterized(b *testing.B) {
|
||||
}
|
||||
|
||||
iperf := tools.Iperf{
|
||||
Num: b.N, // KB for the client to send.
|
||||
Length: bm.length, // KB for length.
|
||||
Num: b.N, // KB for the client to send.
|
||||
Parallel: bm.parallel,
|
||||
}
|
||||
|
||||
|
||||
@@ -24,21 +24,20 @@ import (
|
||||
// Iperf is for the client side of `iperf`.
|
||||
type Iperf struct {
|
||||
Num int // Number of bytes to send in KB.
|
||||
Length int // Length in KB.
|
||||
Parallel int // Number of parallel threads.
|
||||
}
|
||||
|
||||
// MakeCmd returns a iperf client command.
|
||||
func (i *Iperf) MakeCmd(host string, port int) []string {
|
||||
cmd := []string{"iperf"}
|
||||
cmd = append(cmd, "--format", "K") // Output in KBytes.
|
||||
cmd = append(cmd, "--realtime") // Measured in realtime.
|
||||
cmd = append(cmd, "--num", fmt.Sprintf("%dK", i.Num)) // Number of bytes to send in KB.
|
||||
len := 128
|
||||
if i.Length > 0 {
|
||||
len = i.Length
|
||||
cmd = append(cmd, "--format", "K") // Output in KBytes.
|
||||
cmd = append(cmd, "--realtime") // Measured in realtime.
|
||||
cmd = append(cmd, "--len", "128K") // Length of data buffer per request.
|
||||
n := i.Num
|
||||
if i.Parallel > 0 {
|
||||
n = i.Num / i.Parallel
|
||||
}
|
||||
cmd = append(cmd, "--len", fmt.Sprintf("%dK", len)) // Length in KB.
|
||||
cmd = append(cmd, "--num", fmt.Sprintf("%dK", n)) // Number of requests to send.
|
||||
cmd = append(cmd, "--client", host)
|
||||
cmd = append(cmd, "--port", fmt.Sprintf("%d", port))
|
||||
if i.Parallel > 0 {
|
||||
@@ -55,7 +54,7 @@ func (i *Iperf) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to parse bandwitdth from %s: %v", output, err)
|
||||
}
|
||||
b.SetBytes(int64(i.Length) * 1024) // Measure Bytes/sec for b.N, although below is iperf output.
|
||||
b.SetBytes(128 * 1024) // Measure Bytes/sec for b.N, although below is iperf output.
|
||||
ReportCustomMetric(b, bW*1024, "bandwidth" /*metric name*/, "bytes_per_second" /*unit*/)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user