summaryrefslogtreecommitdiff
path: root/opendc-compute/opendc-compute-service/src/main/kotlin
diff options
context:
space:
mode:
authorDante Niewenhuis <d.niewenhuis@hotmail.com>2024-03-05 16:50:35 +0100
committerGitHub <noreply@github.com>2024-03-05 16:50:35 +0100
commit960b3d8a13c67ac4b7f479d5764b0b618fc9ea09 (patch)
tree4f103bcf6635341827d9cfa10c10cfde9543f04f /opendc-compute/opendc-compute-service/src/main/kotlin
parent5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec (diff)
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
Diffstat (limited to 'opendc-compute/opendc-compute-service/src/main/kotlin')
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/ComputeSchedulers.kt2
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuCapacityFilter.kt2
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/filters/VCpuFilter.kt4
-rw-r--r--opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/weights/VCpuCapacityWeigher.kt2
4 files changed, 5 insertions, 5 deletions
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<String, String> = 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"