diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-03-03 22:53:57 +0100 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-03-03 22:53:57 +0100 |
| commit | 5f5d54b6f1a96bc595f99f367bea54f1d852ec63 (patch) | |
| tree | fd3a2b12bf5b3841ded39930ad2d3b0c1336448b | |
| parent | b201a8e1a8a3a9199c0f38265bd1326f18d22722 (diff) | |
refactor: Rename maxUsage to limit
This change renames the `maxUsage` parameter to `limit` in order to
align terminology with other products/projects such as VMWare vSphere.
3 files changed, 18 insertions, 18 deletions
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/execution/ServerContext.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/execution/ServerContext.kt index 485fdcdf..b09a5a7d 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/execution/ServerContext.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/execution/ServerContext.kt @@ -57,12 +57,12 @@ public interface ServerContext { * After the method returns, [burst] will contain the remaining burst length for each of the cores (which may be * zero). * - * Both [burst] and [maxUsage] must be of the same size and in any other case the method will throw an + * Both [burst] and [limit] must be of the same size and in any other case the method will throw an * [IllegalArgumentException]. * * @param burst The burst time to request from each of the processor cores. - * @param maxUsage The maximum usage in terms of MHz that the processing core may use while running the burst. + * @param limit The maximum usage in terms of MHz that the processing core may use while running the burst. * @param deadline The instant at which this request needs to be fulfilled. */ - public suspend fun run(burst: LongArray, maxUsage: DoubleArray, deadline: Long) + public suspend fun run(burst: LongArray, limit: DoubleArray, deadline: Long) } diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt index 92338ca1..fcdc9363 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt @@ -167,8 +167,8 @@ public class SimpleBareMetalDriver( domain.launch { monitor.onUpdate(server, previousState) } } - override suspend fun run(burst: LongArray, maxUsage: DoubleArray, deadline: Long) { - require(burst.size == maxUsage.size) { "Array dimensions do not match" } + override suspend fun run(burst: LongArray, limit: DoubleArray, deadline: Long) { + require(burst.size == limit.size) { "Array dimensions do not match" } val start = simulationContext.clock.millis() var duration = max(0, deadline - start) @@ -176,7 +176,7 @@ public class SimpleBareMetalDriver( // Determine the duration of the first CPU to finish for (i in 0 until min(cpus.size, burst.size)) { val cpu = cpus[i] - val usage = min(maxUsage[i], cpu.frequency) * 1_000_000 // Usage from MHz to Hz + val usage = min(limit[i], cpu.frequency) * 1_000_000 // Usage from MHz to Hz val cpuDuration = ceil(burst[i] / usage * 1000).toLong() // Convert from seconds to milliseconds if (cpuDuration != 0L) { // We only wait for processor cores with a non-zero burst @@ -194,7 +194,7 @@ public class SimpleBareMetalDriver( // Write back the remaining burst time for (i in 0 until min(cpus.size, burst.size)) { - val usage = min(maxUsage[i], cpus[i].frequency) * 1_000_000 + val usage = min(limit[i], cpus[i].frequency) * 1_000_000 val granted = ceil((end - start) / 1000.0 * usage).toLong() burst[i] = max(0, burst[i] - granted) } diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt index 783a9138..3f358516 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt @@ -124,11 +124,11 @@ class HypervisorVirtDriver( val cpu = vm.cpus[i] // Limit each vCPU to at most an equal share of the host CPU - val actualUsage = min(vm.requestedUsage[i], cpu.frequency / vms.size) + val actualUsage = min(vm.limit[i], cpu.frequency / vms.size) // The duration that we want to run is that of the shortest request from a vCPU duration = min(duration, ceil(vm.requestedBurst[i] / (actualUsage * 1_000_000L)).toLong()) - deadline = min(deadline, vm.requestedDeadline) + deadline = min(deadline, vm.deadline) usage[i] += actualUsage } } @@ -140,7 +140,7 @@ class HypervisorVirtDriver( val cpu = vm.cpus[i] // Limit each vCPU to at most an equal share of the host CPU - val actualUsage = min(vm.requestedUsage[i], cpu.frequency / vms.size) + val actualUsage = min(vm.limit[i], cpu.frequency / vms.size) val actualBurst = (duration * actualUsage * 1_000_000L).toLong() burst[i] += actualBurst @@ -163,7 +163,7 @@ class HypervisorVirtDriver( val cpu = vm.cpus[i] // Limit each vCPU to at most an equal share of the host CPU - val actualUsage = min(vm.requestedUsage[i], cpu.frequency / vms.size) + val actualUsage = min(vm.limit[i], cpu.frequency / vms.size) val actualBurst = (duration * actualUsage * 1_000_000L).toLong() // Compute the fraction of compute time allocated to the VM @@ -176,7 +176,7 @@ class HypervisorVirtDriver( vm.requestedBurst[i] = max(0, vm.requestedBurst[i] - grantedBurst) } - if (vm.requestedBurst.any { it == 0L } || vm.requestedDeadline <= end) { + if (vm.requestedBurst.any { it == 0L } || vm.deadline <= end) { // Return vCPU `run` call: the requested burst was completed or deadline was exceeded vm.chan.send(Unit) } @@ -212,8 +212,8 @@ class HypervisorVirtDriver( ctx: SimulationContext ) : ServerManagementContext { lateinit var requestedBurst: LongArray - lateinit var requestedUsage: DoubleArray - var requestedDeadline: Long = 0L + lateinit var limit: DoubleArray + var deadline: Long = 0L var chan = Channel<Unit>(Channel.RENDEZVOUS) private var initialized: Boolean = false @@ -251,12 +251,12 @@ class HypervisorVirtDriver( monitors.forEach { it.onUpdate(vms.size, availableMemory) } } - override suspend fun run(burst: LongArray, maxUsage: DoubleArray, deadline: Long) { - require(burst.size == maxUsage.size) { "Array dimensions do not match" } + override suspend fun run(burst: LongArray, limit: DoubleArray, deadline: Long) { + require(burst.size == limit.size) { "Array dimensions do not match" } requestedBurst = burst - requestedUsage = maxUsage - requestedDeadline = deadline + this.limit = limit + this.deadline = deadline // Wait until the burst has been run or the coroutine is cancelled try { |
