summaryrefslogtreecommitdiff
path: root/opendc-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-08-24 13:15:26 +0200
committerGitHub <noreply@github.com>2021-08-24 13:15:26 +0200
commitac48fa12f36180de31154a7c828b4dc281dac94b (patch)
tree3a1117b62e627094ea2859a8b1cb910ef7046851 /opendc-simulator
parent51515bb255b3b32ca3020419a0c84130a4d8d370 (diff)
parent5266ecd476a18f601cb4eb6166f4c8338c440210 (diff)
merge: Add tests for interference and failures in Capelin
This pull request updates the Capelin experiments to test for interference and failure scenarios. This allows us to track regressions in these subsystems more easily. * Clean up Bitbrains trace reader to enable re-use * Keep trace order after sampling * Update Bitbrains trace tests * Add support for reporting interfered work * Add support for SimHost failure * Add tests for interference and failures
Diffstat (limited to 'opendc-simulator')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt4
-rw-r--r--opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceDistributorMaxMin.kt36
-rw-r--r--opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceSwitchMaxMin.kt2
3 files changed, 36 insertions, 6 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt
index 17130d34..c31b1f6b 100644
--- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt
+++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/kernel/SimFairShareHypervisor.kt
@@ -67,6 +67,7 @@ public class SimFairShareHypervisor(
private var lastDemand = 0.0
private var lastActual = 0.0
private var lastOvercommit = 0.0
+ private var lastInterference = 0.0
private var lastReport = Long.MIN_VALUE
override fun onConverge(timestamp: Long) {
@@ -79,7 +80,7 @@ public class SimFairShareHypervisor(
(counters.demand - lastDemand).toLong(),
(counters.actual - lastActual).toLong(),
(counters.overcommit - lastOvercommit).toLong(),
- 0L,
+ (counters.interference - lastInterference).toLong(),
lastCpuUsage,
lastCpuDemand
)
@@ -91,6 +92,7 @@ public class SimFairShareHypervisor(
lastDemand = counters.demand
lastActual = counters.actual
lastOvercommit = counters.overcommit
+ lastInterference = counters.interference
val load = lastCpuDemand / ctx.cpus.sumOf { it.model.frequency }
triggerGovernors(load)
diff --git a/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceDistributorMaxMin.kt b/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceDistributorMaxMin.kt
index a985986d..6c1e134b 100644
--- a/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceDistributorMaxMin.kt
+++ b/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceDistributorMaxMin.kt
@@ -22,9 +22,9 @@
package org.opendc.simulator.resources
-import org.opendc.simulator.resources.impl.SimResourceCountersImpl
import org.opendc.simulator.resources.interference.InterferenceDomain
import org.opendc.simulator.resources.interference.InterferenceKey
+import kotlin.math.max
import kotlin.math.min
/**
@@ -71,9 +71,23 @@ public class SimResourceDistributorMaxMin(
/**
* The resource counters of this distributor.
*/
- public val counters: SimResourceCounters
+ public val counters: Counters
get() = _counters
- private val _counters = SimResourceCountersImpl()
+ private val _counters = object : Counters {
+ override var demand: Double = 0.0
+ override var actual: Double = 0.0
+ override var overcommit: Double = 0.0
+ override var interference: Double = 0.0
+
+ override fun reset() {
+ demand = 0.0
+ actual = 0.0
+ overcommit = 0.0
+ interference = 0.0
+ }
+
+ override fun toString(): String = "SimResourceDistributorMaxMin.Counters[demand=$demand,actual=$actual,overcommit=$overcommit,interference=$interference]"
+ }
/* SimResourceDistributor */
override fun newOutput(key: InterferenceKey?): SimResourceCloseableProvider {
@@ -111,6 +125,16 @@ public class SimResourceDistributorMaxMin(
}
/**
+ * Extended [SimResourceCounters] interface for the distributor.
+ */
+ public interface Counters : SimResourceCounters {
+ /**
+ * The amount of work lost due to interference.
+ */
+ public val interference: Double
+ }
+
+ /**
* Update the counters of the distributor.
*/
private fun updateCounters(ctx: SimResourceControllableContext, work: Double, willOvercommit: Boolean) {
@@ -326,7 +350,11 @@ public class SimResourceDistributorMaxMin(
}
// Compute the work that was actually granted to the output.
- return (totalAllocatedWork - totalRemainingWork) * fraction * perfScore
+ val potentialConsumedWork = (totalAllocatedWork - totalRemainingWork) * fraction
+
+ _counters.interference += potentialConsumedWork * max(0.0, 1 - perfScore)
+
+ return potentialConsumedWork
}
/* Comparable */
diff --git a/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceSwitchMaxMin.kt b/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceSwitchMaxMin.kt
index d988b70d..e368609f 100644
--- a/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceSwitchMaxMin.kt
+++ b/opendc-simulator/opendc-simulator-resources/src/main/kotlin/org/opendc/simulator/resources/SimResourceSwitchMaxMin.kt
@@ -53,7 +53,7 @@ public class SimResourceSwitchMaxMin(
/**
* The resource counters to track the execution metrics of all switch resources.
*/
- override val counters: SimResourceCounters
+ override val counters: SimResourceDistributorMaxMin.Counters
get() = distributor.counters
/**