Skip to content

Commit

Permalink
Merge branch 'pr-196'
Browse files Browse the repository at this point in the history
This adds support for the --send-size parameter as both a test parameter
and a global parameter. The parameter is supposed to be per-flow, but this
thus far only works on the multi-host rtt_fair-based tests. However, this
is not unique to this new parameter, so let's not hold up merging because
of this.

Closes #196.

Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
  • Loading branch information
tohojo committed Feb 11, 2020
2 parents 3d663cf + 5666e9a commit bb52450
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 8 deletions.
11 changes: 11 additions & 0 deletions doc/options.rst
Expand Up @@ -217,6 +217,17 @@ parsing input files.
can be measured. As such you may need to adjust it if you are experiencing
latency above the default value. Set to 0 to disable.

.. option:: --send-size=SEND_SIZE

Send size (in bytes) used for TCP tests. Netperf uses the socket buffer size
by default, which if too large can cause spikes in the throughput results.
Lowering this value will increase CPU usage but also improves the fidelity
of the throughput results without having to decrease the socket buffer size.

Can be specified multiple times, with each value corresponding to a stream
of a test. If only specified once, the same value will be applied to all
flows.

.. option:: --test-parameter=key=value

Arbitrary test parameter in key=value format. Key will be case folded to
Expand Down
7 changes: 6 additions & 1 deletion flent/runners.py
Expand Up @@ -956,6 +956,9 @@ def check(self):
args.setdefault('cong_control',
self.settings.TEST_PARAMETERS.get('tcp_cong_control', ''))
args.setdefault('socket_timeout', self.settings.SOCKET_TIMEOUT)
args.setdefault('send_size',
self.settings.SEND_SIZE[0]
if self.settings.SEND_SIZE else None)

if self.settings.SWAP_UPDOWN:
if self.test == 'TCP_STREAM':
Expand Down Expand Up @@ -1030,6 +1033,8 @@ def check(self):

if self.test in ("TCP_STREAM", "TCP_MAERTS"):
args['format'] = "-f m"
if args['send_size']:
args['send_size'] = "-m {0} -M {0}".format(args['send_size'])
self.units = 'Mbits/s'

if args['test'] == 'TCP_STREAM' and self.settings.SOCKET_STATS:
Expand All @@ -1050,7 +1055,7 @@ def check(self):
"{marking} -H {control_host} -p {control_port} " \
"-t {test} -l {length:d} {buffer} {format} " \
"{control_local_bind} {extra_args} -- " \
"{socket_timeout} {local_bind} -H {host} -k {output_vars} " \
"{socket_timeout} {send_size} {local_bind} -H {host} -k {output_vars} " \
"{cong_control} {extra_test_args}".format(**args)

super(NetperfDemoRunner, self).check()
Expand Down
16 changes: 14 additions & 2 deletions flent/settings.py
Expand Up @@ -368,6 +368,16 @@ def __call__(self, parser, namespace, values, option_string=None):
"detected to support this (requires netperf version 2.7 or newer). Set to 0 "
"to disable.")

test_group.add_argument(
"--send-size",
action="append", type=unicode, dest="SEND_SIZE",
help="Send size (in bytes) used for TCP tests. netperf uses the socket "
"buffer size by default, which if too large can cause spikes in the "
"throughput results. Lowering this value will increase CPU usage but "
"also improves the fidelity of the throughput results without having "
"to decrease the socket buffer size. Can be specified multiple times, "
"with each value corresponding to a stream of a test.")

test_group.add_argument(
"--test-parameter",
action=Update, type=keyval, dest="TEST_PARAMETERS", metavar='key=value',
Expand Down Expand Up @@ -730,10 +740,12 @@ def update_implications(self):
if self.DATA_DIR is None:
self.DATA_DIR = os.path.dirname(self.OUTPUT) or '.'

# Backwards compatibility for when LOCAL_BIND could only be specified
# once - just duplicate the value
# For per-stream options, if only specified once duplicate them for each
# host so they apply to all flows
if len(self.LOCAL_BIND) == 1 and len(self.HOSTS) > 1:
self.LOCAL_BIND *= len(self.HOSTS)
if len(self.SEND_SIZE) == 1 and len(self.HOSTS) > 1:
self.SEND_SIZE *= len(self.HOSTS)

for k, v in self.BATCH_OVERRIDE.items():
if not hasattr(v, 'lower'):
Expand Down
11 changes: 10 additions & 1 deletion flent/testenv.py
Expand Up @@ -57,7 +57,12 @@
# in the code below
STREAM_CONFIG_PARAM_NAMES = ['label', 'ping_label', 'marking',
'control_host', 'local_bind', 'cc_algo',
'udp_bandwidth', 'udp_pktsize']
'udp_bandwidth', 'udp_pktsize', 'send_size']

