diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-06-03 14:03:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-03 14:03:12 +0200 |
| commit | 1303fe97510fb7987746722b3261c696f523fbd5 (patch) | |
| tree | d927dbd4c71a5ea6435f5994e8fa0bc90ef19b2c /opendc-experiments/opendc-experiments-tf20/src | |
| parent | ae987fa84b2e061eb9fdfec5561e1c976aaa5a54 (diff) | |
| parent | cef12722f03a24a0e1e3b7502fb5e434d93f1664 (diff) | |
simulator: Improve simulator resource model (#142)
This pull request improves the existing simulator resource model
that is at the core of all simulation models in OpenDC.
Most importantly, we have changed the way of how metrics are reported by this layer.
* Add `SimResourceInterpreter` which is responsible for efficiently scheduling
communication between resources in OpenDC. The performance gain is in the 2x-5x range.
* Add uniform interface for exposing resource metrics (using `SimResourceCounters`).
* Split the CPUFreq subsystem in the compute simulator as it mixed responsibilities of
different layers.
**Breaking API Changes**
* Resource providers now accept a `SimResourceInterpreter` which is
responsible for coordinating the communication between resources.
* `ScalingGovernor` is not part of the machine layer anymore. Instead, it should
move in the OS/Hypervisor layer.
* Workloads should now start CPU consumers using `cpu.startConsumer`.
Diffstat (limited to 'opendc-experiments/opendc-experiments-tf20/src')
| -rw-r--r-- | opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt index f4c18ff1..001547ef 100644 --- a/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt +++ b/opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt @@ -29,16 +29,12 @@ import org.opendc.simulator.compute.SimBareMetalMachine import org.opendc.simulator.compute.SimMachine import org.opendc.simulator.compute.SimMachineContext import org.opendc.simulator.compute.SimMachineModel -import org.opendc.simulator.compute.cpufreq.PerformanceScalingGovernor -import org.opendc.simulator.compute.cpufreq.SimpleScalingDriver import org.opendc.simulator.compute.model.MemoryUnit import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.power.PowerModel +import org.opendc.simulator.compute.power.SimplePowerDriver import org.opendc.simulator.compute.workload.SimWorkload -import org.opendc.simulator.resources.SimResourceCommand -import org.opendc.simulator.resources.SimResourceConsumer -import org.opendc.simulator.resources.SimResourceContext -import org.opendc.simulator.resources.SimResourceEvent +import org.opendc.simulator.resources.* import java.time.Clock import java.util.* import kotlin.coroutines.Continuation @@ -67,8 +63,8 @@ public class SimTFDevice( * The [SimMachine] representing the device. */ private val machine = SimBareMetalMachine( - scope.coroutineContext, clock, SimMachineModel(listOf(pu), listOf(memory)), - PerformanceScalingGovernor(), SimpleScalingDriver(powerModel) + SimResourceInterpreter(scope.coroutineContext, clock), SimMachineModel(listOf(pu), listOf(memory)), + SimplePowerDriver(powerModel) ) /** @@ -119,9 +115,11 @@ public class SimTFDevice( */ private var activeWork: Work? = null - override fun onStart(ctx: SimMachineContext) {} - - override fun getConsumer(ctx: SimMachineContext, cpu: ProcessingUnit): SimResourceConsumer = this + override fun onStart(ctx: SimMachineContext) { + for (cpu in ctx.cpus) { + cpu.startConsumer(this) + } + } override fun onNext(ctx: SimResourceContext): SimResourceCommand { val activeWork = activeWork |
