summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFran�ois-R�gis Menguy <francoisregis.menguy@orange.com>2020-11-16 07:00:28 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-11-16 07:00:28 +0000
commitf684939fed81471c1381fa4fab6e1b6ea37093da (patch)
tree2e9764b22ec2e9e5a3bdbffb75fe8d69ef7d5bf2
parent78f547514e54a9332b919734aed7c8ca1390cb48 (diff)
parentbd0cf4ce9c30c8aae9b7a96cf9c8ea073cd9a548 (diff)
Merge "NFVBENCH-192: Complete/fix hdrh related processings to consider all cases (multiple service chains, distribution n/a with intel VFs)"
-rw-r--r--nfvbench/packet_stats.py21
-rw-r--r--nfvbench/summarizer.py34
-rwxr-xr-xnfvbench/traffic_client.py55
-rw-r--r--nfvbench/traffic_gen/traffic_base.py30
-rw-r--r--nfvbench/traffic_gen/trex_gen.py4
5 files changed, 88 insertions, 56 deletions
diff --git a/nfvbench/packet_stats.py b/nfvbench/packet_stats.py
index d6b9a68..d3ec78a 100644
--- a/nfvbench/packet_stats.py
+++ b/nfvbench/packet_stats.py
@@ -239,18 +239,21 @@ class PacketPathStats(object):
results = {'lat_min_usec': latency.min_usec,
'lat_max_usec': latency.max_usec,
'lat_avg_usec': latency.avg_usec}
- if latency.hdrh:
+ if latency.hdrh_available():
results['hdrh'] = latency.hdrh
decoded_histogram = HdrHistogram.decode(latency.hdrh)
- # override min max and avg from hdrh
- results['lat_min_usec'] = decoded_histogram.get_min_value()
- results['lat_max_usec'] = decoded_histogram.get_max_value()
- results['lat_avg_usec'] = decoded_histogram.get_mean_value()
results['lat_percentile'] = {}
- for percentile in self.config.lat_percentiles:
- results['lat_percentile'][percentile] = decoded_histogram.\
- get_value_at_percentile(percentile)
-
+ # override min max and avg from hdrh (only if histogram is valid)
+ if decoded_histogram.get_total_count() != 0:
+ results['lat_min_usec'] = decoded_histogram.get_min_value()
+ results['lat_max_usec'] = decoded_histogram.get_max_value()
+ results['lat_avg_usec'] = decoded_histogram.get_mean_value()
+ for percentile in self.config.lat_percentiles:
+ results['lat_percentile'][percentile] = decoded_histogram.\
+ get_value_at_percentile(percentile)
+ else:
+ for percentile in self.config.lat_percentiles:
+ results['lat_percentile'][percentile] = 'n/a'
else:
results = {}
results['packets'] = counters
diff --git a/nfvbench/summarizer.py b/nfvbench/summarizer.py
index bbd5908..7e2d129 100644
--- a/nfvbench/summarizer.py
+++ b/nfvbench/summarizer.py
@@ -263,8 +263,8 @@ class NFVBenchSummarizer(Summarizer):
# add percentiles headers if hdrh enabled
if not self.config.disable_hdrh:
for percentile in self.config.lat_percentiles:
- self.ndr_pdr_header.append((str(percentile) + ' %ile lat.', Formatter.standard))
- self.single_run_header.append((str(percentile) + ' %ile lat.', Formatter.standard))
+ self.ndr_pdr_header.append(str(percentile) + ' %ile lat.', Formatter.standard)
+ self.single_run_header.append(str(percentile) + ' %ile lat.', Formatter.standard)
# if sender is available initialize record
if self.sender:
self.__record_init()
@@ -481,6 +481,7 @@ class NFVBenchSummarizer(Summarizer):
self.extract_hdrh_percentiles(
analysis['stats']['overall']['rx']['lat_percentile'], row_data)
summary_table.add_row(row_data)
+
single_run_data = {
'type': 'single_run',
'offered_tx_rate_bps': analysis['stats']['offered_tx_rate_bps'],
@@ -556,29 +557,36 @@ class NFVBenchSummarizer(Summarizer):
'lat_min_usec': 'Min lat.',
'lat_max_usec': 'Max lat.'}
if 'lat_avg_usec' in chains['0']:
- lat_keys = ['lat_avg_usec', 'lat_min_usec', 'lat_max_usec', 'lat_percentile']
+ lat_keys = ['lat_avg_usec', 'lat_min_usec', 'lat_max_usec']
if not self.config.disable_hdrh:
+ lat_keys.append('lat_percentile')
for percentile in self.config.lat_percentiles:
- lat_map['lat_' + str(percentile) + '_percentile'] = str(
- percentile) + ' %ile lat.'
+ lat_map['lat_' + str(percentile) + '_percentile'] = \
+ str(percentile) + ' %ile lat.'
for key in lat_map:
- header.append((lat_map[key], Formatter.standard))
+ header.append(lat_map[key], Formatter.standard)
table = Table(header)
for chain in sorted(list(chains.keys()), key=str):
row = [chain] + chains[chain]['packets']
for lat_key in lat_keys:
- if chains[chain].get(lat_key, None):
- if lat_key == 'lat_percentile':
- if not self.config.disable_hdrh:
- for percentile in chains[chain][lat_key]:
- row.append(Formatter.standard(chains[chain][lat_key][percentile]))
- else:
+
+ if lat_key != 'lat_percentile':
+ if chains[chain].get(lat_key, None):
row.append(Formatter.standard(chains[chain][lat_key]))
+ else:
+ row.append('n/a')
else:
- row.append('--')
+ if not self.config.disable_hdrh:
+ if chains[chain].get(lat_key, None):
+ for percentile in chains[chain][lat_key]:
+ row.append(Formatter.standard(
+ chains[chain][lat_key][percentile]))
+ else:
+ for percentile in self.config.lat_percentiles:
+ row.append('n/a')
table.add_row(row)
return table
diff --git a/nfvbench/traffic_client.py b/nfvbench/traffic_client.py
index 6972509..ae8af8d 100755
--- a/nfvbench/traffic_client.py
+++ b/nfvbench/traffic_client.py
@@ -16,6 +16,7 @@
import socket
import struct
import time
+import sys
from attrdict import AttrDict
import bitmath
@@ -1112,20 +1113,25 @@ class TrafficClient(object):
for key in ['pkt_bit_rate', 'pkt_rate']:
for dirc in ['tx', 'rx']:
retDict['overall'][dirc][key] /= 2.0
- retDict['overall']['hdrh'] = stats.get('hdrh', None)
- if retDict['overall']['hdrh']:
- decoded_histogram = HdrHistogram.decode(retDict['overall']['hdrh'])
- # override min max and avg from hdrh
- retDict['overall']['rx']['min_delay_usec'] = decoded_histogram.get_min_value()
- retDict['overall']['rx']['max_delay_usec'] = decoded_histogram.get_max_value()
- retDict['overall']['rx']['avg_delay_usec'] = decoded_histogram.get_mean_value()
- retDict['overall']['rx']['lat_percentile'] = {}
- for percentile in self.config.lat_percentiles:
- retDict['overall']['rx']['lat_percentile'][percentile] = \
- decoded_histogram.get_value_at_percentile(percentile)
else:
retDict['overall'] = retDict[ports[0]]
retDict['overall']['drop_rate_percent'] = self.__get_dropped_rate(retDict['overall'])
+
+ if 'overall_hdrh' in stats:
+ retDict['overall']['hdrh'] = stats.get('overall_hdrh', None)
+ decoded_histogram = HdrHistogram.decode(retDict['overall']['hdrh'])
+ retDict['overall']['rx']['lat_percentile'] = {}
+ # override min max and avg from hdrh (only if histogram is valid)
+ if decoded_histogram.get_total_count() != 0:
+ retDict['overall']['rx']['min_delay_usec'] = decoded_histogram.get_min_value()
+ retDict['overall']['rx']['max_delay_usec'] = decoded_histogram.get_max_value()
+ retDict['overall']['rx']['avg_delay_usec'] = decoded_histogram.get_mean_value()
+ for percentile in self.config.lat_percentiles:
+ retDict['overall']['rx']['lat_percentile'][percentile] = \
+ decoded_histogram.get_value_at_percentile(percentile)
+ else:
+ for percentile in self.config.lat_percentiles:
+ retDict['overall']['rx']['lat_percentile'][percentile] = 'n/a'
return retDict
def __convert_rates(self, rate):
@@ -1154,19 +1160,21 @@ class TrafficClient(object):
}
if key == 'overall':
- stats[key]['hdrh'] = interface.get('hdrh', None)
- if stats[key]['hdrh']:
+ if 'hdrh' in interface:
+ stats[key]['hdrh'] = interface.get('hdrh', None)
decoded_histogram = HdrHistogram.decode(stats[key]['hdrh'])
- # override min max and avg from hdrh
- stats[key]['min_delay_usec'] = decoded_histogram.get_min_value()
- stats[key]['max_delay_usec'] = decoded_histogram.get_max_value()
- stats[key]['avg_delay_usec'] = decoded_histogram.get_mean_value()
stats[key]['lat_percentile'] = {}
- for percentile in self.config.lat_percentiles:
- stats[key]['lat_percentile'][percentile] = decoded_histogram.\
- get_value_at_percentile(percentile)
-
-
+ # override min max and avg from hdrh (only if histogram is valid)
+ if decoded_histogram.get_total_count() != 0:
+ stats[key]['min_delay_usec'] = decoded_histogram.get_min_value()
+ stats[key]['max_delay_usec'] = decoded_histogram.get_max_value()
+ stats[key]['avg_delay_usec'] = decoded_histogram.get_mean_value()
+ for percentile in self.config.lat_percentiles:
+ stats[key]['lat_percentile'][percentile] = decoded_histogram.\
+ get_value_at_percentile(percentile)
+ else:
+ for percentile in self.config.lat_percentiles:
+ stats[key]['lat_percentile'][percentile] = 'n/a'
return stats
def __targets_found(self, rate, targets, results):
@@ -1295,6 +1303,9 @@ class TrafficClient(object):
delta_tx = cur_tx - self.prev_tx
delta_rx = cur_rx - self.prev_rx
drops = delta_tx - delta_rx
+ if delta_tx == 0:
+ LOG.info("\x1b[1mConfiguration issue!\x1b[0m (no transmission)")
+ sys.exit(0)
drop_rate_pct = 100 * (delta_tx - delta_rx)/delta_tx
self.prev_tx = cur_tx
self.prev_rx = cur_rx
diff --git a/nfvbench/traffic_gen/traffic_base.py b/nfvbench/traffic_gen/traffic_base.py
index df28772..30aec6e 100644
--- a/nfvbench/traffic_gen/traffic_base.py
+++ b/nfvbench/traffic_gen/traffic_base.py
@@ -15,10 +15,10 @@
import abc
import sys
-import bitmath
-
from nfvbench.log import LOG
from . import traffic_utils
+from hdrh.histogram import HdrHistogram
+from functools import reduce
class Latency(object):
@@ -34,11 +34,23 @@ class Latency(object):
self.avg_usec = 0
self.hdrh = None
if latency_list:
+ hdrh_list = []
for lat in latency_list:
if lat.available():
self.min_usec = min(self.min_usec, lat.min_usec)
self.max_usec = max(self.max_usec, lat.max_usec)
self.avg_usec += lat.avg_usec
+ if lat.hdrh_available():
+ hdrh_list.append(HdrHistogram.decode(lat.hdrh))
+
+ # aggregate histograms if any
+ if hdrh_list:
+ def add_hdrh(x, y):
+ x.add(y)
+ return x
+ decoded_hdrh = reduce(add_hdrh, hdrh_list)
+ self.hdrh = HdrHistogram.encode(decoded_hdrh).decode('utf-8')
+
# round to nearest usec
self.avg_usec = int(round(float(self.avg_usec) / len(latency_list)))
@@ -46,6 +58,9 @@ class Latency(object):
"""Return True if latency information is available."""
return self.min_usec != sys.maxsize
+ def hdrh_available(self):
+ """Return True if latency histogram information is available."""
+ return self.hdrh is not None
class TrafficGeneratorException(Exception):
"""Exception for traffic generator."""
@@ -133,15 +148,8 @@ class AbstractTrafficGenerator(object):
result = {}
- intf_speeds = self.get_port_speed_gbps()
- tg_if_speed = bitmath.parse_string(str(intf_speeds[0]) + 'Gb').bits
- intf_speed = tg_if_speed
-
- if hasattr(self.config, 'intf_speed') and self.config.intf_speed is not None:
- # in case of limitation due to config, TG speed is not accurate
- # value is overridden by conf
- if self.config.intf_speed != tg_if_speed:
- intf_speed = bitmath.parse_string(self.config.intf_speed.replace('ps', '')).bits
+ # actual interface speed? (may be a virtual override)
+ intf_speed = self.config.intf_speed_used
if hasattr(self.config, 'user_info') and self.config.user_info is not None:
if "extra_encapsulation_bytes" in self.config.user_info:
diff --git a/nfvbench/traffic_gen/trex_gen.py b/nfvbench/traffic_gen/trex_gen.py
index 21e79ae..d5625eb 100644
--- a/nfvbench/traffic_gen/trex_gen.py
+++ b/nfvbench/traffic_gen/trex_gen.py
@@ -168,6 +168,8 @@ class TRex(AbstractTrafficGenerator):
result["latency"] = in_stats["latency"]
# Merge HDRHistogram to have an overall value for all chains and ports
+ # (provided that the histogram exists in the stats returned by T-Rex)
+ # Of course, empty histograms will produce an empty (invalid) histogram.
try:
hdrh_list = []
if ifstats:
@@ -186,7 +188,7 @@ class TRex(AbstractTrafficGenerator):
x.add(y)
return x
decoded_hdrh = reduce(add_hdrh, hdrh_list)
- result["hdrh"] = HdrHistogram.encode(decoded_hdrh).decode('utf-8')
+ result["overall_hdrh"] = HdrHistogram.encode(decoded_hdrh).decode('utf-8')
except KeyError:
pass