diff options
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 ) |
