summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostModel.kt9
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt2
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/HostView.kt2
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt2
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt40
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt40
-rw-r--r--opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/ComputeServiceTest.kt16
-rw-r--r--opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/scheduler/FilterSchedulerTest.kt65
-rw-r--r--opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt7
-rw-r--r--opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt13
-rw-r--r--opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadRunner.kt3
-rw-r--r--opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/VirtualMachine.kt4
12 files changed, 160 insertions, 43 deletions
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostModel.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostModel.kt
index fc092a3f..f3b94e3d 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostModel.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/driver/HostModel.kt
@@ -25,7 +25,12 @@ package org.opendc.compute.service.driver
/**
* Describes the static machine properties of the host.
*
+ * @property cpuCapacity The total CPU capacity of the host in MHz.
* @property cpuCount The number of logical processing cores available for this host.
- * @property memorySize The amount of memory available for this host in MB.
+ * @property memoryCapacity The amount of memory available for this host in MB.
*/
-public data class HostModel(public val cpuCount: Int, public val memorySize: Long)
+public data class HostModel(
+ public val cpuCapacity: Double,
+ public val cpuCount: Int,
+ public val memoryCapacity: Long
+)
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt
index 57e70fcd..2a07a208 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/ComputeServiceImpl.kt
@@ -298,7 +298,7 @@ internal class ComputeServiceImpl(
val hv = HostView(host)
maxCores = max(maxCores, host.model.cpuCount)
- maxMemory = max(maxMemory, host.model.memorySize)
+ maxMemory = max(maxMemory, host.model.memoryCapacity)
hostToView[host] = hv
if (host.state == HostState.UP) {
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/HostView.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/HostView.kt
index e2f33f11..0876209a 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/HostView.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/internal/HostView.kt
@@ -37,7 +37,7 @@ public class HostView(public val host: Host) {
get() = host.uid
public var instanceCount: Int = 0
- public var availableMemory: Long = host.model.memorySize
+ public var availableMemory: Long = host.model.memoryCapacity
public var provisionedCores: Int = 0
override fun toString(): String = "HostView[host=$host]"
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt
index a470a453..8a7a646c 100644
--- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/RamFilter.kt
@@ -34,7 +34,7 @@ public class RamFilter(private val allocationRatio: Double) : HostFilter {
override fun test(host: HostView, server: Server): Boolean {
val requested = server.flavor.memorySize
val available = host.availableMemory
- val total = host.host.model.memorySize
+ val total = host.host.model.memoryCapacity
// Do not allow an instance to overcommit against itself, only against
// other instances.
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt
new file mode 100644
index 00000000..791710c8
--- /dev/null
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.compute.service.scheduler.filters
+
+import org.opendc.compute.api.Server
+import org.opendc.compute.service.internal.HostView
+
+/**
+ * A [HostFilter] that filters hosts based on the vCPU speed requirements of a [Server] and the available
+ * capacity on the host.
+ */
+public class VCpuCapacityFilter : HostFilter {
+ override fun test(host: HostView, server: Server): Boolean {
+ val requiredCapacity = server.flavor.meta["cpu-capacity"] as? Double
+ val hostModel = host.host.model
+ val availableCapacity = hostModel.cpuCapacity / hostModel.cpuCount
+
+ return requiredCapacity == null || availableCapacity >= (requiredCapacity / server.flavor.cpuCount)
+ }
+}
diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt
new file mode 100644
index 00000000..a86226e2
--- /dev/null
+++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2021 AtLarge Research
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package org.opendc.compute.service.scheduler.weights
+
+import org.opendc.compute.api.Server
+import org.opendc.compute.service.internal.HostView
+
+/**
+ * A [HostWeigher] that weighs the hosts based on the difference required vCPU capacity and the available CPU capacity.
+ */
+public class VCpuCapacityWeigher(override val multiplier: Double = 1.0) : HostWeigher {
+
+ override fun getWeight(host: HostView, server: Server): Double {
+ val model = host.host.model
+ val requiredCapacity = server.flavor.meta["cpu-capacity"] as? Double ?: 0.0
+ return model.cpuCapacity / model.cpuCount - requiredCapacity / server.flavor.cpuCount
+ }
+
+ override fun toString(): String = "VCpuWeigher"
+}
diff --git a/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/ComputeServiceTest.kt b/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/ComputeServiceTest.kt
index 564f9493..7b8d0fe2 100644
--- a/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/ComputeServiceTest.kt
+++ b/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/ComputeServiceTest.kt
@@ -125,7 +125,7 @@ internal class ComputeServiceTest {
fun testAddHost() = scope.runBlockingSimulation {
val host = mockk<Host>(relaxUnitFun = true)
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.UP
assertEquals(0, service.hostCount)
@@ -147,7 +147,7 @@ internal class ComputeServiceTest {
fun testAddHostDouble() = scope.runBlockingSimulation {
val host = mockk<Host>(relaxUnitFun = true)
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.DOWN
assertEquals(0, service.hostCount)
@@ -216,7 +216,7 @@ internal class ComputeServiceTest {
fun testServerCannotFitOnHost() = scope.runBlockingSimulation {
val host = mockk<Host>(relaxUnitFun = true)
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.UP
every { host.canFit(any()) } returns false
@@ -241,7 +241,7 @@ internal class ComputeServiceTest {
val listeners = mutableListOf<HostListener>()
every { host.uid } returns UUID.randomUUID()
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.DOWN
every { host.addListener(any()) } answers { listeners.add(it.invocation.args[0] as HostListener) }
every { host.canFit(any()) } returns false
@@ -272,7 +272,7 @@ internal class ComputeServiceTest {
val listeners = mutableListOf<HostListener>()
every { host.uid } returns UUID.randomUUID()
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.UP
every { host.addListener(any()) } answers { listeners.add(it.invocation.args[0] as HostListener) }
every { host.canFit(any()) } returns false
@@ -303,7 +303,7 @@ internal class ComputeServiceTest {
val listeners = mutableListOf<HostListener>()
every { host.uid } returns UUID.randomUUID()
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.UP
every { host.canFit(any()) } returns true
every { host.addListener(any()) } answers { listeners.add(it.invocation.args[0] as HostListener) }
@@ -326,7 +326,7 @@ internal class ComputeServiceTest {
val listeners = mutableListOf<HostListener>()
every { host.uid } returns UUID.randomUUID()
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.UP
every { host.canFit(any()) } returns true
every { host.addListener(any()) } answers { listeners.add(it.invocation.args[0] as HostListener) }
@@ -369,7 +369,7 @@ internal class ComputeServiceTest {
val listeners = mutableListOf<HostListener>()
every { host.uid } returns UUID.randomUUID()
- every { host.model } returns HostModel(4, 2048)
+ every { host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.state } returns HostState.UP
every { host.canFit(any()) } returns true
every { host.addListener(any()) } answers { listeners.add(it.invocation.args[0] as HostListener) }
diff --git a/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/scheduler/FilterSchedulerTest.kt b/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/scheduler/FilterSchedulerTest.kt
index cafd4498..3f2ce43b 100644
--- a/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/scheduler/FilterSchedulerTest.kt
+++ b/opendc-compute/opendc-compute-service/src/test/kotlin/org/opendc/compute/service/scheduler/FilterSchedulerTest.kt
@@ -33,10 +33,7 @@ import org.opendc.compute.api.Server
import org.opendc.compute.service.driver.HostModel
import org.opendc.compute.service.driver.HostState
import org.opendc.compute.service.internal.HostView
-import org.opendc.compute.service.scheduler.filters.ComputeFilter
-import org.opendc.compute.service.scheduler.filters.InstanceCountFilter
-import org.opendc.compute.service.scheduler.filters.RamFilter
-import org.opendc.compute.service.scheduler.filters.VCpuFilter
+import org.opendc.compute.service.scheduler.filters.*
import org.opendc.compute.service.scheduler.weights.CoreRamWeigher
import org.opendc.compute.service.scheduler.weights.InstanceCountWeigher
import org.opendc.compute.service.scheduler.weights.RamWeigher
@@ -183,12 +180,12 @@ internal class FilterSchedulerTest {
val hostA = mockk<HostView>()
every { hostA.host.state } returns HostState.UP
- every { hostA.host.model } returns HostModel(4, 2048)
+ every { hostA.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostA.availableMemory } returns 512
val hostB = mockk<HostView>()
every { hostB.host.state } returns HostState.UP
- every { hostB.host.model } returns HostModel(4, 2048)
+ every { hostB.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostB.availableMemory } returns 2048
scheduler.addHost(hostA)
@@ -210,7 +207,7 @@ internal class FilterSchedulerTest {
val host = mockk<HostView>()
every { host.host.state } returns HostState.UP
- every { host.host.model } returns HostModel(4, 2048)
+ every { host.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.availableMemory } returns 2048
scheduler.addHost(host)
@@ -231,12 +228,12 @@ internal class FilterSchedulerTest {
val hostA = mockk<HostView>()
every { hostA.host.state } returns HostState.UP
- every { hostA.host.model } returns HostModel(4, 2048)
+ every { hostA.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostA.provisionedCores } returns 3
val hostB = mockk<HostView>()
every { hostB.host.state } returns HostState.UP
- every { hostB.host.model } returns HostModel(4, 2048)
+ every { hostB.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostB.provisionedCores } returns 0
scheduler.addHost(hostA)
@@ -258,7 +255,7 @@ internal class FilterSchedulerTest {
val host = mockk<HostView>()
every { host.host.state } returns HostState.UP
- every { host.host.model } returns HostModel(4, 2048)
+ every { host.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { host.provisionedCores } returns 0
scheduler.addHost(host)
@@ -271,6 +268,34 @@ internal class FilterSchedulerTest {
}
@Test
+ fun testVCpuCapacityFilter() {
+ val scheduler = FilterScheduler(
+ filters = listOf(VCpuCapacityFilter()),
+ weighers = emptyList(),
+ )
+
+ val hostA = mockk<HostView>()
+ every { hostA.host.state } returns HostState.UP
+ every { hostA.host.model } returns HostModel(8 * 2600.0, 8, 2048)
+ every { hostA.availableMemory } returns 512
+ scheduler.addHost(hostA)
+
+ val hostB = mockk<HostView>()
+ every { hostB.host.state } returns HostState.UP
+ every { hostB.host.model } returns HostModel(4 * 3200.0, 4, 2048)
+ every { hostB.availableMemory } returns 512
+
+ scheduler.addHost(hostB)
+
+ val server = mockk<Server>()
+ every { server.flavor.cpuCount } returns 2
+ every { server.flavor.memorySize } returns 1024
+ every { server.flavor.meta } returns mapOf("cpu-capacity" to 2 * 3200.0)
+
+ assertEquals(hostB, scheduler.select(server))
+ }
+
+ @Test
fun testInstanceCountFilter() {
val scheduler = FilterScheduler(
filters = listOf(InstanceCountFilter(limit = 2)),
@@ -279,12 +304,12 @@ internal class FilterSchedulerTest {
val hostA = mockk<HostView>()
every { hostA.host.state } returns HostState.UP
- every { hostA.host.model } returns HostModel(4, 2048)
+ every { hostA.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostA.instanceCount } returns 2
val hostB = mockk<HostView>()
every { hostB.host.state } returns HostState.UP
- every { hostB.host.model } returns HostModel(4, 2048)
+ every { hostB.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostB.instanceCount } returns 0
scheduler.addHost(hostA)
@@ -306,12 +331,12 @@ internal class FilterSchedulerTest {
val hostA = mockk<HostView>()
every { hostA.host.state } returns HostState.UP
- every { hostA.host.model } returns HostModel(4, 2048)
+ every { hostA.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostA.availableMemory } returns 1024
val hostB = mockk<HostView>()
every { hostB.host.state } returns HostState.UP
- every { hostB.host.model } returns HostModel(4, 2048)
+ every { hostB.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostB.availableMemory } returns 512
scheduler.addHost(hostA)
@@ -333,12 +358,12 @@ internal class FilterSchedulerTest {
val hostA = mockk<HostView>()
every { hostA.host.state } returns HostState.UP
- every { hostA.host.model } returns HostModel(12, 2048)
+ every { hostA.host.model } returns HostModel(12 * 2600.0, 12, 2048)
every { hostA.availableMemory } returns 1024
val hostB = mockk<HostView>()
every { hostB.host.state } returns HostState.UP
- every { hostB.host.model } returns HostModel(4, 2048)
+ every { hostB.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostB.availableMemory } returns 512
scheduler.addHost(hostA)
@@ -360,12 +385,12 @@ internal class FilterSchedulerTest {
val hostA = mockk<HostView>()
every { hostA.host.state } returns HostState.UP
- every { hostA.host.model } returns HostModel(4, 2048)
+ every { hostA.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostA.provisionedCores } returns 2
val hostB = mockk<HostView>()
every { hostB.host.state } returns HostState.UP
- every { hostB.host.model } returns HostModel(4, 2048)
+ every { hostB.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostB.provisionedCores } returns 0
scheduler.addHost(hostA)
@@ -387,12 +412,12 @@ internal class FilterSchedulerTest {
val hostA = mockk<HostView>()
every { hostA.host.state } returns HostState.UP
- every { hostA.host.model } returns HostModel(4, 2048)
+ every { hostA.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostA.instanceCount } returns 2
val hostB = mockk<HostView>()
every { hostB.host.state } returns HostState.UP
- every { hostB.host.model } returns HostModel(4, 2048)
+ every { hostB.host.model } returns HostModel(4 * 2600.0, 4, 2048)
every { hostB.instanceCount } returns 0
scheduler.addHost(hostA)
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
index b9d02185..10faeb5b 100644
--- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
+++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt
@@ -121,7 +121,7 @@ public class SimHost(
field = value
}
- override val model: HostModel = HostModel(model.cpus.size, model.memory.sumOf { it.size })
+ override val model: HostModel = HostModel(model.cpus.sumOf { it.frequency }, model.cpus.size, model.memory.sumOf { it.size })
/**
* The [GuestListener] that listens for guest events.
@@ -188,7 +188,7 @@ public class SimHost(
}
override fun canFit(server: Server): Boolean {
- val sufficientMemory = model.memorySize >= server.flavor.memorySize
+ val sufficientMemory = model.memoryCapacity >= server.flavor.memorySize
val enoughCpus = model.cpuCount >= server.flavor.cpuCount
val canFit = hypervisor.canFit(server.flavor.toMachineModel())
@@ -319,8 +319,9 @@ public class SimHost(
*/
private fun Flavor.toMachineModel(): MachineModel {
val originalCpu = machine.model.cpus[0]
+ val cpuCapacity = (this.meta["cpu-capacity"] as? Double ?: Double.MAX_VALUE).coerceAtMost(originalCpu.frequency)
val processingNode = originalCpu.node.copy(coreCount = cpuCount)
- val processingUnits = (0 until cpuCount).map { originalCpu.copy(id = it, node = processingNode) }
+ val processingUnits = (0 until cpuCount).map { originalCpu.copy(id = it, node = processingNode, frequency = cpuCapacity) }
val memoryUnits = listOf(MemoryUnit("Generic", "Generic", 3200.0, memorySize))
return MachineModel(processingUnits, memoryUnits).optimize()
diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt
index 1a6624f7..f23becda 100644
--- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt
+++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadLoader.kt
@@ -92,7 +92,8 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
val idCol = reader.resolve(RESOURCE_ID)
val startTimeCol = reader.resolve(RESOURCE_START_TIME)
val stopTimeCol = reader.resolve(RESOURCE_STOP_TIME)
- val coresCol = reader.resolve(RESOURCE_CPU_COUNT)
+ val cpuCountCol = reader.resolve(RESOURCE_CPU_COUNT)
+ val cpuCapacityCol = reader.resolve(RESOURCE_CPU_CAPACITY)
val memCol = reader.resolve(RESOURCE_MEM_CAPACITY)
var counter = 0
@@ -108,8 +109,9 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
val submissionTime = reader.get(startTimeCol) as Instant
val endTime = reader.get(stopTimeCol) as Instant
- val maxCores = reader.getInt(coresCol)
- val requiredMemory = reader.getDouble(memCol) / 1000.0 // Convert from KB to MB
+ val cpuCount = reader.getInt(cpuCountCol)
+ val cpuCapacity = reader.getDouble(cpuCapacityCol)
+ val memCapacity = reader.getDouble(memCol) / 1000.0 // Convert from KB to MB
val uid = UUID.nameUUIDFromBytes("$id-${counter++}".toByteArray())
val builder = fragments.getValue(id)
@@ -119,8 +121,9 @@ public class ComputeWorkloadLoader(private val baseDir: File) {
VirtualMachine(
uid,
id,
- maxCores,
- requiredMemory.roundToLong(),
+ cpuCount,
+ cpuCapacity,
+ memCapacity.roundToLong(),
totalLoad,
submissionTime,
endTime,
diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadRunner.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadRunner.kt
index 283f82fe..90ee56cb 100644
--- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadRunner.kt
+++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/ComputeWorkloadRunner.kt
@@ -128,7 +128,8 @@ public class ComputeWorkloadRunner(
client.newFlavor(
entry.name,
entry.cpuCount,
- entry.memCapacity
+ entry.memCapacity,
+ meta = if (entry.cpuCapacity > 0.0) mapOf("cpu-capacity" to entry.cpuCapacity) else emptyMap()
),
meta = mapOf("workload" to workload)
)
diff --git a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/VirtualMachine.kt b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/VirtualMachine.kt
index 5dd239f6..88e80719 100644
--- a/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/VirtualMachine.kt
+++ b/opendc-compute/opendc-compute-workload/src/main/kotlin/org/opendc/compute/workload/VirtualMachine.kt
@@ -31,8 +31,9 @@ import java.util.*
*
* @param uid The unique identifier of the virtual machine.
* @param name The name of the virtual machine.
+ * @param cpuCapacity The required CPU capacity for the VM in MHz.
* @param cpuCount The number of vCPUs in the VM.
- * @param memCapacity The provisioned memory for the VM.
+ * @param memCapacity The provisioned memory for the VM in MB.
* @param startTime The start time of the VM.
* @param stopTime The stop time of the VM.
* @param trace The trace that belong to this VM.
@@ -41,6 +42,7 @@ public data class VirtualMachine(
val uid: UUID,
val name: String,
val cpuCount: Int,
+ val cpuCapacity: Double,
val memCapacity: Long,
val totalLoad: Double,
val startTime: Instant,