summaryrefslogtreecommitdiff
path: root/opendc
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-04-12 13:59:00 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-04-12 13:59:00 +0200
commit8d4d552e706ad5c5adebc774920337b4f201ac1f (patch)
treedb0332a19de49d5e4580bfd4f0ddfbc2ab887f18 /opendc
parent5f141c8b6aa6cfe96333f0cc02015e490b90fca6 (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')
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/core/image/VmImage.kt2
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/HypervisorEvent.kt4
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt20
-rw-r--r--opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20Monitor.kt8
-rw-r--r--opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt2
-rw-r--r--opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20TraceReader.kt16
6 files changed, 32 insertions, 20 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
)
diff --git a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20Monitor.kt b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20Monitor.kt
index c0d6de03..245aa250 100644
--- a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20Monitor.kt
+++ b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/Sc20Monitor.kt
@@ -17,7 +17,7 @@ class Sc20Monitor(
private val lastServerStates = mutableMapOf<Server, Pair<ServerState, Long>>()
init {
- outputFile.write("time,duration,requestedBurst,grantedBurst,overcommissionedBurst,interferedBurst,numberOfDeployedImages,server,hostState,hostUsage,powerDraw,failedVms\n")
+ outputFile.write("time,duration,requestedBurst,grantedBurst,overcommissionedBurst,interferedBurst,cpuUsage,cpuDemand,numberOfDeployedImages,server,hostState,hostUsage,powerDraw,failedVms\n")
}
suspend fun onVmStateChanged(server: Server) {}
@@ -32,6 +32,8 @@ class Sc20Monitor(
0,
0,
0,
+ 0.0,
+ 0.0,
0,
server,
duration
@@ -49,6 +51,8 @@ class Sc20Monitor(
grantedBurst: Long,
overcommissionedBurst: Long,
interferedBurst: Long,
+ cpuUsage: Double,
+ cpuDemand: Double,
numberOfDeployedImages: Int,
hostServer: Server,
duration: Long = 5 * 60 * 1000L
@@ -60,7 +64,7 @@ class Sc20Monitor(
val usage = driver.usage.first()
val powerDraw = driver.powerDraw.first()
- outputFile.write("$time,$duration,$requestedBurst,$grantedBurst,$overcommissionedBurst,$interferedBurst,$numberOfDeployedImages,${hostServer.uid},${hostServer.state},$usage,$powerDraw")
+ outputFile.write("$time,$duration,$requestedBurst,$grantedBurst,$overcommissionedBurst,$interferedBurst,$cpuUsage,$cpuDemand,$numberOfDeployedImages,${hostServer.uid},${hostServer.state},$usage,$powerDraw")
outputFile.newLine()
}
diff --git a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt
index ede18b40..c75bde30 100644
--- a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt
+++ b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt
@@ -201,6 +201,8 @@ fun main(args: Array<String>) {
event.grantedBurst,
event.overcommissionedBurst,
event.interferedBurst,
+ event.cpuUsage,
+ event.cpuDemand,
event.numberOfDeployedImages,
event.hostServer
)
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 776cbc4e..3688864f 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
@@ -36,6 +36,7 @@ import java.io.BufferedReader
import java.io.File
import java.io.FileReader
import java.util.UUID
+import kotlin.math.max
/**
* A [TraceReader] for the internal VM workload trace format.
@@ -82,7 +83,7 @@ class Sc20TraceReader(
println(vmFile)
val flopsHistory = mutableListOf<FlopsHistoryFragment>()
var vmId = ""
- var cores = -1
+ var maxCores = -1
var requiredMemory = -1L
BufferedReader(FileReader(vmFile)).use { reader ->
@@ -96,11 +97,13 @@ class Sc20TraceReader(
vmId = vmFile.name
val timestamp = (values[timestampCol].trim().toLong() - 5 * 60) * 1000L
- cores = values[coreCol].trim().toInt()
+ val cores = values[coreCol].trim().toInt()
val cpuUsage = values[cpuUsageCol].trim().toDouble() // MHz
- requiredMemory = values[provisionedMemoryCol].trim().toLong()
+ requiredMemory = max(requiredMemory, values[provisionedMemoryCol].trim().toLong())
+ maxCores = max(maxCores, cores)
+
+ val flops: Long = (cpuUsage * 5 * 60).toLong()
- val flops: Long = (cpuUsage * 5 * 60 * cores).toLong()
if (flopsHistory.isEmpty()) {
flopsHistory.add(FlopsHistoryFragment(timestamp, flops, traceInterval, cpuUsage, cores))
@@ -115,8 +118,7 @@ class Sc20TraceReader(
oldFragment.flops + flops,
oldFragment.duration + traceInterval,
cpuUsage,
- cores
- )
+ cores)
)
}
}
@@ -136,7 +138,7 @@ class Sc20TraceReader(
vmId,
mapOf(IMAGE_PERF_INTERFERENCE_MODEL to relevantPerformanceInterferenceModelItems),
flopsHistory,
- cores,
+ maxCores,
requiredMemory
)
)