summaryrefslogtreecommitdiff
path: root/simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-08 11:47:01 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-08 11:48:57 +0200
commit41ad2f2950550fcd95a599bd8869aa191c88396a (patch)
tree5d9bf52b5b93dddb92ad7e2ea29b0af08147113d /simulator
parent2ed3ad44885c93287d4ef9c7996db73f1d49d62d (diff)
simulator: Divide CPU usage over all cores
This change fixes an issue in SimTraceWorkload where the CPU usage was not divided across the cores, but was instead requested for all cores.
Diffstat (limited to 'simulator')
-rw-r--r--simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt12
-rw-r--r--simulator/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt12
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt5
3 files changed, 15 insertions, 14 deletions
diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
index 830fc868..2a897b28 100644
--- a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
+++ b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt
@@ -94,10 +94,10 @@ internal class SimHostTest {
mapOf(
"workload" to SimTraceWorkload(
sequenceOf(
- SimTraceWorkload.Fragment(duration * 1000, 28.0, 2),
- SimTraceWorkload.Fragment(duration * 1000, 3500.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 2 * 28.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 2 * 3500.0, 2),
SimTraceWorkload.Fragment(duration * 1000, 0.0, 2),
- SimTraceWorkload.Fragment(duration * 1000, 183.0, 2)
+ SimTraceWorkload.Fragment(duration * 1000, 2 * 183.0, 2)
),
)
)
@@ -109,10 +109,10 @@ internal class SimHostTest {
mapOf(
"workload" to SimTraceWorkload(
sequenceOf(
- SimTraceWorkload.Fragment(duration * 1000, 28.0, 2),
- SimTraceWorkload.Fragment(duration * 1000, 3100.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 2 * 28.0, 2),
+ SimTraceWorkload.Fragment(duration * 1000, 2 * 3100.0, 2),
SimTraceWorkload.Fragment(duration * 1000, 0.0, 2),
- SimTraceWorkload.Fragment(duration * 1000, 73.0, 2)
+ SimTraceWorkload.Fragment(duration * 1000, 2 * 73.0, 2)
)
)
)
diff --git a/simulator/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt b/simulator/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
index bc639765..9a620fb2 100644
--- a/simulator/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
+++ b/simulator/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
@@ -118,9 +118,9 @@ 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(1672916917970, monitor.totalRequestedBurst) { "Incorrect requested burst" } },
- { assertEquals(434262255818, monitor.totalGrantedBurst) { "Incorrect granted burst" } },
- { assertEquals(1236692477983, monitor.totalOvercommissionedBurst) { "Incorrect overcommitted burst" } },
+ { assertEquals(207629398281, monitor.totalRequestedBurst) { "Incorrect requested burst" } },
+ { assertEquals(204986447775, monitor.totalGrantedBurst) { "Incorrect granted burst" } },
+ { assertEquals(2642950497, monitor.totalOvercommissionedBurst) { "Incorrect overcommitted burst" } },
{ assertEquals(0, monitor.totalInterferedBurst) { "Incorrect interfered burst" } }
)
}
@@ -156,9 +156,9 @@ class CapelinIntegrationTest {
// Note that these values have been verified beforehand
assertAll(
- { assertEquals(702636229989, monitor.totalRequestedBurst) { "Total requested work incorrect" } },
- { assertEquals(172636987071, monitor.totalGrantedBurst) { "Total granted work incorrect" } },
- { assertEquals(528959213229, monitor.totalOvercommissionedBurst) { "Total overcommitted work incorrect" } },
+ { assertEquals(96538919775, monitor.totalRequestedBurst) { "Total requested work incorrect" } },
+ { assertEquals(96519182315, 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/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
index 2442d748..694a928b 100644
--- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
+++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt
@@ -50,14 +50,15 @@ public class SimTraceWorkload(public val trace: Sequence<Fragment>) : SimWorkloa
override fun onNext(ctx: SimResourceContext): SimResourceCommand {
val now = ctx.clock.millis()
val fragment = fragment ?: return SimResourceCommand.Exit
- val work = (fragment.duration / 1000) * fragment.usage
+ val usage = fragment.usage / fragment.cores
+ val work = (fragment.duration / 1000) * usage
val deadline = offset + fragment.duration
assert(deadline >= now) { "Deadline already passed" }
val cmd =
if (cpu.id < fragment.cores && work > 0.0)
- SimResourceCommand.Consume(work, fragment.usage, deadline)
+ SimResourceCommand.Consume(work, usage, deadline)
else
SimResourceCommand.Idle(deadline)