diff options
| author | Dante Niewenhuis <d.niewenhuis@hotmail.com> | 2024-12-06 15:44:09 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-06 15:44:09 +0100 |
| commit | 8bbc3de611f9a679b5fb542241d32f887b4fe921 (patch) | |
| tree | fd19092f7921359c0cc619693a29b15b8cda2db3 /opendc-simulator/opendc-simulator-compute/src | |
| parent | 0ce9557b2960979e7e25be7aae05c389d51da17e (diff) | |
Renamed Multiplexer to FlowDistributor (#282)
* Restructured opendc-simulator-flow.
Renamed Multiplexer to FlowDistributor.
* spotless applied
* Added FlowDistributor topologies back
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src')
15 files changed, 45 insertions, 207 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt deleted file mode 100644 index 8d8f4ef8..00000000 --- a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) 2021 AtLarge Research - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package org.opendc.simulator.compute - -import kotlinx.coroutines.coroutineScope -import kotlinx.coroutines.launch -import org.opendc.simulator.compute.old.SimBareMetalMachine -import org.opendc.simulator.compute.old.kernel.SimHypervisor -import org.opendc.simulator.compute.old.model.CpuModel -import org.opendc.simulator.compute.old.model.MachineModel -import org.opendc.simulator.compute.old.model.MemoryUnit -import org.opendc.simulator.compute.old.model.ProcessingNode -import org.opendc.simulator.compute.old.workload.SimTrace -import org.opendc.simulator.flow2.FlowEngine -import org.opendc.simulator.flow2.mux.FlowMultiplexerFactory -import org.opendc.simulator.kotlin.runSimulation -import org.openjdk.jmh.annotations.Benchmark -import org.openjdk.jmh.annotations.Fork -import org.openjdk.jmh.annotations.Measurement -import org.openjdk.jmh.annotations.Scope -import org.openjdk.jmh.annotations.Setup -import org.openjdk.jmh.annotations.State -import org.openjdk.jmh.annotations.Warmup -import java.util.SplittableRandom -import java.util.concurrent.ThreadLocalRandom -import java.util.concurrent.TimeUnit - -@State(Scope.Thread) -@Fork(1) -@Warmup(iterations = 2, time = 1, timeUnit = TimeUnit.SECONDS) -@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS) -class SimMachineBenchmarks { - private lateinit var machineModel: MachineModel - private lateinit var trace: SimTrace - - @Setup - fun setUp() { - val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2) - - machineModel = - MachineModel( - // cpus - List(cpuNode.coreCount) { - CpuModel( - cpuNode, - it, - 1000.0, - ) - }, - // memory - List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }, - ) - - val random = ThreadLocalRandom.current() - val builder = SimTrace.builder() - repeat(1000000) { - val timestamp = it.toLong() * 1000 - val deadline = timestamp + 1000 - builder.add(deadline, random.nextDouble(0.0, 4500.0), 1) - } - trace = builder.build() - } - - @Benchmark - fun benchmarkBareMetal() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - return@runSimulation machine.runWorkload(trace.createWorkload(0)) - } - } - - @Benchmark - fun benchmarkSpaceSharedHypervisor() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.forwardingMultiplexer(), SplittableRandom(1)) - - launch { machine.runWorkload(hypervisor) } - - val vm = hypervisor.newMachine(machineModel) - - try { - return@runSimulation vm.runWorkload(trace.createWorkload(0)) - } finally { - vm.cancel() - machine.cancel() - } - } - } - - @Benchmark - fun benchmarkFairShareHypervisorSingle() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1)) - - launch { machine.runWorkload(hypervisor) } - - val vm = hypervisor.newMachine(machineModel) - - try { - return@runSimulation vm.runWorkload(trace.createWorkload(0)) - } finally { - vm.cancel() - machine.cancel() - } - } - } - - @Benchmark - fun benchmarkFairShareHypervisorDouble() { - return runSimulation { - val engine = FlowEngine.create(dispatcher) - val graph = engine.newGraph() - val machine = SimBareMetalMachine.create(graph, machineModel) - val hypervisor = SimHypervisor.create(FlowMultiplexerFactory.maxMinMultiplexer(), SplittableRandom(1)) - - launch { machine.runWorkload(hypervisor) } - - coroutineScope { - repeat(2) { - val vm = hypervisor.newMachine(machineModel) - - launch { - try { - vm.runWorkload(trace.createWorkload(0)) - } finally { - machine.cancel() - } - } - } - } - machine.cancel() - } - } -} diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java index 63331a6c..c5b8a9ea 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/cpu/SimCpu.java @@ -24,11 +24,11 @@ package org.opendc.simulator.compute.cpu; import org.opendc.simulator.compute.machine.PerformanceCounters; import org.opendc.simulator.compute.models.CpuModel; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimCpu} of a machine. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java index 8364324a..074f0ed8 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/SimMachine.java @@ -24,7 +24,6 @@ package org.opendc.simulator.compute.machine; import java.time.InstantSource; import java.util.function.Consumer; -import org.opendc.simulator.Multiplexer; import org.opendc.simulator.compute.cpu.CpuPowerModel; import org.opendc.simulator.compute.cpu.SimCpu; import org.opendc.simulator.compute.memory.Memory; @@ -32,7 +31,8 @@ import org.opendc.simulator.compute.models.MachineModel; import org.opendc.simulator.compute.power.SimPsu; import org.opendc.simulator.compute.workload.SimWorkload; import org.opendc.simulator.compute.workload.Workload; -import org.opendc.simulator.engine.FlowGraph; +import org.opendc.simulator.engine.graph.FlowDistributor; +import org.opendc.simulator.engine.graph.FlowGraph; /** * A machine that is able to execute {@link SimWorkload} objects. @@ -44,7 +44,7 @@ public class SimMachine { private final InstantSource clock; private SimCpu cpu; - private Multiplexer cpuMux; + private FlowDistributor cpuMux; private SimPsu psu; private Memory memory; @@ -74,7 +74,7 @@ public class SimMachine { return cpu; } - public Multiplexer getCpuMux() { + public FlowDistributor getCpuMux() { return cpuMux; } @@ -114,7 +114,7 @@ public class SimMachine { public SimMachine( FlowGraph graph, MachineModel machineModel, - Multiplexer powerMux, + FlowDistributor powerMux, CpuPowerModel cpuPowerModel, Consumer<Exception> completion) { this.graph = graph; @@ -132,8 +132,8 @@ public class SimMachine { this.memory = new Memory(graph, this.machineModel.getMemory()); - // Create a Multiplexer and add the cpu as supplier - this.cpuMux = new Multiplexer(this.graph); + // Create a FlowDistributor and add the cpu as supplier + this.cpuMux = new FlowDistributor(this.graph); graph.addEdge(this.cpuMux, this.cpu); this.completion = completion; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java index 15a1b1c4..b8a9c738 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/machine/VirtualMachine.java @@ -26,11 +26,11 @@ import java.util.function.Consumer; import org.opendc.simulator.compute.cpu.SimCpu; import org.opendc.simulator.compute.workload.SimWorkload; import org.opendc.simulator.compute.workload.Workload; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /* A virtual Machine created to run a single workload diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java index 2656a99a..d4406b20 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/memory/Memory.java @@ -23,7 +23,7 @@ package org.opendc.simulator.compute.memory; import org.opendc.simulator.compute.models.MemoryUnit; -import org.opendc.simulator.engine.FlowGraph; +import org.opendc.simulator.engine.graph.FlowGraph; /** * The [SimMemory] implementation for a machine. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java index 98ef2b72..91095c01 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/CarbonModel.java @@ -23,8 +23,8 @@ package org.opendc.simulator.compute.power; import java.util.List; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; /** * CarbonModel used to provide the Carbon Intensity of a {@link SimPowerSource} diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java index ea500c81..e8626e40 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPowerSource.java @@ -24,10 +24,10 @@ package org.opendc.simulator.compute.power; import java.util.List; import org.opendc.simulator.compute.cpu.SimCpu; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimPsu} implementation that estimates the power consumption based on CPU usage. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java index 709d3e15..c1e8a1b9 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/power/SimPsu.java @@ -23,11 +23,11 @@ package org.opendc.simulator.compute.power; import org.opendc.simulator.compute.cpu.SimCpu; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimPsu} implementation that estimates the power consumption based on CPU usage. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java index 78e8b5d4..ecd4c47f 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/ChainWorkload.java @@ -23,7 +23,7 @@ package org.opendc.simulator.compute.workload; import java.util.ArrayList; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowSupplier; public class ChainWorkload implements Workload { private ArrayList<Workload> workloads; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java index 723c450d..f4f7cdd6 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/CheckpointModel.java @@ -29,8 +29,8 @@ package org.opendc.simulator.compute.workload; import java.time.InstantSource; import org.jetbrains.annotations.NotNull; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; public class CheckpointModel extends FlowNode { private SimWorkload simWorkload; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java index 5b7c10bb..75bdde92 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimChainWorkload.java @@ -23,9 +23,9 @@ package org.opendc.simulator.compute.workload; import java.util.LinkedList; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; /** * A {@link SimChainWorkload} that composes multiple {@link SimWorkload}s. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java index 59994fe6..72c095dc 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimTraceWorkload.java @@ -23,11 +23,11 @@ package org.opendc.simulator.compute.workload; import java.util.LinkedList; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowEdge; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowEdge; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; +import org.opendc.simulator.engine.graph.FlowSupplier; public class SimTraceWorkload extends SimWorkload implements FlowConsumer { private LinkedList<TraceFragment> remainingFragments; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java index b5c89941..2919fc3a 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/SimWorkload.java @@ -22,9 +22,9 @@ package org.opendc.simulator.compute.workload; -import org.opendc.simulator.engine.FlowConsumer; -import org.opendc.simulator.engine.FlowGraph; -import org.opendc.simulator.engine.FlowNode; +import org.opendc.simulator.engine.graph.FlowConsumer; +import org.opendc.simulator.engine.graph.FlowGraph; +import org.opendc.simulator.engine.graph.FlowNode; /** * A model that characterizes the runtime behavior of some particular workload. diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java index 39bb6111..7f82ab71 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/TraceWorkload.java @@ -24,7 +24,7 @@ package org.opendc.simulator.compute.workload; import java.util.ArrayList; import java.util.List; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowSupplier; public class TraceWorkload implements Workload { private ArrayList<TraceFragment> fragments; diff --git a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java index cd34921a..d85669bb 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java +++ b/opendc-simulator/opendc-simulator-compute/src/main/java/org/opendc/simulator/compute/workload/Workload.java @@ -22,7 +22,7 @@ package org.opendc.simulator.compute.workload; -import org.opendc.simulator.engine.FlowSupplier; +import org.opendc.simulator.engine.graph.FlowSupplier; public interface Workload { |
