From 3a370ece860b0eba25cd1c7a366d767ae458192b Mon Sep 17 00:00:00 2001 From: Sacheendra Talluri Date: Wed, 2 Apr 2025 17:54:53 +0200 Subject: Separate timeshift into an interface and add it to memorizing (#329) * Separate timeshift into an interface and add it to memorizing * Run spotless apply * Remove random from memorizing sched test * Record time on task termination * spotless apply --- .../specs/allocation/AllocationPolicySpec.kt | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'opendc-experiments/opendc-experiments-base/src/main') diff --git a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt index 21d2f994..bc96562c 100644 --- a/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt +++ b/opendc-experiments/opendc-experiments-base/src/main/kotlin/org/opendc/experiments/base/experiment/specs/allocation/AllocationPolicySpec.kt @@ -28,6 +28,7 @@ import org.opendc.compute.simulator.scheduler.ComputeScheduler import org.opendc.compute.simulator.scheduler.ComputeSchedulerEnum import org.opendc.compute.simulator.scheduler.FilterScheduler import org.opendc.compute.simulator.scheduler.createPrefabComputeScheduler +import org.opendc.compute.simulator.scheduler.timeshift.MemorizingTimeshift import org.opendc.compute.simulator.scheduler.timeshift.TaskStopper import org.opendc.compute.simulator.scheduler.timeshift.TimeshiftScheduler import java.time.InstantSource @@ -68,6 +69,7 @@ public data class TimeShiftAllocationPolicySpec( val longForecastThreshold: Double = 0.35, val forecastSize: Int = 24, val taskStopper: TaskStopperSpec? = null, + val memorize: Boolean = true, ) : AllocationPolicySpec public fun createComputeScheduler( @@ -85,10 +87,22 @@ public fun createComputeScheduler( is TimeShiftAllocationPolicySpec -> { val filters = spec.filters.map { createHostFilter(it) } val weighers = spec.weighers.map { createHostWeigher(it) } - TimeshiftScheduler( - filters, weighers, spec.windowSize, clock, spec.subsetSize, spec.forecast, - spec.shortForecastThreshold, spec.longForecastThreshold, spec.forecastSize, seeder, - ) + if (spec.memorize) { + MemorizingTimeshift( + filters, + spec.windowSize, + clock, + spec.forecast, + spec.shortForecastThreshold, + spec.longForecastThreshold, + spec.forecastSize, + ) + } else { + TimeshiftScheduler( + filters, weighers, spec.windowSize, clock, spec.subsetSize, spec.forecast, + spec.shortForecastThreshold, spec.longForecastThreshold, spec.forecastSize, seeder, + ) + } } } } -- cgit v1.2.3