# Mapping of test parameters that will be picked up from the global settings if
# they are not set
GLOBAL_TEST_PARAMS_MAP = {'local_binds': 'LOCAL_BIND',
'send_sizes': 'SEND_SIZE'}

class _no_default():
pass
Expand Down Expand Up @@ -155,6 +160,10 @@ def get_test_parameter(self, name, default=_no_default, split=False, cast=None):
ret = cast(ret)
return ret
except KeyError:
if name in GLOBAL_TEST_PARAMS_MAP:
ret = self.env[GLOBAL_TEST_PARAMS_MAP[name]]
if ret:
return ret
if default is not _no_default:
return default
if self.informational:
Expand Down
6 changes: 3 additions & 3 deletions flent/tests/rtt_fair.inc
Expand Up @@ -34,7 +34,7 @@ DATA_SETS = o([
])

def add_stream(i, host=None, label='BE', ping_label='ICMP', marking='CS0',
control_host=None, local_bind=None, cc_algo=None,
control_host=None, local_bind=None, cc_algo=None, send_size=None,
length=LENGTH, delay=DELAY, **kwargs):
if host is None:
return
Expand All @@ -46,12 +46,12 @@ def add_stream(i, host=None, label='BE', ping_label='ICMP', marking='CS0',
{'test': 'TCP_STREAM', 'length': length, 'host': host, 'marking': marking or
'CS0', 'control_host': control_host or host, 'local_bind': local_bind,
'delay': delay, 'id': host, 'units': 'Mbits/s', 'runner': 'netperf_demo',
'cong_control': cc_algo}
'cong_control': cc_algo, 'send_size': send_size}
DATA_SETS['TCP download %s %s' % (label or "BE", host)] = \
{'test': 'TCP_MAERTS', 'length': length, 'host': host, 'marking': marking or
'CS0', 'control_host': control_host or host, 'local_bind': local_bind,
'delay': delay, 'id': host, 'units': 'Mbits/s', 'runner': 'netperf_demo',
'cong_control': cc_algo}
'cong_control': cc_algo, 'send_size': send_size}
DATA_SETS['Ping (ms) %s %s' % (ping_label or "ICMP", host)] = \
{'ip_version': IP_VERSION, 'interval': STEP_SIZE, 'length': TOTAL_LENGTH,
'host': host, 'local_bind': local_bind, 'id': host, 'units': 'ms',
Expand Down
14 changes: 13 additions & 1 deletion man/flent.1
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "FLENT" "1" "July 09, 2019" "1.9.9-git" "Flent: The FLExible Network Tester"
.TH "FLENT" "1" "February 11, 2020" "1.9.9-git" "Flent: The FLExible Network Tester"
.SH NAME
flent \- Flent: The FLExible Network Tester
.
Expand Down Expand Up @@ -318,6 +318,18 @@ latency above the default value. Set to 0 to disable.
.UNINDENT
.INDENT 0.0
.TP
.B \-\-send\-size=SEND_SIZE
Send size (in bytes) used for TCP tests. Netperf uses the socket buffer size
by default, which if too large can cause spikes in the throughput results.
Lowering this value will increase CPU usage but also improves the fidelity
of the throughput results without having to decrease the socket buffer size.
.sp
Can be specified multiple times, with each value corresponding to a stream
of a test. If only specified once, the same value will be applied to all
flows.
.UNINDENT
.INDENT 0.0
.TP
.B \-\-test\-parameter=key=value
Arbitrary test parameter in key=value format. Key will be case folded to
lower case. The values are stored with the results metadata, and so can be
Expand Down

0 comments on commit bb52450

Please sign in to comment.