Skip to content

Commit

Permalink
Fixed several cpu related bugs, changed input topology (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanteNiewenhuis authored Apr 29, 2024
1 parent aefa53b commit 2dc44c7
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 221 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public class VCpuFilter(private val allocationRatio: Double) : HostFilter {
server: Server,
): Boolean {
val requested = server.flavor.coreCount
val total = host.host.model.coreCount
val limit = total * allocationRatio
val totalCores = host.host.model.coreCount
val limit = totalCores * allocationRatio

// Do not allow an instance to overcommit against itself, only against other instances
if (requested > total) {
if (requested > totalCores) {
return false
}

val free = limit - host.provisionedCores
return free >= requested
val availableCores = limit - host.provisionedCores
return availableCores >= requested
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class SimHost(

override fun canFit(server: Server): Boolean {
val sufficientMemory = model.memoryCapacity >= server.flavor.memorySize
val enoughCpus = model.cpuCount >= server.flavor.coreCount
val enoughCpus = model.coreCount >= server.flavor.coreCount
val canFit = hypervisor.canFit(server.flavor.toMachineModel())

return sufficientMemory && enoughCpus && canFit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

package org.opendc.compute.topology

import org.opendc.compute.topology.specs.CPUJSONSpec
import org.opendc.compute.topology.specs.ClusterJSONSpec
import org.opendc.compute.topology.specs.HostJSONSpec
import org.opendc.compute.topology.specs.HostSpec
Expand Down Expand Up @@ -104,14 +103,14 @@ private fun ClusterJSONSpec.toHostSpecs(random: RandomGenerator): List<HostSpec>
* Helper method to convert a [HostJSONSpec] into a [HostSpec]s.
*/
private var hostId = 0
private var globalCoreId = 0

private fun HostJSONSpec.toHostSpecs(
clusterId: Int,
random: RandomGenerator,
): HostSpec {
val unknownProcessingNode = ProcessingNode("unknown", "unknown", "unknown", cpus.sumOf { it.coreCount })

val units = cpus.flatMap { cpu -> List(cpu.count) { cpu.toProcessingUnits(unknownProcessingNode) }.flatten() }
val unknownProcessingNode = ProcessingNode("unknown", "unknown", "unknown", cpu.coreCount)
val units = List(cpu.count) { ProcessingUnit(unknownProcessingNode, globalCoreId++, cpu.coreSpeed) }

val unknownMemoryUnit = MemoryUnit(memory.vendor, memory.modelName, memory.memorySpeed, memory.memorySize)
val machineModel =
Expand All @@ -134,15 +133,3 @@ private fun HostJSONSpec.toHostSpecs(

return hostSpec
}

/**
* Helper method to convert a [CPUJSONSpec] into a list of [ProcessingUnit]s.
*/
private var globalCoreId = 0

private fun CPUJSONSpec.toProcessingUnits(unknownProcessingNode: ProcessingNode): List<ProcessingUnit> {
val units = List(coreCount) { ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed) }
return units

// return listOf(ProcessingUnit(unknownProcessingNode, globalCoreId++, coreSpeed))
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public data class ClusterJSONSpec(
* Definition of a compute host modeled in the simulation.
*
* @param name The name of the host.
* @param cpus List of the different CPUs available in this cluster
* @param cpu The CPU available in this cluster
* @param memory The amount of RAM memory available in Byte
* @param powerModel The power model used to determine the power draw of a host
* @param count The power model used to determine the power draw of a host
*/
@Serializable
public data class HostJSONSpec(
val name: String = "Host",
val cpus: List<CPUJSONSpec>,
val cpu: CPUJSONSpec,
val memory: MemoryJSONSpec,
val powerModel: PowerModelJSONSpec = PowerModelJSONSpec("linear", 350.0, 400.0, 200.0),
val count: Int = 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ class ScenarioIntegrationTest {
{ assertEquals(0, monitor.serversActive, "All VMs should finish after a run") },
{ assertEquals(0, monitor.attemptsFailure, "No VM should be unscheduled") },
{ assertEquals(0, monitor.serversPending, "No VM should not be in the queue") },
{ assertEquals(223379991650, monitor.idleTime) { "Incorrect idle time" } },
{ assertEquals(66977091124, monitor.activeTime) { "Incorrect active time" } },
{ assertEquals(3160267873, monitor.stealTime) { "Incorrect steal time" } },
{ assertEquals(36256553309, monitor.idleTime) { "Incorrect idle time" } },
{ assertEquals(10404414534, monitor.activeTime) { "Incorrect active time" } },
{ assertEquals(54402726811, monitor.stealTime) { "Incorrect steal time" } },
{ assertEquals(0, monitor.lostTime) { "Incorrect lost time" } },
{ assertEquals(2.0774585843587227E7, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(6.232122296636381E9, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
{ assertEquals(3.804398939214319E7, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(1.141307641744099E10, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
)
}

Expand Down Expand Up @@ -163,12 +163,12 @@ class ScenarioIntegrationTest {

// Note that these values have been verified beforehand
assertAll(
{ assertEquals(10996730092, monitor.idleTime) { "Idle time incorrect" } },
{ assertEquals(9741285381, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(152, monitor.stealTime) { "Steal time incorrect" } },
{ assertEquals(873236440, monitor.idleTime) { "Idle time incorrect" } },
{ assertEquals(1719015528, monitor.activeTime) { "Active time incorrect" } },
{ assertEquals(8022269916, monitor.stealTime) { "Steal time incorrect" } },
{ assertEquals(0, monitor.lostTime) { "Lost time incorrect" } },
{ assertEquals(2539987.394500494, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(7.619825262052509E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
{ assertEquals(2874229.394500494, monitor.powerDraw, 1E4) { "Incorrect power draw" } },
{ assertEquals(8.622534568334692E8, monitor.energyUsage, 1E4) { "Incorrect energy usage" } },
)
}

Expand Down Expand Up @@ -213,8 +213,8 @@ class ScenarioIntegrationTest {

/**
* Test a small simulation setup with failures.
* FIXME: Currently failures do not work. reactivate this test when Failures are implemented again
*/
@Test
fun testFailures() =
runSimulation {
val seed = 0L
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
[
{
"name": "H01",
"cpus":
[
{
"coreCount": 32,
"coreSpeed": 3200
}
],
"cpu":
{
"coreCount": 32,
"coreSpeed": 3200
},
"memory": {
"memorySize": 256000
}
Expand All @@ -27,13 +25,11 @@
{
"name": "H02",
"count": 6,
"cpus":
[
{
"coreCount": 8,
"coreSpeed": 2930
}
],
"cpu":
{
"coreCount": 8,
"coreSpeed": 2930
},
"memory": {
"memorySize": 64000
}
Expand All @@ -47,13 +43,11 @@
{
"name": "H03",
"count": 2,
"cpus":
[
{
"coreCount": 16,
"coreSpeed": 3200
}
],
"cpu":
{
"coreCount": 16,
"coreSpeed": 3200
},
"memory": {
"memorySize": 128000
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
[
{
"name": "H01",
"cpus":
[
{
"coreCount": 8,
"coreSpeed": 3200
}
],
"cpu":
{
"coreCount": 8,
"coreSpeed": 3200
},
"memory": {
"memorySize": 128000
}
Expand Down
12 changes: 6 additions & 6 deletions site/docs/documentation/Input/Topology.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ In the following section, we describe the different components of the schema.

### Host

| variable | type | required? | default | description |
|-------------|-----------------------------|-----------|---------|--------------------------------------------------------------------------------|
| name | string | no | Host | The name of the host. This is only important for debugging and post-processing |
| count | integer | no | 1 | The amount of hosts of this type are in the cluster |
| cpus | List[[CPU](#cpu)] | yes | N/A | A list of the hosts in a cluster. |
| memory | [Memory](#memory) | yes | N/A | The memory used by the host |
| variable | type | required? | default | description |
|------------|-----------------------|-----------|---------|--------------------------------------------------------------------------------|
| name | string | no | Host | The name of the host. This is only important for debugging and post-processing |
| count | integer | no | 1 | The amount of hosts of this type are in the cluster |
| cpu | [CPU](#cpu) | yes | N/A | The CPUs in the host |
| memory | [Memory](#memory) | yes | N/A | The memory used by the host |
| power model | [Power Model](#power-model) | yes | N/A | The power model used to determine the power draw of the host |

### CPU
Expand Down
Loading

0 comments on commit 2dc44c7

Please sign in to comment.