summaryrefslogtreecommitdiff
path: root/opendc-experiments/opendc-experiments-capelin/src
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2022-10-05 14:44:43 +0200
committerGitHub <noreply@github.com>2022-10-05 14:44:43 +0200
commitc2047d09b27b0c05f5c203509dde524e17d3b729 (patch)
tree3903d8aed5e87850c92e1b2dce8379ea99bdfa6d /opendc-experiments/opendc-experiments-capelin/src
parentec3b5b462c1b8296ba18a3872f56d569fa70e45b (diff)
parentbe176910eb870209576326ffaad8bf21241fccbd (diff)
merge: Extract scheduler from simulation coroutine dispatcher (#106)
This pull request extracts the scheduler from the `SimulationCoroutineDispatcher` into a separate `SimulationScheduler` class which allows users to re-use the scheduler between different coroutine dispatchers. We implement the `SimulationScheduler` in Java, removing the explicit dependency on Kotlin or `kotlinx-coroutines`. The scheduler uses a separate specialized priority queue implementation that eliminates allocation in the hot path of the simulator. ## Implementation Notes :hammer_and_pick: * Add Java-based simulator core * Use SimulationScheduler in coroutine dispatcher * Rename runBlockingSimulation to runSimulation ## External Dependencies :four_leaf_clover: * N/A ## Breaking API Changes :warning: * The Kotlin API for simulation has been moved to `org.opendc.simulator.kotlin`. * `runBlockingSImulation` renamed to `runSimulation`
Diffstat (limited to 'opendc-experiments/opendc-experiments-capelin/src')
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/jmh/kotlin/org/opendc/experiments/capelin/CapelinBenchmarks.kt4
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt4
-rw-r--r--opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt10
3 files changed, 9 insertions, 9 deletions
diff --git a/opendc-experiments/opendc-experiments-capelin/src/jmh/kotlin/org/opendc/experiments/capelin/CapelinBenchmarks.kt b/opendc-experiments/opendc-experiments-capelin/src/jmh/kotlin/org/opendc/experiments/capelin/CapelinBenchmarks.kt
index f021e223..ef3deeb2 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/jmh/kotlin/org/opendc/experiments/capelin/CapelinBenchmarks.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/jmh/kotlin/org/opendc/experiments/capelin/CapelinBenchmarks.kt
@@ -32,7 +32,7 @@ import org.opendc.experiments.capelin.topology.clusterTopology
import org.opendc.experiments.compute.*
import org.opendc.experiments.compute.topology.HostSpec
import org.opendc.experiments.provisioner.Provisioner
-import org.opendc.simulator.core.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import org.openjdk.jmh.annotations.*
import java.io.File
import java.util.*
@@ -60,7 +60,7 @@ class CapelinBenchmarks {
}
@Benchmark
- fun benchmarkCapelin() = runBlockingSimulation {
+ fun benchmarkCapelin() = runSimulation {
val serviceDomain = "compute.opendc.org"
Provisioner(coroutineContext, clock, seed = 0).use { provisioner ->
diff --git a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt
index f1214b08..7461038d 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/main/kotlin/org/opendc/experiments/capelin/CapelinRunner.kt
@@ -28,7 +28,7 @@ import org.opendc.experiments.capelin.topology.clusterTopology
import org.opendc.experiments.compute.*
import org.opendc.experiments.compute.export.parquet.ParquetComputeMonitor
import org.opendc.experiments.provisioner.Provisioner
-import org.opendc.simulator.core.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import java.io.File
import java.time.Duration
import java.util.*
@@ -54,7 +54,7 @@ public class CapelinRunner(
/**
* Run a single [scenario] with the specified seed.
*/
- fun runScenario(scenario: Scenario, seed: Long) = runBlockingSimulation {
+ fun runScenario(scenario: Scenario, seed: Long) = runSimulation {
val serviceDomain = "compute.opendc.org"
val topology = clusterTopology(File(envPath, "${scenario.topology.name}.txt"))
diff --git a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
index 9be2d522..238a5f87 100644
--- a/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
+++ b/opendc-experiments/opendc-experiments-capelin/src/test/kotlin/org/opendc/experiments/capelin/CapelinIntegrationTest.kt
@@ -39,7 +39,7 @@ import org.opendc.experiments.compute.telemetry.table.HostTableReader
import org.opendc.experiments.compute.telemetry.table.ServiceTableReader
import org.opendc.experiments.compute.topology.HostSpec
import org.opendc.experiments.provisioner.Provisioner
-import org.opendc.simulator.core.runBlockingSimulation
+import org.opendc.simulator.kotlin.runSimulation
import java.io.File
import java.time.Duration
import java.util.*
@@ -80,7 +80,7 @@ class CapelinIntegrationTest {
* Test a large simulation setup.
*/
@Test
- fun testLarge() = runBlockingSimulation {
+ fun testLarge() = runSimulation {
val seed = 0L
val workload = createTestWorkload(1.0, seed)
val topology = createTopology()
@@ -124,7 +124,7 @@ class CapelinIntegrationTest {
* Test a small simulation setup.
*/
@Test
- fun testSmall() = runBlockingSimulation {
+ fun testSmall() = runSimulation {
val seed = 1L
val workload = createTestWorkload(0.25, seed)
val topology = createTopology("single")
@@ -164,7 +164,7 @@ class CapelinIntegrationTest {
* Test a small simulation setup with interference.
*/
@Test
- fun testInterference() = runBlockingSimulation {
+ fun testInterference() = runSimulation {
val seed = 0L
val workload = createTestWorkload(1.0, seed)
val topology = createTopology("single")
@@ -202,7 +202,7 @@ class CapelinIntegrationTest {
* Test a small simulation setup with failures.
*/
@Test
- fun testFailures() = runBlockingSimulation {
+ fun testFailures() = runSimulation {
val seed = 0L
val topology = createTopology("single")
val workload = createTestWorkload(0.25, seed)