summaryrefslogtreecommitdiff
path: root/opendc-simulator/opendc-simulator-compute/src/jmh
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-25 16:01:14 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-25 16:01:14 +0200
commitcd0b45627f0d8da8c8dc4edde223f3c36e9bcfbf (patch)
tree6ae1681630a0e270c23804e6dbb3bd414ebe5d6e /opendc-simulator/opendc-simulator-compute/src/jmh
parent128a1db017545597a5c035b7960eb3fd36b5f987 (diff)
build: Migrate to flat project structure
This change updates the project structure to become flattened. Previously, the simulator, frontend and API each lived into their own directory. With this change, all modules of the project live in the top-level directory of the repository. This should improve discoverability of modules of the project.
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src/jmh')
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt43
-rw-r--r--opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt158
2 files changed, 201 insertions, 0 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt
new file mode 100644
index 00000000..43bbfd0b
--- /dev/null
+++ b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/BenchmarkHelpers.kt
@@ -0,0 +1,43 @@
+/*
+ * 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 org.opendc.simulator.compute.workload.SimTraceWorkload
+
+/**
+ * Helper function to create simple consumer workload.
+ */
+fun createSimpleConsumer(): SimTraceWorkload {
+ return SimTraceWorkload(
+ sequenceOf(
+ SimTraceWorkload.Fragment(1000, 28.0, 1),
+ SimTraceWorkload.Fragment(1000, 3500.0, 1),
+ SimTraceWorkload.Fragment(1000, 0.0, 1),
+ SimTraceWorkload.Fragment(1000, 183.0, 1),
+ SimTraceWorkload.Fragment(1000, 400.0, 1),
+ SimTraceWorkload.Fragment(1000, 100.0, 1),
+ SimTraceWorkload.Fragment(1000, 3000.0, 1),
+ SimTraceWorkload.Fragment(1000, 4500.0, 1),
+ ),
+ )
+}
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
new file mode 100644
index 00000000..7b97a665
--- /dev/null
+++ b/opendc-simulator/opendc-simulator-compute/src/jmh/kotlin/org/opendc/simulator/compute/SimMachineBenchmarks.kt
@@ -0,0 +1,158 @@
+/*
+ * 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.ExperimentalCoroutinesApi
+import kotlinx.coroutines.coroutineScope
+import kotlinx.coroutines.launch
+import org.opendc.simulator.compute.cpufreq.PerformanceScalingGovernor
+import org.opendc.simulator.compute.cpufreq.SimpleScalingDriver
+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.power.ConstantPowerModel
+import org.opendc.simulator.compute.workload.SimWorkload
+import org.opendc.simulator.core.SimulationCoroutineScope
+import org.opendc.simulator.core.runBlockingSimulation
+import org.opendc.utils.TimerScheduler
+import org.openjdk.jmh.annotations.*
+import java.time.Clock
+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)
+@OptIn(ExperimentalCoroutinesApi::class)
+class SimMachineBenchmarks {
+ private lateinit var scope: SimulationCoroutineScope
+ private lateinit var clock: Clock
+ private lateinit var scheduler: TimerScheduler<Any>
+ private lateinit var machineModel: SimMachineModel
+
+ @Setup
+ fun setUp() {
+ scope = SimulationCoroutineScope()
+ scheduler = TimerScheduler(scope.coroutineContext, clock)
+
+ val cpuNode = ProcessingNode("Intel", "Xeon", "amd64", 2)
+
+ machineModel = SimMachineModel(
+ cpus = List(cpuNode.coreCount) { ProcessingUnit(cpuNode, it, 1000.0) },
+ memory = List(4) { MemoryUnit("Crucial", "MTA18ASF4G72AZ-3G2B1", 3200.0, 32_000) }
+ )
+ }
+
+ @State(Scope.Thread)
+ class Workload {
+ lateinit var workloads: Array<SimWorkload>
+
+ @Setup
+ fun setUp() {
+ workloads = Array(2) { createSimpleConsumer() }
+ }
+ }
+
+ @Benchmark
+ fun benchmarkBareMetal(state: Workload) {
+ return scope.runBlockingSimulation {
+ val machine = SimBareMetalMachine(
+ coroutineContext, clock, machineModel, PerformanceScalingGovernor(),
+ SimpleScalingDriver(ConstantPowerModel(0.0))
+ )
+ return@runBlockingSimulation machine.run(state.workloads[0])
+ }
+ }
+
+ @Benchmark
+ fun benchmarkSpaceSharedHypervisor(state: Workload) {
+ return scope.runBlockingSimulation {
+ val machine = SimBareMetalMachine(
+ coroutineContext, clock, machineModel, PerformanceScalingGovernor(),
+ SimpleScalingDriver(ConstantPowerModel(0.0))
+ )
+ val hypervisor = SimSpaceSharedHypervisor()
+
+ launch { machine.run(hypervisor) }
+
+ val vm = hypervisor.createMachine(machineModel)
+
+ try {
+ return@runBlockingSimulation vm.run(state.workloads[0])
+ } finally {
+ vm.close()
+ machine.close()
+ }
+ }
+ }
+
+ @Benchmark
+ fun benchmarkFairShareHypervisorSingle(state: Workload) {
+ return scope.runBlockingSimulation {
+ val machine = SimBareMetalMachine(
+ coroutineContext, clock, machineModel, PerformanceScalingGovernor(),
+ SimpleScalingDriver(ConstantPowerModel(0.0))
+ )
+ val hypervisor = SimFairShareHypervisor()
+
+ launch { machine.run(hypervisor) }
+
+ val vm = hypervisor.createMachine(machineModel)
+
+ try {
+ return@runBlockingSimulation vm.run(state.workloads[0])
+ } finally {
+ vm.close()
+ machine.close()
+ }
+ }
+ }
+
+ @Benchmark
+ fun benchmarkFairShareHypervisorDouble(state: Workload) {
+ return scope.runBlockingSimulation {
+ val machine = SimBareMetalMachine(
+ coroutineContext, clock, machineModel, PerformanceScalingGovernor(),
+ SimpleScalingDriver(ConstantPowerModel(0.0))
+ )
+ val hypervisor = SimFairShareHypervisor()
+
+ launch { machine.run(hypervisor) }
+
+ coroutineScope {
+ repeat(2) { i ->
+ val vm = hypervisor.createMachine(machineModel)
+
+ launch {
+ try {
+ vm.run(state.workloads[i])
+ } finally {
+ machine.close()
+ }
+ }
+ }
+ }
+ machine.close()
+ }
+ }
+}