Skip to content

Commit

Permalink
Change Class enum, fair -> target
Browse files Browse the repository at this point in the history
  • Loading branch information
ccanel committed Feb 29, 2024
1 parent c48f036 commit 0d23307
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions ratemon/model/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
class Class(IntEnum):
"""Classes for three-class models.
Flow throughput is lower than, approximately, or above fair.
Flow throughput is below, near, or above the target rate.
"""

BELOW_FAIR = 0
APPROX_FAIR = 1
ABOVE_FAIR = 2
BELOW_TARGET = 0
NEAR_TARGET = 1
ABOVE_TARGET = 2

@staticmethod
def ratio_to_class(ratio):
Expand All @@ -137,11 +137,11 @@ def ratio_to_class(ratio):
ratio = ratio[0]

if ratio < 1 - FAIR_THRESH:
cls = Class.BELOW_FAIR
cls = Class.BELOW_TARGET
elif ratio <= 1 + FAIR_THRESH:
cls = Class.APPROX_FAIR
cls = Class.NEAR_TARGET
elif ratio > 1 + FAIR_THRESH:
cls = Class.ABOVE_FAIR
cls = Class.ABOVE_TARGET
else:
raise Exception("This case should never be reached.")
return cls
Expand Down
2 changes: 1 addition & 1 deletion ratemon/runtime/flow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def __init__(self, fourtuple, loss_event_windows, start_time_us):
self.min_rtt_us = sys.maxsize
# The timestamp of the last packet on which we have run inference.
self.latest_time_sec = time.time()
self.label = defaults.Class.APPROX_FAIR
self.label = defaults.Class.NEAR_TARGET
self.decision = (defaults.Decision.NOT_PACED, None)
self.loss_tracker = loss_event_rate.LossTracker(self, loss_event_windows)

Expand Down
8 changes: 4 additions & 4 deletions ratemon/runtime/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
def predict(net, in_fets, debug=False):
"""Run inference on a flow's packets.
Returns a label (below fair, approximately fair, above fair), the updated
Returns a label (below target, near target, above target), the updated
min_rtt_us, and the features of the last packet.
"""
in_fets = utils.clean(in_fets)
Expand Down Expand Up @@ -159,7 +159,7 @@ def make_decision_servicepolicy(
# features.make_win_metric(features.LOSS_RATE_FET, models.MathisFairness.win_size)
# ]

# if label == defaults.Class.ABOVE_FAIR and loss_rate >= 1e-9:
# if label == defaults.Class.ABOVE_TARGET and loss_rate >= 1e-9:
# logging.info("Mode 1")
# # This sender is sending too fast according to the Mathis model, and we
# # know that the bottleneck is fully utilized because there has been loss
Expand Down Expand Up @@ -270,7 +270,7 @@ def make_decision_flow_fairness(
)
else:
tput_bps = utils.safe_tput_bps(fets, 0, len(fets) - 1)
if label == defaults.Class.ABOVE_FAIR:
if label == defaults.Class.ABOVE_TARGET:
# This flow is sending too fast. Force the sender to slow down.
new_tput_bps = reaction_strategy.react_down(
args.reaction_strategy,
Expand All @@ -289,7 +289,7 @@ def make_decision_flow_fairness(
)
elif flow_to_decisions[flowkey][0] == defaults.Decision.PACED:
# We are already pacing this flow.
if label == defaults.Class.BELOW_FAIR:
if label == defaults.Class.BELOW_TARGET:
# If we are already pacing this flow but we are being too
# aggressive, then let it send faster.
new_tput_bps = reaction_strategy.react_up(
Expand Down

0 comments on commit 0d23307

Please sign in to comment.