summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/jmh
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-23 17:15:25 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-03 22:23:33 +0200
commit80335a49513f3e74228aa1bfb998dd54855f68e2 (patch)
tree3bfdc735ef39353c6c715399c2d9890ff423d4c4 /opendc-simulator/opendc-simulator-compute/src/jmh
parentb5d6aa7f384ea9d6a1a40965e883ac6403c302fd (diff)
simulator: Introduce SimResourceScheduler
This change introduces the SimResourceScheduler interface, which is a generic interface for scheduling the coordination and synchronization between resource providers and resource consumers. This interface replaces the need for users to manually specify the clock and coroutine context per resource provider.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/jmh')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt15
1 files changed, 8 insertions, 7 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
index bae31921..15714aca 100644
--- a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
@@ -34,7 +34,8 @@ import org.opendc.simulator.compute.power.ConstantPowerModel
import org.opendc.simulator.compute.workload.SimTraceWorkload
import org.opendc.simulator.core.SimulationCoroutineScope
import org.opendc.simulator.core.runBlockingSimulation
-import org.opendc.utils.TimerScheduler
+import org.opendc.simulator.resources.SimResourceScheduler
+import org.opendc.simulator.resources.SimResourceSchedulerTrampoline
import org.openjdk.jmh.annotations.*
import java.util.concurrent.TimeUnit
@@ -45,13 +46,13 @@ import java.util.concurrent.TimeUnit
@OptIn(ExperimentalCoroutinesApi::class)
class SimMachineBenchmarks {
private lateinit var scope: SimulationCoroutineScope
- private lateinit var scheduler: TimerScheduler<Any>
+ private lateinit var scheduler: SimResourceScheduler
private lateinit var machineModel: SimMachineModel
@Setup
fun setUp() {
scope = SimulationCoroutineScope()
- scheduler = TimerScheduler(scope.coroutineContext, scope.clock)
+ scheduler = SimResourceSchedulerTrampoline(scope.coroutineContext, scope.clock)
val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
@@ -61,7 +62,7 @@ class SimMachineBenchmarks {
)
}
- @State(Scope.Thread)
+ @State(Scope.Benchmark)
class Workload {
lateinit var trace: Sequence<SimTraceWorkload.Fragment>
@@ -120,7 +121,7 @@ class SimMachineBenchmarks {
coroutineContext, clock, machineModel, PerformanceScalingGovernor(),
SimpleScalingDriver(ConstantPowerModel(0.0))
)
- val hypervisor = SimFairShareHypervisor()
+ val hypervisor = SimFairShareHypervisor(scheduler)
launch { machine.run(hypervisor) }
@@ -142,12 +143,12 @@ class SimMachineBenchmarks {
coroutineContext, clock, machineModel, PerformanceScalingGovernor(),
SimpleScalingDriver(ConstantPowerModel(0.0))
)
- val hypervisor = SimFairShareHypervisor()
+ val hypervisor = SimFairShareHypervisor(scheduler)
launch { machine.run(hypervisor) }
coroutineScope {
- repeat(2) { i ->
+ repeat(2) {
val vm = hypervisor.createMachine(machineModel)
launch {