summaryrefslogtreecommitdiff
path: root/opendc-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-09-19 14:33:05 +0200
committerGitHub <noreply@github.com>2021-09-19 14:33:05 +0200
commit453c25c4b453fa0af26bebbd8863abfb79218119 (patch)
tree7977e81ec34ce7f57d8b14a717ccb63f54cd03cb /opendc-simulator
parentc1b9719aad10566c9d17f9eb757236c58a602b89 (diff)
parent76a0f8889a4990108bc7906556dec6381647404b (diff)
merge: Enable re-use of virtual machine workload helpers
This pull request enables re-use of virtual machine workload helpers by extracting the helpers into a separate module which may be used by other experiments. - Support workload/machine CPU count mismatch - Extract common code out of Capelin experiments - Support flexible topology creation - Add option for optimizing SimHost simulation - Support creating CPU-optimized topology - Make workload sampling model extensible - Add support for extended Bitbrains trace format - Add support for Azure VM trace format - Add support for internal OpenDC VM trace format - Optimize OpenDC VM trace format - Add tool for converting workload traces - Remove dependency on SnakeYaml **Breaking API Changes** - `RESOURCE_NCPU` and `RESOURCE_STATE_NCPU` are renamed to `RESOURCE_CPU_COUNT` and `RESOURCE_STATE_CPU_COUNT` respectively.
Diffstat (limited to 'opendc-simulator')
-rw-r--r--opendc-simulator/opendc-simulator-compute/build.gradle.kts1
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt13
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt6
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt3
4 files changed, 6 insertions, 17 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/build.gradle.kts b/opendc-simulator/opendc-simulator-compute/build.gradle.kts
index 74384480..7d06ee62 100644
--- a/opendc-simulator/opendc-simulator-compute/build.gradle.kts
+++ b/opendc-simulator/opendc-simulator-compute/build.gradle.kts
@@ -36,5 +36,4 @@ dependencies {
api(projects.opendcSimulator.opendcSimulatorNetwork)
implementation(projects.opendcSimulator.opendcSimulatorCore)
implementation(projects.opendcUtils)
- implementation(libs.yaml)
}
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt
index 0c995f06..2694700c 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/power/InterpolationPowerModel.kt
@@ -22,7 +22,6 @@
package org.opendc.simulator.compute.power
-import org.yaml.snakeyaml.Yaml
import kotlin.math.ceil
import kotlin.math.floor
import kotlin.math.max
@@ -37,8 +36,6 @@ import kotlin.math.min
* @see <a href="http://www.spec.org/power_ssj2008/results/res2011q1/">Machines used in the SPEC benchmark</a>
*/
public class InterpolationPowerModel(private val powerValues: List<Double>) : PowerModel {
- public constructor(hardwareName: String) : this(loadAveragePowerValue(hardwareName))
-
public override fun computePower(utilization: Double): Double {
val clampedUtilization = min(1.0, max(0.0, utilization))
val utilizationFlr = floor(clampedUtilization * 10).toInt()
@@ -63,14 +60,4 @@ public class InterpolationPowerModel(private val powerValues: List<Double>) : Po
* @return the power consumption for the given utilization percentage
*/
private fun getAveragePowerValue(index: Int): Double = powerValues[index]
-
- private companion object {
- private fun loadAveragePowerValue(hardwareName: String, path: String = "spec_machines.yml"): List<Double> {
- val content = this::class
- .java.classLoader
- .getResourceAsStream(path)
- val hardwareToAveragePowerValues: Map<String, List<Double>> = Yaml().load(content)
- return hardwareToAveragePowerValues.getOrDefault(hardwareName, listOf())
- }
- }
}
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
index 48be8e1a..5a4c4f44 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
@@ -27,6 +27,7 @@ import org.opendc.simulator.compute.model.ProcessingUnit
import org.opendc.simulator.resources.SimResourceCommand
import org.opendc.simulator.resources.SimResourceConsumer
import org.opendc.simulator.resources.SimResourceContext
+import kotlin.math.min
/**
* A [SimWorkload] that replays a workload trace consisting of multiple fragments, each indicating the resource
@@ -89,15 +90,16 @@ public class SimTraceWorkload(public val trace: Sequence<Fragment>, private val
return SimResourceCommand.Idle(timestamp)
}
+ val cores = min(cpu.node.coreCount, fragment.cores)
val usage = if (fragment.cores > 0)
- fragment.usage / fragment.cores
+ fragment.usage / cores
else
0.0
val deadline = timestamp + fragment.duration
val duration = deadline - now
val work = duration * usage / 1000
- return if (cpu.id < fragment.cores && work > 0.0)
+ return if (cpu.id < cores && work > 0.0)
SimResourceCommand.Consume(work, usage, deadline)
else
SimResourceCommand.Idle(deadline)
diff --git a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt
index ac2ed303..7852534a 100644
--- a/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/test/kotlin/org/opendc/simulator/compute/power/PowerModelTest.kt
@@ -61,7 +61,8 @@ internal class PowerModelTest {
@Test
fun `compute power draw by the SPEC benchmark model`() {
- val powerModel = InterpolationPowerModel("IBMx3550M3_XeonX5675")
+ val ibm = listOf(58.4, 98.0, 109.0, 118.0, 128.0, 140.0, 153.0, 170.0, 189.0, 205.0, 222.0)
+ val powerModel = InterpolationPowerModel(ibm)
assertAll(
{ assertEquals(58.4, powerModel.computePower(0.0)) },