diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-09-16 11:29:26 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-16 11:29:26 +0200 |
| commit | 4a010c6b9e033314a2624a0756dcdc7f17010d9d (patch) | |
| tree | 70dc26e98cf8421eb5db7f62cf63d4ea2399c505 /opendc-compute/opendc-compute-simulator/src/main | |
| parent | 5047e4a25a0814f96852882f02c4017e1d5f81e7 (diff) | |
All simulation are now run with a single CPU and single MemoryUnit. multi CPUs are combined into one. This is for performance and explainability. (#255)
Diffstat (limited to 'opendc-compute/opendc-compute-simulator/src/main')
3 files changed, 9 insertions, 21 deletions
diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt index ac0a8043..e681403c 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/SimHost.kt @@ -41,8 +41,6 @@ import org.opendc.simulator.compute.SimMachineContext import org.opendc.simulator.compute.kernel.SimHypervisor import org.opendc.simulator.compute.model.MachineModel import org.opendc.simulator.compute.model.MemoryUnit -import org.opendc.simulator.compute.model.ProcessingNode -import org.opendc.simulator.compute.model.ProcessingUnit import org.opendc.simulator.compute.workload.SimWorkload import org.opendc.simulator.compute.workload.SimWorkloads import java.time.Duration @@ -96,10 +94,9 @@ public class SimHost( private val model: HostModel = HostModel( - machine.model.cpus.sumOf { it.frequency }, - machine.model.cpus.size, - machine.model.cpus.sumOf { it.node.coreCount }, - machine.model.memory.sumOf { it.size }, + machine.model.cpu.totalCapacity, + machine.model.cpu.coreCount, + machine.model.memory.size, ) /** @@ -349,22 +346,14 @@ public class SimHost( * Convert flavor to machine model. */ private fun Flavor.toMachineModel(): MachineModel { - val originalCpu = machine.model.cpus[0] - val originalNode = originalCpu.node - val cpuCapacity = (this.meta["cpu-capacity"] as? Double ?: Double.MAX_VALUE).coerceAtMost(originalCpu.frequency) - val processingNode = ProcessingNode(originalNode.vendor, originalNode.modelName, originalNode.architecture, coreCount) - val processingUnits = (0 until coreCount).map { ProcessingUnit(processingNode, it, cpuCapacity) } - val memoryUnits = listOf(MemoryUnit("Generic", "Generic", 3200.0, memorySize)) - - val model = MachineModel(processingUnits, memoryUnits) - return if (optimize) model.optimize() else model + return MachineModel(machine.model.cpu, MemoryUnit("Generic", "Generic", 3200.0, memorySize)) } private var localLastReport = clock.millis() private var localUptime = 0L private var localDowntime = 0L private var localBootTime: Instant? = null - private val localCpuLimit = machine.model.cpus.sumOf { it.frequency * it.node.coreCount } + private val localCpuLimit = machine.model.cpu.totalCapacity /** * Helper function to track the uptime of a machine. diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/DefaultWorkloadMapper.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/DefaultWorkloadMapper.kt index ea8f51d0..412da37f 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/DefaultWorkloadMapper.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/DefaultWorkloadMapper.kt @@ -39,8 +39,8 @@ internal object DefaultWorkloadMapper : SimWorkloadMapper { override fun createWorkload(task: Task): SimWorkload { val workload = delegate.createWorkload(task) - // FIXME: look at connecting this to frontend. Probably not needed since the duration is so small - val bootWorkload = SimWorkloads.runtime(Duration.ofMillis(1), 0.8, 0L, 0L) + // FIXME: look at connecting this to frontend. This does currently not work correctly + val bootWorkload = SimWorkloads.runtime(Duration.ofMillis(0), 1.0, 0L, 0L) return SimWorkloads.chain(bootWorkload, workload) } } diff --git a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt index 1925233f..cf6c146a 100644 --- a/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt +++ b/opendc-compute/opendc-compute-simulator/src/main/kotlin/org/opendc/compute/simulator/internal/Guest.kt @@ -31,7 +31,6 @@ import org.opendc.compute.simulator.SimHost import org.opendc.compute.simulator.SimWorkloadMapper import org.opendc.simulator.compute.SimMachineContext import org.opendc.simulator.compute.kernel.SimHypervisor -import org.opendc.simulator.compute.kernel.SimVirtualMachine import org.opendc.simulator.compute.workload.SimWorkload import java.time.Duration import java.time.Instant @@ -47,7 +46,7 @@ internal class Guest( private val mapper: SimWorkloadMapper, private val listener: GuestListener, val task: Task, - val machine: SimVirtualMachine, + val machine: SimHypervisor.SimVirtualMachine, ) { /** * The state of the [Guest]. @@ -225,7 +224,7 @@ internal class Guest( private var localDowntime = 0L private var localLastReport = clock.millis() private var localBootTime: Instant? = null - private val localCpuLimit = machine.model.cpus.sumOf { it.frequency } + private val localCpuLimit = machine.model.cpu.totalCapacity /** * Helper function to track the uptime and downtime of the guest. |
