diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-04-12 13:59:00 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-04-12 13:59:00 +0200 |
| commit | 8d4d552e706ad5c5adebc774920337b4f201ac1f (patch) | |
| tree | db0332a19de49d5e4580bfd4f0ddfbc2ab887f18 /opendc/opendc-compute/src | |
| parent | 5f141c8b6aa6cfe96333f0cc02015e490b90fca6 (diff) | |
bug: Fix invalid FLOPs value for trace fragments
This change fixes the invalid FLOPs values for the trace fragments which
were multiplied twice by the number of cores of the VM.
Diffstat (limited to 'opendc/opendc-compute/src')
3 files changed, 15 insertions, 11 deletions
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt index 9ad88c17..b2a01804 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt @@ -27,7 +27,7 @@ class VmImage( } else { val cores = min(fragment.cores, ctx.server.flavor.cpuCount) val burst = LongArray(cores) { fragment.flops / cores } - val usage = DoubleArray(cores) { fragment.usage } + val usage = DoubleArray(cores) { fragment.usage / cores } ctx.run(burst, usage, simulationContext.clock.millis() + fragment.duration) } diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorEvent.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorEvent.kt index 9ceb8bfc..7c088bc8 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorEvent.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorEvent.kt @@ -60,6 +60,8 @@ public sealed class HypervisorEvent { * it did not have the capacity. * @property interferedBurst The sum of CPU time that virtual machines could not utilize due to performance * interference. + * @property cpuUsage CPU use in megahertz. + * @property cpuDemand CPU demand in megahertz. * @property numberOfDeployedImages The number of images deployed on this hypervisor. */ public data class SliceFinished( @@ -68,6 +70,8 @@ public sealed class HypervisorEvent { public val grantedBurst: Long, public val overcommissionedBurst: Long, public val interferedBurst: Long, + public val cpuUsage: Double, + public val cpuDemand: Double, public val numberOfDeployedImages: Int, public val hostServer: Server ) : HypervisorEvent() diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt index 5f15084d..cec9ce53 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt @@ -246,14 +246,14 @@ class SimpleVirtDriver( // Divide the requests over the available capacity of the pCPUs fairly for (i in pCPUs) { - val remaining = hostContext.cpus.size - i - val availableShare = availableUsage / remaining - val grantedUsage = min(hostContext.cpus[i].frequency, availableShare) - val pBurst = ceil(duration * grantedUsage).toLong() + val maxCpuUsage = hostContext.cpus[i].frequency + val fraction = maxCpuUsage / maxUsage + val grantedUsage = min(maxCpuUsage, totalAllocatedUsage * fraction) + val grantedBurst = ceil(duration * grantedUsage).toLong() usage[i] = grantedUsage - burst[i] = pBurst - totalAllocatedBurst += pBurst + burst[i] = grantedBurst + totalAllocatedBurst += grantedBurst availableUsage -= grantedUsage } @@ -308,9 +308,7 @@ class SimpleVirtDriver( if (req.burst <= 0L || req.isCancelled) { hasFinished = true - } - - if (vm.deadline <= end && hostContext.server.state != ServerState.ERROR) { + } else if (vm.deadline <= end && hostContext.server.state != ServerState.ERROR) { // Request must have its entire burst consumed or otherwise we have overcommission // Note that we count the overcommissioned burst if the hypervisor has failed. totalOvercommissionedBurst += req.burst @@ -335,7 +333,9 @@ class SimpleVirtDriver( min(totalRequestedBurst, totalAllocatedBurst), min(totalRequestedBurst, totalGrantedBurst), // We can run more than requested due to timing totalOvercommissionedBurst, - totalInterferedBurst, // Might be smaller than zero due to FP rounding errors + totalInterferedBurst, // Might be smaller than zero due to FP rounding errors, + totalAllocatedUsage, + totalRequestedUsage, vmCount, // Some VMs might already have finished, so keep initial VM count server ) |
