Skip to content

Commit

Permalink
Rope uses percentage for Clutch RPS (#86)
Browse files Browse the repository at this point in the history

* Rope uses absolute values instead of percentage

Co-authored-by: Calvin Cheung <[email protected]>
  • Loading branch information
calvin681 and calvin681 authored Jan 5, 2021
1 parent aab3066 commit f6b3764
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,32 @@ void start() {
clutchCustomConfiguration.isPresent())) {

ClutchConfiguration config = null;
int minSize = stageSchedulingInfo.getScalingPolicy().getMin();
int maxSize = stageSchedulingInfo.getScalingPolicy().getMax();
int minSize = 0;
int maxSize = 0;
boolean useJsonConfigBased = false;
boolean useClutch = false;
boolean useClutchRps = false;
boolean useClutchExperimental = false;

// Determine which type of scaler to use.
if (stageSchedulingInfo.getScalingPolicy() != null) {
minSize = stageSchedulingInfo.getScalingPolicy().getMin();
maxSize = stageSchedulingInfo.getScalingPolicy().getMax();
if (stageSchedulingInfo.getScalingPolicy().getStrategies() != null) {
Set<StageScalingPolicy.ScalingReason> reasons = stageSchedulingInfo.getScalingPolicy().getStrategies()
.values()
.stream()
.map(StageScalingPolicy.Strategy::getReason)
.collect(Collectors.toSet());
if (reasons.contains(StageScalingPolicy.ScalingReason.Clutch)) {
useClutch = true;
} else if (reasons.contains(StageScalingPolicy.ScalingReason.ClutchExperimental)) {
useClutchExperimental = true;
} else if (reasons.contains(StageScalingPolicy.ScalingReason.ClutchRps)) {
useClutchRps = true;
}
}
}
if (clutchCustomConfiguration.isPresent()) {
try {
config = getClutchConfiguration(clutchCustomConfiguration.get()).get(stage);
Expand All @@ -179,21 +197,6 @@ void start() {
}
}
}
if (stageSchedulingInfo.getScalingPolicy() != null &&
stageSchedulingInfo.getScalingPolicy().getStrategies() != null) {
Set<StageScalingPolicy.ScalingReason> reasons = stageSchedulingInfo.getScalingPolicy().getStrategies()
.values()
.stream()
.map(StageScalingPolicy.Strategy::getReason)
.collect(Collectors.toSet());
if (reasons.contains(StageScalingPolicy.ScalingReason.Clutch)) {
useClutch = true;
} else if (reasons.contains(StageScalingPolicy.ScalingReason.ClutchExperimental)) {
useClutchExperimental = true;
} else if (reasons.contains(StageScalingPolicy.ScalingReason.ClutchRps)) {
useClutchRps = true;
}
}

int initialSize = stageSchedulingInfo.getNumberOfInstances();
StageScaler scaler = new StageScaler(stage, stageSchedulingInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public RpsClutchConfigurationSelector(Integer stageNumber, StageSchedulingInfo s
@Override
public ClutchConfiguration apply(Map<Clutch.Metric, UpdateDoublesSketch> sketches) {
double setPoint = getSetpoint(sketches);
Tuple2<Double, Double> rope = getRope().map(x -> x * setPoint, y -> y * setPoint);

// Gain - number of ticks within the cooldown period. This is the minimum number of times PID output will accumulate
// before an action is taken.
Expand All @@ -60,7 +61,7 @@ public ClutchConfiguration apply(Map<Clutch.Metric, UpdateDoublesSketch> sketche
.integralDecay(INTEGRAL_DECAY)
.minSize(getMinSize())
.maxSize(getMaxSize())
.rope(getRope())
.rope(rope)
.cooldownInterval(getCooldownSecs())
.cooldownUnits(TimeUnit.SECONDS)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void testApply() {
assertEquals(100.0, config.getSetPoint(), 1e-10);
assertEquals(1, config.getMinSize());
assertEquals(10, config.getMaxSize());
assertEquals(Tuple.of(0.2, 0.1), config.getRope());
assertEquals(Tuple.of(20.0, 10.0), config.getRope());
assertEquals(300L, config.getCooldownInterval());
}

Expand All @@ -76,7 +76,7 @@ public void testScalingPolicyFallback() {
assertEquals(100.0, config.getSetPoint(), 1e-10);
assertEquals(2, config.getMinSize());
assertEquals(9, config.getMaxSize());
assertEquals(Tuple.of(0.3, 0.0), config.getRope());
assertEquals(Tuple.of(30.0, 0.0), config.getRope());
assertEquals(400L, config.getCooldownInterval());

}
Expand Down

0 comments on commit f6b3764

Please sign in to comment.