summaryrefslogtreecommitdiff
path: root/opendc-experiments
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-02-19 11:32:38 +0100
committerGitHub <noreply@github.com>2022-02-19 11:32:38 +0100
commita413367c039e1cbb640cbd7087068d78140b373f (patch)
tree3737158b657c8cb2f102621f90d7f5dedddaba77 /opendc-experiments
parent0cba027933e19254573f2488086db3e4660f93d2 (diff)
parent5a0821e19eed87e91054289051213cb60b4235b4 (diff)
merge: Backport generic changes from Radice branch
This pull request backports changes from the Radice branch that are not related to Radice itself. ## Implementation Notes :hammer_and_pick: * Adjust CPU capacity to number of vCPUs * Fix reporting of CPU time * Flush results before accessing counters * Move logger field out of class * Remove delta parameter from flow callbacks ## Breaking API Changes :warning: * `delta` parameter from callbacks in `FlowSource` is removed.
Diffstat (limited to 'opendc-experiments')
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt10
-rw-r--r--opendc-experiments/opendc-experiments-tf20/src/main/kotlin/org/opendc/experiments/tf20/core/SimTFDevice.kt15
2 files changed, 17 insertions, 8 deletions
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 aefd8304..891fc8be 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
@@ -117,7 +117,7 @@ class CapelinIntegrationTest {
{ assertEquals(0, serviceMetrics.serversActive, "All VMs should finish after a run") },
{ assertEquals(0, serviceMetrics.attemptsFailure, "No VM should be unscheduled") },
{ assertEquals(0, serviceMetrics.serversPending, "No VM should not be in the queue") },
- { assertEquals(223388307, this@CapelinIntegrationTest.exporter.idleTime) { "Incorrect idle time" } },
+ { assertEquals(223393683, this@CapelinIntegrationTest.exporter.idleTime) { "Incorrect idle time" } },
{ assertEquals(66977508, this@CapelinIntegrationTest.exporter.activeTime) { "Incorrect active time" } },
{ assertEquals(3160381, this@CapelinIntegrationTest.exporter.stealTime) { "Incorrect steal time" } },
{ assertEquals(0, this@CapelinIntegrationTest.exporter.lostTime) { "Incorrect lost time" } },
@@ -166,7 +166,7 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(10999208, this@CapelinIntegrationTest.exporter.idleTime) { "Idle time incorrect" } },
+ { assertEquals(10999592, this@CapelinIntegrationTest.exporter.idleTime) { "Idle time incorrect" } },
{ assertEquals(9741207, this@CapelinIntegrationTest.exporter.activeTime) { "Active time incorrect" } },
{ assertEquals(0, this@CapelinIntegrationTest.exporter.stealTime) { "Steal time incorrect" } },
{ assertEquals(0, this@CapelinIntegrationTest.exporter.lostTime) { "Lost time incorrect" } },
@@ -218,10 +218,10 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(6027666, this@CapelinIntegrationTest.exporter.idleTime) { "Idle time incorrect" } },
+ { assertEquals(6028050, this@CapelinIntegrationTest.exporter.idleTime) { "Idle time incorrect" } },
{ assertEquals(14712749, this@CapelinIntegrationTest.exporter.activeTime) { "Active time incorrect" } },
{ assertEquals(12532907, this@CapelinIntegrationTest.exporter.stealTime) { "Steal time incorrect" } },
- { assertEquals(468522, this@CapelinIntegrationTest.exporter.lostTime) { "Lost time incorrect" } }
+ { assertEquals(467963, this@CapelinIntegrationTest.exporter.lostTime) { "Lost time incorrect" } }
)
}
@@ -263,7 +263,7 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(10866961, exporter.idleTime) { "Idle time incorrect" } },
+ { assertEquals(10867345, exporter.idleTime) { "Idle time incorrect" } },
{ assertEquals(9607095, exporter.activeTime) { "Active time incorrect" } },
{ assertEquals(0, exporter.stealTime) { "Steal time incorrect" } },
{ assertEquals(0, exporter.lostTime) { "Lost time incorrect" } },
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 c751463d..5245261c 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
@@ -120,6 +120,11 @@ public class SimTFDevice(
*/
private var activeWork: Work? = null
+ /**
+ * The timestamp of the last pull.
+ */
+ private var lastPull: Long = 0L
+
override fun onStart(ctx: SimMachineContext) {
for (cpu in ctx.cpus) {
cpu.startConsumer(this)
@@ -131,11 +136,15 @@ public class SimTFDevice(
override fun onStart(conn: FlowConnection, now: Long) {
ctx = conn
capacity = conn.capacity
-
+ lastPull = now
conn.shouldSourceConverge = true
}
- override fun onPull(conn: FlowConnection, now: Long, delta: Long): Long {
+ override fun onPull(conn: FlowConnection, now: Long): Long {
+ val lastPull = lastPull
+ this.lastPull = now
+ val delta = (now - lastPull).coerceAtLeast(0)
+
val consumedWork = conn.rate * delta / 1000.0
capacity = conn.capacity
@@ -164,7 +173,7 @@ public class SimTFDevice(
}
}
- override fun onConverge(conn: FlowConnection, now: Long, delta: Long) {
+ override fun onConverge(conn: FlowConnection, now: Long) {
_usage.record(conn.rate)
_power.record(machine.psu.powerDraw)
}