summaryrefslogtreecommitdiff
path: root/simulator/opendc-simulator
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-03 17:41:59 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-10-04 16:35:21 +0200
commit136c1b9ddc7bd9331d3552d681e9190fc6198271 (patch)
tree19a04e730d93969542f726084444b9e7f13a7b8d /simulator/opendc-simulator
parentc8567a567348e13c341bf1a1ec64ed34ce25815a (diff)
Migrate codebase to opendc-simulator-compute
This change updates the remainder of the codebase to use the opendc-simulator-compute module for the simulation of workloads.
Diffstat (limited to 'simulator/opendc-simulator')
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt14
-rw-r--r--simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/workload/SimTraceWorkload.kt2
2 files changed, 10 insertions, 6 deletions
diff --git a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt
index 7c2cfbe3..55eda70f 100644
--- a/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt
+++ b/simulator/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimHypervisor.kt
@@ -103,14 +103,15 @@ public class SimHypervisor(
* Run the scheduling process of the hypervisor.
*/
override suspend fun run(ctx: SimExecutionContext) {
- val maxUsage = ctx.machine.cpus.sumByDouble { it.frequency }
- val pCPUs = ctx.machine.cpus.indices.sortedBy { ctx.machine.cpus[it].frequency }
+ val model = ctx.machine
+ val maxUsage = model.cpus.sumByDouble { it.frequency }
+ val pCPUs = model.cpus.indices.sortedBy { model.cpus[it].frequency }
val vms = mutableSetOf<VmSession>()
val vcpus = mutableListOf<VCpu>()
- val usage = DoubleArray(ctx.machine.cpus.size)
- val burst = LongArray(ctx.machine.cpus.size)
+ val usage = DoubleArray(model.cpus.size)
+ val burst = LongArray(model.cpus.size)
fun process(command: SchedulerCommand) {
when (command) {
@@ -180,13 +181,16 @@ public class SimHypervisor(
duration = min(duration, req.burst / grantedUsage)
}
+ // XXX We set the minimum duration to 5 minutes here to prevent the rounding issues that are occurring with the FLOPs.
+ duration = 300.0
+
val totalAllocatedUsage = maxUsage - availableUsage
var totalAllocatedBurst = 0L
availableUsage = totalAllocatedUsage
// Divide the requests over the available capacity of the pCPUs fairly
for (i in pCPUs) {
- val maxCpuUsage = ctx.machine.cpus[i].frequency
+ val maxCpuUsage = model.cpus[i].frequency
val fraction = maxCpuUsage / maxUsage
val grantedUsage = min(maxCpuUsage, totalAllocatedUsage * fraction)
val grantedBurst = ceil(duration * grantedUsage).toLong()
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 e7eaa8bf..7b1ddf32 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
@@ -29,7 +29,7 @@ import kotlin.math.min
* A [SimWorkload] that replays a workload trace consisting of multiple fragments, each indicating the resource
* consumption for some period of time.
*/
-public class SimTraceWorkload(private val trace: Sequence<Fragment>) : SimWorkload {
+public class SimTraceWorkload(public val trace: Sequence<Fragment>) : SimWorkload {
override suspend fun run(ctx: SimExecutionContext) {
var offset = ctx.clock.millis()