diff options
Diffstat (limited to 'opendc-compute')
4 files changed, 10 insertions, 6 deletions
diff --git a/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt b/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt index 9b92cf33..1c7d1e7d 100644 --- a/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt +++ b/opendc-compute/opendc-compute-failure/src/main/kotlin/org/opendc/compute/failure/victimselector/StochasticVictimSelector.kt @@ -27,6 +27,7 @@ import java.util.SplittableRandom import java.util.random.RandomGenerator import kotlin.math.max import kotlin.math.min +import kotlin.math.roundToInt /** * A [VictimSelector] that stochastically selects a set of hosts to be failed. @@ -73,7 +74,7 @@ public class StochasticVictimSelector( ): List<SimHost> { // clamp value between 0.0 and 1.0 val intensity = min(1.0, max(0.0, failureIntensity)) - val numberOfHosts = (hosts.size * intensity).toInt() + val numberOfHosts = (hosts.size * intensity).roundToInt() return hosts.asSequence().shuffled().take(numberOfHosts).toList() } diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt index 4a561e95..25e559fd 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/MemorizingScheduler.kt @@ -40,7 +40,7 @@ public class MemorizingScheduler( ) : ComputeScheduler { // We assume that there will be max 200 tasks per host. // The index of a host list is the number of tasks on that host. - private val hostsQueue = List(20000, { mutableListOf<HostView>() }) + private val hostsQueue = List(100, { mutableListOf<HostView>() }) private var minAvailableHost = 0 private var numHosts = 0 diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt index 4ea526b7..7549bb1c 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TaskStopper.kt @@ -79,7 +79,9 @@ public class TaskStopper( isHighCarbon = noForecastUpdateCarbonIntensity(newCarbonIntensity) } else { val forecast = carbonModel!!.getForecast(forecastSize) - val quantileIndex = (forecastSize * forecastThreshold).roundToInt() + + val localForecastSize = forecast.size + val quantileIndex = (localForecastSize * forecastThreshold).roundToInt() val thresholdCarbonIntensity = forecast.sorted()[quantileIndex] isHighCarbon = newCarbonIntensity > thresholdCarbonIntensity diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt index 2f9b4364..f402c5a5 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/scheduler/timeshift/TimeshiftScheduler.kt @@ -171,10 +171,11 @@ public class TimeshiftScheduler( } val forecast = carbonModel!!.getForecast(forecastSize) - val forecastSize = forecast.size - val shortQuantileIndex = (forecastSize * shortForecastThreshold).roundToInt() + val localForecastSize = forecast.size + + val shortQuantileIndex = (localForecastSize * shortForecastThreshold).roundToInt() val shortCarbonIntensity = forecast.sorted()[shortQuantileIndex] - val longQuantileIndex = (forecastSize * longForecastThreshold).roundToInt() + val longQuantileIndex = (localForecastSize * longForecastThreshold).roundToInt() val longCarbonIntensity = forecast.sorted()[longQuantileIndex] shortLowCarbon = newCarbonIntensity < shortCarbonIntensity |
