From 2ed3ad44885c93287d4ef9c7996db73f1d49d62d Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 8 Apr 2021 10:39:58 +0200 Subject: compute: Fix random allocation policy This change fixes an issue in the RandomAllocationPolicy where it would incorrectly obtain the required memory for the server. --- .../org/opendc/compute/service/scheduler/RandomAllocationPolicy.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'simulator/opendc-compute') diff --git a/simulator/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/RandomAllocationPolicy.kt b/simulator/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/RandomAllocationPolicy.kt index ac7b351d..006e0d1c 100644 --- a/simulator/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/RandomAllocationPolicy.kt +++ b/simulator/opendc-compute/opendc-compute-service/src/main/kotlin/org/opendc/compute/service/scheduler/RandomAllocationPolicy.kt @@ -38,7 +38,7 @@ public class RandomAllocationPolicy(private val random: Random = Random(0)) : Al ): HostView? { return hypervisors.asIterable() .filter { hv -> - val fitsMemory = hv.availableMemory >= (server.image.meta["required-memory"] as Long) + val fitsMemory = hv.availableMemory >= server.flavor.memorySize val fitsCpu = hv.host.model.cpuCount >= server.flavor.cpuCount fitsMemory && fitsCpu } -- cgit v1.2.3 From 41ad2f2950550fcd95a599bd8869aa191c88396a Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 8 Apr 2021 11:47:01 +0200 Subject: simulator: Divide CPU usage over all cores This change fixes an issue in SimTraceWorkload where the CPU usage was not divided across the cores, but was instead requested for all cores. --- .../test/kotlin/org/opendc/compute/simulator/SimHostTest.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'simulator/opendc-compute') diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt index 830fc868..2a897b28 100644 --- a/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt +++ b/simulator/opendc-compute/opendc-compute-simulator/src/test/kotlin/org/opendc/compute/simulator/SimHostTest.kt @@ -94,10 +94,10 @@ internal class SimHostTest { mapOf( "workload" to SimTraceWorkload( sequenceOf( - SimTraceWorkload.Fragment(duration * 1000, 28.0, 2), - SimTraceWorkload.Fragment(duration * 1000, 3500.0, 2), + SimTraceWorkload.Fragment(duration * 1000, 2 * 28.0, 2), + SimTraceWorkload.Fragment(duration * 1000, 2 * 3500.0, 2), SimTraceWorkload.Fragment(duration * 1000, 0.0, 2), - SimTraceWorkload.Fragment(duration * 1000, 183.0, 2) + SimTraceWorkload.Fragment(duration * 1000, 2 * 183.0, 2) ), ) ) @@ -109,10 +109,10 @@ internal class SimHostTest { mapOf( "workload" to SimTraceWorkload( sequenceOf( - SimTraceWorkload.Fragment(duration * 1000, 28.0, 2), - SimTraceWorkload.Fragment(duration * 1000, 3100.0, 2), + SimTraceWorkload.Fragment(duration * 1000, 2 * 28.0, 2), + SimTraceWorkload.Fragment(duration * 1000, 2 * 3100.0, 2), SimTraceWorkload.Fragment(duration * 1000, 0.0, 2), - SimTraceWorkload.Fragment(duration * 1000, 73.0, 2) + SimTraceWorkload.Fragment(duration * 1000, 2 * 73.0, 2) ) ) ) -- cgit v1.2.3 From 8deb1fbff56f9aee0b5f0114c026fb4e57d53f95 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 8 Apr 2021 12:31:34 +0200 Subject: compute: Use BatchRecorder to emit metrics This change updates the SimHost implementation to use BatchRecorder to batch record multiple metrics at once. --- .../kotlin/org/opendc/compute/simulator/SimHost.kt | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'simulator/opendc-compute') diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt index 89d01c57..7a0f8bc7 100644 --- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt +++ b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt @@ -98,13 +98,15 @@ public class SimHost( cpuUsage: Double, cpuDemand: Double ) { - _cpuWork.record(requestedWork.toDouble()) - _cpuWorkGranted.record(grantedWork.toDouble()) - _cpuWorkOvercommit.record(overcommittedWork.toDouble()) - _cpuWorkInterference.record(interferedWork.toDouble()) - _cpuUsage.record(cpuUsage) - _cpuDemand.record(cpuDemand) - _cpuPower.record(machine.powerDraw) + + _batch.put(_cpuWork, requestedWork.toDouble()) + _batch.put(_cpuWorkGranted, grantedWork.toDouble()) + _batch.put(_cpuWorkOvercommit, overcommittedWork.toDouble()) + _batch.put(_cpuWorkInterference, interferedWork.toDouble()) + _batch.put(_cpuUsage, cpuUsage) + _batch.put(_cpuDemand, cpuDemand) + _batch.put(_cpuPower, machine.powerDraw) + _batch.record() } } ) @@ -151,7 +153,6 @@ public class SimHost( .setDescription("The amount of CPU resources used by the host") .setUnit("MHz") .build() - .bind(Labels.of("host", uid.toString())) /** * The CPU demand on the host. @@ -160,7 +161,6 @@ public class SimHost( .setDescription("The amount of CPU resources the guests would use if there were no CPU contention or CPU limits") .setUnit("MHz") .build() - .bind(Labels.of("host", uid.toString())) /** * The requested work for the CPU. @@ -169,7 +169,6 @@ public class SimHost( .setDescription("The amount of power used by the CPU") .setUnit("W") .build() - .bind(Labels.of("host", uid.toString())) /** * The requested work for the CPU. @@ -178,7 +177,6 @@ public class SimHost( .setDescription("The amount of work supplied to the CPU") .setUnit("1") .build() - .bind(Labels.of("host", uid.toString())) /** * The work actually performed by the CPU. @@ -187,7 +185,6 @@ public class SimHost( .setDescription("The amount of work performed by the CPU") .setUnit("1") .build() - .bind(Labels.of("host", uid.toString())) /** * The work that could not be performed by the CPU due to overcommitting resource. @@ -196,7 +193,6 @@ public class SimHost( .setDescription("The amount of work not performed by the CPU due to overcommitment") .setUnit("1") .build() - .bind(Labels.of("host", uid.toString())) /** * The work that could not be performed by the CPU due to interference. @@ -205,7 +201,11 @@ public class SimHost( .setDescription("The amount of work not performed by the CPU due to interference") .setUnit("1") .build() - .bind(Labels.of("host", uid.toString())) + + /** + * The batch recorder used to record multiple metrics atomically. + */ + private val _batch = meter.newBatchRecorder("host", uid.toString()) init { // Launch hypervisor onto machine -- cgit v1.2.3 From 638dd7a33d5f7f0b8fcca9c99cdc92819cf0847c Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Tue, 30 Mar 2021 22:42:41 +0200 Subject: exp: Add experiment for OpenDC Energy project This change adds an experiment for the OpenDC Energy project, which tests various energy models that have been implemented in OpenDC. --- .../kotlin/org/opendc/compute/simulator/SimHost.kt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'simulator/opendc-compute') diff --git a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt index 7a0f8bc7..ea775efc 100644 --- a/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt +++ b/simulator/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt @@ -32,6 +32,8 @@ import org.opendc.compute.api.ServerState import org.opendc.compute.service.driver.* import org.opendc.simulator.compute.* import org.opendc.simulator.compute.cpufreq.PerformanceScalingGovernor +import org.opendc.simulator.compute.cpufreq.ScalingDriver +import org.opendc.simulator.compute.cpufreq.ScalingGovernor import org.opendc.simulator.compute.cpufreq.SimpleScalingDriver import org.opendc.simulator.compute.interference.IMAGE_PERF_INTERFERENCE_MODEL import org.opendc.simulator.compute.interference.PerformanceInterferenceModel @@ -56,9 +58,24 @@ public class SimHost( clock: Clock, meter: Meter, hypervisor: SimHypervisorProvider, - powerModel: PowerModel = ConstantPowerModel(0.0), + scalingGovernor: ScalingGovernor, + scalingDriver: ScalingDriver, private val mapper: SimWorkloadMapper = SimMetaWorkloadMapper(), ) : Host, FailureDomain, AutoCloseable { + + public constructor( + uid: UUID, + name: String, + model: SimMachineModel, + meta: Map, + context: CoroutineContext, + clock: Clock, + meter: Meter, + hypervisor: SimHypervisorProvider, + powerModel: PowerModel = ConstantPowerModel(0.0), + mapper: SimWorkloadMapper = SimMetaWorkloadMapper(), + ) : this(uid, name, model, meta, context, clock, meter, hypervisor, PerformanceScalingGovernor(), SimpleScalingDriver(powerModel), mapper) + /** * The [CoroutineScope] of the host bounded by the lifecycle of the host. */ @@ -82,7 +99,7 @@ public class SimHost( /** * The machine to run on. */ - public val machine: SimBareMetalMachine = SimBareMetalMachine(context, clock, model, PerformanceScalingGovernor(), SimpleScalingDriver(powerModel)) + public val machine: SimBareMetalMachine = SimBareMetalMachine(context, clock, model, scalingGovernor, scalingDriver) /** * The hypervisor to run multiple workloads. -- cgit v1.2.3