diff options
author | Vratko Polak <vrpolak@cisco.com> | 2021-03-22 17:11:21 +0100 |
---|---|---|
committer | Vratko Polak <vrpolak@cisco.com> | 2021-03-22 17:11:21 +0100 |
commit | b6fbffad32515ccf94404680cb5280c2cb561af5 (patch) | |
tree | 6f16569781e3e3627589c6fff0d7a5be0410d3f3 /resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py | |
parent | adf5f13886e8bdd4fb224f12f10d731cadf698f3 (diff) |
MLRsearch: Support other than just two ratios
+ Change some method names and argument types:
+ Do not mention NDR and PDR, except as examples.
+ Return list of ReceiveRateInterval instead of NdrPdrResult.
+ The resulting intervals can be degenerate when hitting min/max rate.
+ Rename quantity name parts from "fraction" to "ratio".
+ Intervals are no longer tracked for each target ratio.
+ They are found dynamically from known results.
+ Add effective_loss_ratio field to avoid loss inversion effects.
+ Move some functions to separate files.
+ Bound search logic moved to MeasurementDatabase.py
+ ProgressState moved to its file.
+ WidthArithmetics.py holds small computation functions.
+ Use parameter expansion_coefficient instead of "doublings".
+ Do uneven bisect to save time when width is not power of two times goal.
+ Timeout now correctly tracked for the whole search,
not just the current phase.
+ Make logging (debug) function pluggable.
+ Added debug log messages for initial phase.
+ Do not mark as subclass if contructor signature differs.
+ Avoid re-measure on scale-limited (ASTF) profiles.
+ Remove outdated comments.
+ Bump copyright years.
Change-Id: I93f693b4f186f59030ee5ac21b78acc890109813
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py')
-rw-r--r-- | resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py b/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py index c732e66026..c52934530e 100644 --- a/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py +++ b/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -19,7 +19,8 @@ class ReceiveRateMeasurement: def __init__( self, duration, target_tr, transmit_count, loss_count, - approximated_duration=0.0, partial_transmit_count=0): + approximated_duration=0.0, partial_transmit_count=0, + effective_loss_ratio=None): """Constructor, normalize primary and compute secondary quantities. If approximated_duration is nonzero, it is stored. @@ -27,7 +28,7 @@ class ReceiveRateMeasurement: Either way, additional secondary quantities are computed from the store value. - If there is zero transmit_count, fractions are set to zero. + If there is zero transmit_count, ratios are set to zero. In some cases, traffic generator does not attempt all the needed transactions. In that case, nonzero partial_transmit_count @@ -36,6 +37,14 @@ class ReceiveRateMeasurement: TODO: Use None instead of zero? + Field effective_loss_ratio is specific for use in MLRsearch, + where measurements with lower loss ratio at higher target_tr + cannot be relied upon if there is a measurement with higher loss ratio + at lower target_tr. In this case, the higher loss ratio from + other measurement is stored as effective loss ratio in this measurement. + If None, the computed loss ratio of this measurement is used. + If not None, the computed ratio can still be apllied if it is larger. + :param duration: Measurement duration [s]. :param target_tr: Target transmit rate [pps]. If bidirectional traffic is measured, this is bidirectional rate. @@ -44,6 +53,7 @@ class ReceiveRateMeasurement: :param approximated_duration: Estimate of the actual time of the trial. :param partial_transmit_count: Estimate count of actually attempted transactions. + :param effective_loss_ratio: None or highest loss ratio so far. :type duration: float :type target_tr: float :type transmit_count: int @@ -59,11 +69,15 @@ class ReceiveRateMeasurement: self.transmit_rate = transmit_count / self.duration self.loss_rate = loss_count / self.duration self.receive_rate = self.receive_count / self.duration - self.loss_fraction = ( + self.loss_ratio = ( float(self.loss_count) / self.transmit_count if self.transmit_count > 0 else 1.0 ) - self.receive_fraction = ( + self.effective_loss_ratio = self.loss_ratio + if effective_loss_ratio is not None: + if effective_loss_ratio > self.loss_ratio: + self.effective_loss_ratio = float(effective_loss_ratio) + self.receive_ratio = ( float(self.receive_count) / self.transmit_count if self.transmit_count > 0 else 0.0 ) @@ -81,12 +95,12 @@ class ReceiveRateMeasurement: int(partial_transmit_count) if partial_transmit_count else self.transmit_count ) - self.partial_receive_fraction = ( + self.partial_receive_ratio = ( float(self.receive_count) / self.partial_transmit_count if self.partial_transmit_count > 0 else 0.0 ) self.partial_receive_rate = ( - self.target_tr * self.partial_receive_fraction + self.target_tr * self.partial_receive_ratio ) # We use relative packet ratios in order to support cases # where target_tr is in transactions per second, @@ -96,9 +110,9 @@ class ReceiveRateMeasurement: ) def __str__(self): - """Return string reporting input and loss fraction.""" + """Return string reporting input and loss ratio.""" return f"d={self.duration!s},Tr={self.target_tr!s}," \ - f"Df={self.loss_fraction!s}" + f"Df={self.loss_ratio!s}" def __repr__(self): """Return string evaluable as a constructor call.""" @@ -107,4 +121,5 @@ class ReceiveRateMeasurement: f"transmit_count={self.transmit_count!r}," \ f"loss_count={self.loss_count!r}," \ f"approximated_duration={self.approximated_duration!r}," \ - f"partial_transmit_count={self.partial_transmit_count!r})" + f"partial_transmit_count={self.partial_transmit_count!r}," \ + f"effective_loss_ratio={self.effective_loss_ratio!r})" |