From b1296f9b531b9a39bc6927f48a079dfcf840333e Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 13 Mar 2020 16:48:44 +0100 Subject: refactor: Change burst to MFLOps --- .../main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt | 2 +- .../com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt | 2 +- .../atlarge/opendc/compute/metal/driver/SimpleBareMetalDriver.kt | 6 +++--- .../opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt | 6 +++--- .../opendc/compute/virt/service/SimpleVirtProvisioningService.kt | 7 ------- .../opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt | 2 +- .../opendc/compute/virt/driver/hypervisor/HypervisorTest.kt | 4 ++-- .../kotlin/com/atlarge/opendc/format/trace/sc20/Sc20TraceReader.kt | 4 ++-- .../kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt | 2 +- 9 files changed, 14 insertions(+), 21 deletions(-) diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt index dbf6d824..ba148ee0 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/ProcessingUnit.kt @@ -29,7 +29,7 @@ package com.atlarge.opendc.compute.core * * @property node The processing node containing the CPU core. * @property id The identifier of the CPU core within the processing node. - * @property frequency The clock rate of the CPU. + * @property frequency The clock rate of the CPU in MHz. */ public data class ProcessingUnit( public val node: ProcessingNode, diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt index 27d8091a..107237ea 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/FlopsApplicationImage.kt @@ -38,7 +38,7 @@ import kotlin.math.min * @property uid The unique identifier of this image. * @property name The name of this image. * @property tags The tags attached to the image. - * @property flops The number of floating point operations to perform for this task. + * @property flops The number of floating point operations to perform for this task in MFLOPs. * @property cores The number of cores that the image is able to utilize. * @property utilization A model of the CPU utilization of the application. */ 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 cd3e9a48..c7dc74cf 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 @@ -199,10 +199,10 @@ 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(limit[i], cpu.frequency) * 1_000_000 // Usage from MHz to Hz + val usage = min(limit[i], cpu.frequency) val cpuDuration = ceil(burst[i] / usage * 1000).toLong() // Convert from seconds to milliseconds - totalUsage += usage / (cpu.frequency * 1_000_000) + totalUsage += usage / cpu.frequency if (cpuDuration != 0L) { // We only wait for processor cores with a non-zero burst duration = min(duration, cpuDuration) @@ -229,7 +229,7 @@ public class SimpleBareMetalDriver( // Write back the remaining burst time for (i in 0 until min(cpus.size, burst.size)) { - val usage = min(limit[i], cpus[i].frequency) * 1_000_000 + val usage = min(limit[i], cpus[i].frequency) 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 1f9c8a80..7cd48bc3 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 @@ -137,7 +137,7 @@ class HypervisorVirtDriver( availableUsage -= grantedUsage // The duration that we want to run is that of the shortest request from a vCPU - duration = min(duration, req.burst / (req.allocatedUsage * 1_000_000L)) + duration = min(duration, req.burst / req.allocatedUsage) deadline = min(deadline, req.vm.deadline) } @@ -153,7 +153,7 @@ class HypervisorVirtDriver( val grantedUsage = min(hostContext.cpus[i].frequency, availableShare) usage[i] = grantedUsage - burst[i] = (duration * grantedUsage * 1_000_000L).toLong() + burst[i] = (duration * grantedUsage).toLong() availableUsage -= grantedUsage } @@ -182,7 +182,7 @@ class HypervisorVirtDriver( val fraction = req.allocatedUsage / totalUsage // Derive the burst that was allocated to this vCPU - val allocatedBurst = ceil(duration * req.allocatedUsage * 1_000_000L).toLong() + val allocatedBurst = ceil(duration * req.allocatedUsage).toLong() // Compute the burst time that the VM was actually granted val grantedBurst = (performanceScore * (allocatedBurst - ceil(totalRemainder * fraction))).toLong() diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt index f036e370..17960186 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/service/SimpleVirtProvisioningService.kt @@ -43,11 +43,6 @@ class SimpleVirtProvisioningService( */ internal val activeImages: MutableSet = mutableSetOf() - /** - * The images hosted on each server. - */ - internal val imagesByServer: MutableMap> = mutableMapOf() - init { ctx.domain.launch { val provisionedNodes = provisioningService.nodes().toList() @@ -101,8 +96,6 @@ class SimpleVirtProvisioningService( imageInstance.flavor ) activeImages += imageInstance - imagesByServer.putIfAbsent(imageInstance.server!!, mutableSetOf()) - imagesByServer[imageInstance.server!!]!!.add(imageInstance) } catch (e: InsufficientMemoryOnServerException) { println("Unable to deploy image due to insufficient memory") } diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt index f3796028..b8882eda 100644 --- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt +++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/metal/driver/SimpleBareMetalDriverTest.kt @@ -63,7 +63,7 @@ internal class SimpleBareMetalDriverTest { finalState = server.state } } - val image = FlopsApplicationImage(UUID.randomUUID(), "", emptyMap(), 1_000_000_000, 2) + val image = FlopsApplicationImage(UUID.randomUUID(), "", emptyMap(), 1_000, 2) // Batch driver commands withContext(dom.coroutineContext) { diff --git a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt index adc476a7..254ad5fe 100644 --- a/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt +++ b/opendc/opendc-compute/src/test/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorTest.kt @@ -69,8 +69,8 @@ internal class HypervisorTest { println("Hello World!") } }) - val workloadA = FlopsApplicationImage(UUID.randomUUID(), "", emptyMap(), 1_000_000_000, 1) - val workloadB = FlopsApplicationImage(UUID.randomUUID(), "", emptyMap(), 2_000_000_000, 1) + val workloadA = FlopsApplicationImage(UUID.randomUUID(), "", emptyMap(), 1_000, 1) + val workloadB = FlopsApplicationImage(UUID.randomUUID(), "", emptyMap(), 2_000, 1) val monitor = object : ServerMonitor { override suspend fun onUpdate(server: Server, previousState: ServerState) { println("[${simulationContext.clock.millis()}]: $server") diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20TraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20TraceReader.kt index 498f147f..3c974e44 100644 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20TraceReader.kt +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20TraceReader.kt @@ -98,9 +98,9 @@ class Sc20TraceReader( val timestamp = (values[timestampCol].trim().toLong() - 5 * 60) * 1000L cores = values[coreCol].trim().toInt() val cpuUsage = values[cpuUsageCol].trim().toDouble() // MHz - requiredMemory = (values[provisionedMemoryCol].trim().toDouble() / 1000).toLong() + requiredMemory = values[provisionedMemoryCol].trim().toLong() - val flops: Long = (cpuUsage * 1_000_000L * 5 * 60 * cores).toLong() + val flops: Long = (cpuUsage * 5 * 60 * cores).toLong() if (flopsHistory.isEmpty()) { flopsHistory.add(FlopsHistoryFragment(timestamp, flops, traceInterval, cpuUsage)) diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt index b4964b26..d001687c 100644 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt @@ -98,7 +98,7 @@ class VmTraceReader( val cpuUsage = values[cpuUsageCol].trim().toDouble() // MHz requiredMemory = (values[provisionedMemoryCol].trim().toDouble() / 1000).toLong() - val flops: Long = (cpuUsage * 1_000_000L * 5 * 60 * cores).toLong() + val flops: Long = (cpuUsage * 5 * 60 * cores).toLong() if (flopsHistory.isEmpty()) { flopsHistory.add(FlopsHistoryFragment(timestamp, flops, traceInterval, cpuUsage)) -- cgit v1.2.3 From 04bf648ce13f36a39e7ca6b41f4fbab281bb9392 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 13 Mar 2020 17:08:34 +0100 Subject: bug: Write deployed images only once --- .../kotlin/com/atlarge/opendc/experiments/sc20/Sc20HypervisorMonitor.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20HypervisorMonitor.kt b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20HypervisorMonitor.kt index 90874ea3..9e8f0fa8 100644 --- a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20HypervisorMonitor.kt +++ b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20HypervisorMonitor.kt @@ -29,7 +29,7 @@ class Sc20HypervisorMonitor( val usage = driver.usage.first() val powerDraw = driver.powerDraw.first() - outputFile.write("$time,$requestedBurst,$grantedBurst,$numberOfDeployedImages,$numberOfDeployedImages,${hostServer.uid},$usage,$powerDraw") + outputFile.write("$time,$requestedBurst,$grantedBurst,$numberOfDeployedImages,${hostServer.uid},$usage,$powerDraw") outputFile.newLine() } -- cgit v1.2.3