diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-03-05 16:50:35 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-05 16:50:35 +0100 |
| commit | 960b3d8a13c67ac4b7f479d5764b0b618fc9ea09 (patch) | |
| tree | 4f103bcf6635341827d9cfa10c10cfde9543f04f /opendc-compute/opendc-compute-service/src/main | |
| parent | 5864cbcbfe2eb8c36ca05c3a39c7e5916aeecaec (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')
7 files changed, 15 insertions, 15 deletions
diff --git a/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ComputeService.java b/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ComputeService.java index eda9a79f..167b13c7 100644 --- a/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ComputeService.java +++ b/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ComputeService.java @@ -171,7 +171,7 @@ public final class ComputeService implements AutoCloseable { HostView hv = hostToView.get(host); final ServiceFlavor flavor = serviceServer.getFlavor(); if (hv != null) { - hv.provisionedCores -= flavor.getCpuCount(); + hv.provisionedCores -= flavor.getCoreCount(); hv.instanceCount--; hv.availableMemory += flavor.getMemorySize(); } else { @@ -237,7 +237,7 @@ public final class ComputeService implements AutoCloseable { HostView hv = new HostView(host); HostModel model = host.getModel(); - maxCores = Math.max(maxCores, model.cpuCount()); + maxCores = Math.max(maxCores, model.coreCount()); maxMemory = Math.max(maxMemory, model.memoryCapacity()); hostToView.put(host, hv); @@ -370,7 +370,7 @@ public final class ComputeService implements AutoCloseable { LOGGER.trace( "Server {} selected for scheduling but no capacity available for it at the moment", server); - if (flavor.getMemorySize() > maxMemory || flavor.getCpuCount() > maxCores) { + if (flavor.getMemorySize() > maxMemory || flavor.getCoreCount() > maxCores) { // Remove the incoming image queue.poll(); serversPending--; @@ -403,7 +403,7 @@ public final class ComputeService implements AutoCloseable { attemptsSuccess++; hv.instanceCount++; - hv.provisionedCores += flavor.getCpuCount(); + hv.provisionedCores += flavor.getCoreCount(); hv.availableMemory -= flavor.getMemorySize(); activeServers.put(server, host); diff --git a/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ServiceFlavor.java b/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ServiceFlavor.java index dba87e2c..0f434a6a 100644 --- a/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ServiceFlavor.java +++ b/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/ServiceFlavor.java @@ -36,7 +36,7 @@ public final class ServiceFlavor implements Flavor { private final ComputeService service; private final UUID uid; private final String name; - private final int cpuCount; + private final int coreCount; private final long memorySize; private final Map<String, String> labels; private final Map<String, ?> meta; @@ -45,22 +45,22 @@ public final class ServiceFlavor implements Flavor { ComputeService service, UUID uid, String name, - int cpuCount, + int coreCount, long memorySize, Map<String, String> labels, Map<String, ?> meta) { this.service = service; this.uid = uid; this.name = name; - this.cpuCount = cpuCount; + this.coreCount = coreCount; this.memorySize = memorySize; this.labels = labels; this.meta = meta; } @Override - public int getCpuCount() { - return cpuCount; + public int getCoreCount() { + return coreCount; } @Override diff --git a/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/driver/HostModel.java b/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/driver/HostModel.java index 9caa6da7..2d45817b 100644 --- a/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/driver/HostModel.java +++ b/opendc-compute/opendc-compute-service/src/main/java/org/opendc/compute/service/driver/HostModel.java @@ -29,4 +29,4 @@ package org.opendc.compute.service.driver; * @param cpuCount The number of logical processing cores available for this host. * @param memoryCapacity The amount of memory available for this host in MB. */ -public record HostModel(double cpuCapacity, int cpuCount, long memoryCapacity) {} +public record HostModel(double cpuCapacity, int cpuCount, int coreCount, long memoryCapacity) {} 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" |
