summaryrefslogtreecommitdiff
path: root/opendc-experiments
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-06-03 14:03:12 +0200
committerGitHub <noreply@github.com>2021-06-03 14:03:12 +0200
commit1303fe97510fb7987746722b3261c696f523fbd5 (patch)
treed927dbd4c71a5ea6435f5994e8fa0bc90ef19b2c /opendc-experiments
parentae987fa84b2e061eb9fdfec5561e1c976aaa5a54 (diff)
parentcef12722f03a24a0e1e3b7502fb5e434d93f1664 (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')
-rw-r--r--opendc-experiments/opendc-experiments-capelin/build.gradle.kts2
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt8
-rw-r--r--opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt18
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt20
4 files changed, 24 insertions, 24 deletions
diff --git a/opendc-experiments/opendc-experiments-capelin/build.gradle.kts b/opendc-experiments/opendc-experiments-capelin/build.gradle.kts
index 7c7f0dad..0dade513 100644
--- a/opendc-experiments/opendc-experiments-capelin/build.gradle.kts
+++ b/opendc-experiments/opendc-experiments-capelin/build.gradle.kts
@@ -48,4 +48,6 @@ dependencies {
exclude(group = "org.slf4j", module = "slf4j-log4j12")
exclude(group = "log4j")
}
+
+ testImplementation(libs.log4j.slf4j)
}
diff --git a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
index 2d5cc68c..4b21b4f7 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
@@ -113,8 +113,8 @@ class CapelinIntegrationTest {
{ assertEquals(0, monitorResults.runningVms, "All VMs should finish after a run") },
{ assertEquals(0, monitorResults.unscheduledVms, "No VM should not be unscheduled") },
{ assertEquals(0, monitorResults.queuedVms, "No VM should not be in the queue") },
- { assertEquals(207389912923, monitor.totalRequestedBurst) { "Incorrect requested burst" } },
- { assertEquals(207122087280, monitor.totalGrantedBurst) { "Incorrect granted burst" } },
+ { assertEquals(207380244590, monitor.totalRequestedBurst) { "Incorrect requested burst" } },
+ { assertEquals(207112418950, monitor.totalGrantedBurst) { "Incorrect granted burst" } },
{ assertEquals(267825640, monitor.totalOvercommissionedBurst) { "Incorrect overcommitted burst" } },
{ assertEquals(0, monitor.totalInterferedBurst) { "Incorrect interfered burst" } }
)
@@ -150,8 +150,8 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(96350072517, monitor.totalRequestedBurst) { "Total requested work incorrect" } },
- { assertEquals(96330335057, monitor.totalGrantedBurst) { "Total granted work incorrect" } },
+ { assertEquals(96344616902, monitor.totalRequestedBurst) { "Total requested work incorrect" } },
+ { assertEquals(96324879442, monitor.totalGrantedBurst) { "Total granted work incorrect" } },
{ assertEquals(19737460, monitor.totalOvercommissionedBurst) { "Total overcommitted work incorrect" } },
{ assertEquals(0, monitor.totalInterferedBurst) { "Total interfered work incorrect" } }
)
diff --git a/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt b/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt
index 7460a1e7..37e10580 100644
--- a/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt
+++ b/opendc-experiments/opendc-experiments-energy21/src/main/kotlin/org/opendc/experiments/energy21/EnergyExperiment.kt
@@ -173,23 +173,23 @@ public class EnergyExperiment : Experiment("Energy Modeling 2021") {
*/
public enum class PowerModelType {
CUBIC {
- override val driver: ScalingDriver = SimpleScalingDriver(CubicPowerModel(206.0, 56.4))
+ override val driver: PowerDriver = SimplePowerDriver(CubicPowerModel(206.0, 56.4))
},
LINEAR {
- override val driver: ScalingDriver = SimpleScalingDriver(LinearPowerModel(206.0, 56.4))
+ override val driver: PowerDriver = SimplePowerDriver(LinearPowerModel(206.0, 56.4))
},
SQRT {
- override val driver: ScalingDriver = SimpleScalingDriver(SqrtPowerModel(206.0, 56.4))
+ override val driver: PowerDriver = SimplePowerDriver(SqrtPowerModel(206.0, 56.4))
},
SQUARE {
- override val driver: ScalingDriver = SimpleScalingDriver(SquarePowerModel(206.0, 56.4))
+ override val driver: PowerDriver = SimplePowerDriver(SquarePowerModel(206.0, 56.4))
},
INTERPOLATION {
- override val driver: ScalingDriver = SimpleScalingDriver(
+ override val driver: PowerDriver = SimplePowerDriver(
InterpolationPowerModel(
listOf(56.4, 100.0, 107.0, 117.0, 127.0, 138.0, 149.0, 162.0, 177.0, 191.0, 206.0)
)
@@ -197,17 +197,17 @@ public class EnergyExperiment : Experiment("Energy Modeling 2021") {
},
MSE {
- override val driver: ScalingDriver = SimpleScalingDriver(MsePowerModel(206.0, 56.4, 1.4))
+ override val driver: PowerDriver = SimplePowerDriver(MsePowerModel(206.0, 56.4, 1.4))
},
ASYMPTOTIC {
- override val driver: ScalingDriver = SimpleScalingDriver(AsymptoticPowerModel(206.0, 56.4, 0.3, false))
+ override val driver: PowerDriver = SimplePowerDriver(AsymptoticPowerModel(206.0, 56.4, 0.3, false))
},
ASYMPTOTIC_DVFS {
- override val driver: ScalingDriver = SimpleScalingDriver(AsymptoticPowerModel(206.0, 56.4, 0.3, true))
+ override val driver: PowerDriver = SimplePowerDriver(AsymptoticPowerModel(206.0, 56.4, 0.3, true))
};
- public abstract val driver: ScalingDriver
+ public abstract val driver: PowerDriver
}
}
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