diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-04-13 17:24:45 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-04-13 17:37:40 +0200 |
| commit | e9a5234cd22289b8358aa8b1f833a81391e4802c (patch) | |
| tree | 2d12104b10a91d8230f9293de6e8cbb84c5a94c0 /opendc/opendc-compute/src | |
| parent | 6e7c253cb61f2c529f6e852183c997d733ad864d (diff) | |
refactor: Make total burst calculation more reliable
Diffstat (limited to 'opendc/opendc-compute/src')
| -rw-r--r-- | opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt | 5 |
1 files changed, 2 insertions, 3 deletions
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 730d49f5..73f9dd5c 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 @@ -275,7 +275,7 @@ class SimpleVirtDriver( } // The total requested burst that the VMs wanted to run in the time-frame that we ran. - val totalRequestedSubBurst = min(totalRequestedBurst, ceil(totalRequestedUsage * duration).toLong()) + val totalRequestedSubBurst = requests.map { ceil((duration * 1000) / (it.vm.deadline - start) * it.burst).toLong() }.sum() val totalRemainder = burst.sum() val totalGrantedBurst = totalAllocatedBurst - totalRemainder @@ -307,7 +307,7 @@ class SimpleVirtDriver( totalInterferedBurst += grantedBurst - usedBurst // Compute remaining burst time to be executed for the request - req.burst = max(0, vm.burst[i] - grantedBurst) + req.burst = max(0, vm.burst[i] - usedBurst) vm.burst[i] = req.burst if (req.burst <= 0L || req.isCancelled) { @@ -449,7 +449,6 @@ class SimpleVirtDriver( override suspend fun run(burst: LongArray, limit: DoubleArray, deadline: Long) { require(burst.size == limit.size) { "Array dimensions do not match" } - this.deadline = deadline this.burst = burst val requests = cpus.asSequence() |
