From 00cfd19aa237dbfecd350e992b2d0a04af0e0028 Mon Sep 17 00:00:00 2001 From: venkataanil Date: Tue, 25 Jun 2024 00:10:13 +0530 Subject: [PATCH] Fix uperf RR reporting (#146) Uperf was reporting Mbps for RR throughput instead of op/s. Fixed that in this patch. fixes #144 Signed-off-by: venkataanil --- cmd/k8s-netperf/k8s-netperf.go | 4 ++-- pkg/drivers/driver.go | 2 +- pkg/drivers/iperf.go | 2 +- pkg/drivers/netperf.go | 2 +- pkg/drivers/uperf.go | 11 +++++++---- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/k8s-netperf/k8s-netperf.go b/cmd/k8s-netperf/k8s-netperf.go index 0ce0f6e8..a30f7900 100644 --- a/cmd/k8s-netperf/k8s-netperf.go +++ b/cmd/k8s-netperf/k8s-netperf.go @@ -364,7 +364,7 @@ func executeWorkload(nc config.Config, s config.PerfScenarios, hostNet bool, dri if err != nil { log.Fatal(err) } - nr, err = driver.ParseResults(&r) + nr, err = driver.ParseResults(&r, nc) if err != nil { log.Error(err) try := 0 @@ -377,7 +377,7 @@ func executeWorkload(nc config.Config, s config.PerfScenarios, hostNet bool, dri log.Error(err) continue } - nr, err = driver.ParseResults(&r) + nr, err = driver.ParseResults(&r, nc) if err != nil { log.Error(err) try++ diff --git a/pkg/drivers/driver.go b/pkg/drivers/driver.go index cd265c76..0281e71f 100644 --- a/pkg/drivers/driver.go +++ b/pkg/drivers/driver.go @@ -13,7 +13,7 @@ import ( type Driver interface { IsTestSupported(string) bool Run(c *kubernetes.Clientset, rc rest.Config, nc config.Config, client apiv1.PodList, serverIP string) (bytes.Buffer, error) - ParseResults(stdout *bytes.Buffer) (sample.Sample, error) + ParseResults(stdout *bytes.Buffer, nc config.Config) (sample.Sample, error) } type netperf struct { diff --git a/pkg/drivers/iperf.go b/pkg/drivers/iperf.go index e98652f3..47cbe802 100644 --- a/pkg/drivers/iperf.go +++ b/pkg/drivers/iperf.go @@ -151,7 +151,7 @@ func (i *iperf3) Run(c *kubernetes.Clientset, rc rest.Config, nc config.Config, // ParseResults accepts the stdout from the execution of the benchmark. // It will return a Sample struct or error -func (i *iperf3) ParseResults(stdout *bytes.Buffer) (sample.Sample, error) { +func (i *iperf3) ParseResults(stdout *bytes.Buffer, _ config.Config) (sample.Sample, error) { sample := sample.Sample{} sample.Driver = i.driverName result := IperfResult{} diff --git a/pkg/drivers/netperf.go b/pkg/drivers/netperf.go index ad172440..39de8047 100644 --- a/pkg/drivers/netperf.go +++ b/pkg/drivers/netperf.go @@ -82,7 +82,7 @@ func (n *netperf) Run(c *kubernetes.Clientset, rc rest.Config, nc config.Config, // ParseResults accepts the stdout from the execution of the benchmark. It also needs // It will return a Sample struct or error -func (n *netperf) ParseResults(stdout *bytes.Buffer) (sample.Sample, error) { +func (n *netperf) ParseResults(stdout *bytes.Buffer, _ config.Config) (sample.Sample, error) { sample := sample.Sample{} sample.Driver = n.driverName send := 0.0 diff --git a/pkg/drivers/uperf.go b/pkg/drivers/uperf.go index 60a1a160..4b08edea 100644 --- a/pkg/drivers/uperf.go +++ b/pkg/drivers/uperf.go @@ -190,7 +190,7 @@ func (u *uperf) Run(c *kubernetes.Clientset, rc rest.Config, nc config.Config, c // ParseResults accepts the stdout from the execution of the benchmark. // It will return a Sample struct or error -func (u *uperf) ParseResults(stdout *bytes.Buffer) (sample.Sample, error) { +func (u *uperf) ParseResults(stdout *bytes.Buffer, nc config.Config) (sample.Sample, error) { sample := sample.Sample{} sample.Driver = u.driverName sample.Metric = "Mb/s" @@ -218,10 +218,13 @@ func (u *uperf) ParseResults(stdout *bytes.Buffer) (sample.Sample, error) { } averageByte, _ := stats.Mean(byteSummary) - averageOps, _ := stats.Mean(opSummary) - sample.Throughput = float64(averageByte*8) / 1000000 + if strings.Contains(nc.Profile, "STREAM") { + sample.Throughput = float64(averageByte*8) / 1000000 + } else { + sample.Throughput, _ = stats.Mean(opSummary) + } sample.Latency99ptile, _ = stats.Percentile(latSummary, 99) - log.Debugf("Storing uperf sample throughput: %f Mbps, P99 Latency %f, Average ops: %f ", sample.Throughput, sample.Latency99ptile, averageOps) + log.Debugf("Storing uperf sample Average bytes: %f , P99 Latency %f, Throughput: %f ", averageByte, sample.Latency99ptile, sample.Throughput) return sample, nil