From 960b3d8a13c67ac4b7f479d5764b0b618fc9ea09 Mon Sep 17 00:00:00 2001 From: Dante Niewenhuis Date: Tue, 5 Mar 2024 16:50:35 +0100 Subject: Cpu fix (#208) * Updated the topology format to JSON. Updated TopologyReader.kt to handle JSON filed. Added documentation for the new format. * applied spotless kotlin * small update * Updated for spotless apply * Updated for spotless apply --- .../kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt | 2 +- .../opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt | 2 +- .../kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt | 4 ++-- .../opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'opendc-compute/opendc-compute-service/src/main/kotlin') diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt index 18947146..4d234b1b 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt @@ -42,7 +42,7 @@ public fun createComputeScheduler( seeder: RandomGenerator, placements: Map = emptyMap(), ): ComputeScheduler { - val cpuAllocationRatio = 16.0 + val cpuAllocationRatio = 1.0 val ramAllocationRatio = 1.5 return when (name) { "mem" -> 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 index e3397e50..01ece80e 100644 --- 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 @@ -38,6 +38,6 @@ public class VCpuCapacityFilter : HostFilter { val hostModel = host.host.model val availableCapacity = hostModel.cpuCapacity / hostModel.cpuCount - return requiredCapacity == null || availableCapacity >= (requiredCapacity / server.flavor.cpuCount) + return requiredCapacity == null || availableCapacity >= (requiredCapacity / server.flavor.coreCount) } } diff --git a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt index 5d02873f..451ea4b6 100644 --- a/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt +++ b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt @@ -35,8 +35,8 @@ public class VCpuFilter(private val allocationRatio: Double) : HostFilter { host: HostView, server: Server, ): Boolean { - val requested = server.flavor.cpuCount - val total = host.host.model.cpuCount + val requested = server.flavor.coreCount + val total = host.host.model.coreCount val limit = total * allocationRatio // 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/weights/VCpuCapacityWeigher.kt b/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt index 2912ce49..242660c3 100644 --- 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 @@ -35,7 +35,7 @@ public class VCpuCapacityWeigher(override val multiplier: Double = 1.0) : HostWe ): 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 + return model.cpuCapacity / model.cpuCount - requiredCapacity / server.flavor.coreCount } override fun toString(): String = "VCpuWeigher" -- cgit v1.2.3