From b8ba3cf81da6367285c5d5a23a70f8c340a45fdd Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 26 Mar 2021 15:30:22 +0100 Subject: compute: Integrate OpenTelemetry Metrics in OpenDC Workflow This change integrates the OpenTelemetry Metrics API in the OpenDC Workflow Service implementation. This replaces the old infrastructure for gathering metrics. --- .../opendc-experiments-sc18/.gitignore | 2 - .../opendc-experiments-sc18/build.gradle.kts | 38 ------ .../sc18/UnderspecificationExperiment.kt | 138 --------------------- .../org/opendc/experiments/sc18/WorkflowMetrics.kt | 86 ------------- 4 files changed, 264 deletions(-) delete mode 100644 simulator/opendc-experiments/opendc-experiments-sc18/.gitignore delete mode 100644 simulator/opendc-experiments/opendc-experiments-sc18/build.gradle.kts delete mode 100644 simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/UnderspecificationExperiment.kt delete mode 100644 simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/WorkflowMetrics.kt (limited to 'simulator/opendc-experiments') diff --git a/simulator/opendc-experiments/opendc-experiments-sc18/.gitignore b/simulator/opendc-experiments/opendc-experiments-sc18/.gitignore deleted file mode 100644 index ba64707c..00000000 --- a/simulator/opendc-experiments/opendc-experiments-sc18/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -input/ -output/ diff --git a/simulator/opendc-experiments/opendc-experiments-sc18/build.gradle.kts b/simulator/opendc-experiments/opendc-experiments-sc18/build.gradle.kts deleted file mode 100644 index 02e77c7c..00000000 --- a/simulator/opendc-experiments/opendc-experiments-sc18/build.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2019 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. - */ - -description = "Experiments for the SC18 article" - -/* Build configuration */ -plugins { - `kotlin-library-conventions` - `experiment-conventions` -} - -dependencies { - api(platform(project(":opendc-platform"))) - api(project(":opendc-harness")) - implementation(project(":opendc-format")) - implementation(project(":opendc-workflow:opendc-workflow-service")) - implementation(project(":opendc-simulator:opendc-simulator-core")) - implementation(project(":opendc-compute:opendc-compute-simulator")) -} diff --git a/simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/UnderspecificationExperiment.kt b/simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/UnderspecificationExperiment.kt deleted file mode 100644 index 225200c9..00000000 --- a/simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/UnderspecificationExperiment.kt +++ /dev/null @@ -1,138 +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.experiments.sc18 - -import io.opentelemetry.api.metrics.MeterProvider -import kotlinx.coroutines.* -import kotlinx.coroutines.test.TestCoroutineScope -import org.opendc.compute.service.ComputeService -import org.opendc.compute.service.scheduler.NumberOfActiveServersAllocationPolicy -import org.opendc.compute.simulator.SimHost -import org.opendc.format.environment.sc18.Sc18EnvironmentReader -import org.opendc.format.trace.gwf.GwfTraceReader -import org.opendc.harness.dsl.Experiment -import org.opendc.harness.dsl.anyOf -import org.opendc.simulator.compute.SimSpaceSharedHypervisorProvider -import org.opendc.simulator.utils.DelayControllerClockAdapter -import org.opendc.trace.core.EventTracer -import org.opendc.trace.core.enable -import org.opendc.workflow.service.WorkflowEvent -import org.opendc.workflow.service.WorkflowService -import org.opendc.workflow.service.scheduler.WorkflowSchedulerMode -import org.opendc.workflow.service.scheduler.job.NullJobAdmissionPolicy -import org.opendc.workflow.service.scheduler.job.SubmissionTimeJobOrderPolicy -import org.opendc.workflow.service.scheduler.task.NullTaskEligibilityPolicy -import org.opendc.workflow.service.scheduler.task.SubmissionTimeTaskOrderPolicy -import java.io.File -import java.io.FileInputStream -import kotlin.math.max - -/** - * The [UnderspecificationExperiment] investigates the impact of scheduler underspecification on performance. - * It focuses on components that must exist (that is, based on their own publications, the correct operation of the - * schedulers under study requires these components), yet have been left underspecified by their author. - */ -public class UnderspecificationExperiment : Experiment("underspecification") { - /** - * The workflow traces to test. - */ - private val trace: String by anyOf("input/traces/chronos_exp_noscaler_ca.gwf") - - /** - * The datacenter environments to test. - */ - private val environment: String by anyOf("input/environments/base.json") - - @OptIn(ExperimentalCoroutinesApi::class) - override fun doRun(repeat: Int) { - val testScope = TestCoroutineScope() - val clock = DelayControllerClockAdapter(testScope) - val tracer = EventTracer(clock) - val recording = tracer.openRecording().run { - enable() - enable() - enable() - enable() - enable() - this - } - - testScope.launch { - launch { println("MAKESPAN: ${recording.workflowRuntime()}") } - launch { println("WAIT: ${recording.workflowWaitingTime()}") } - recording.start() - } - - testScope.launch { - val hosts = Sc18EnvironmentReader(FileInputStream(File(environment))) - .use { it.read() } - .map { def -> - SimHost( - def.uid, - def.name, - def.model, - def.meta, - testScope.coroutineContext, - clock, - SimSpaceSharedHypervisorProvider() - ) - } - - val compute = ComputeService( - testScope.coroutineContext, - clock, - MeterProvider.noop().get("opendc-compute"), - NumberOfActiveServersAllocationPolicy(), - ) - - hosts.forEach { compute.addHost(it) } - - val scheduler = WorkflowService( - testScope.coroutineContext, - clock, - tracer, - compute.newClient(), - mode = WorkflowSchedulerMode.Batch(100), - jobAdmissionPolicy = NullJobAdmissionPolicy, - jobOrderPolicy = SubmissionTimeJobOrderPolicy(), - taskEligibilityPolicy = NullTaskEligibilityPolicy, - taskOrderPolicy = SubmissionTimeTaskOrderPolicy(), - ) - - val reader = GwfTraceReader(File(trace)) - - while (reader.hasNext()) { - val entry = reader.next() - delay(max(0, entry.start * 1000 - clock.millis())) - scheduler.submit(entry.workload) - } - } - - testScope.advanceUntilIdle() - recording.close() - - // Check whether everything went okay - testScope.uncaughtExceptions.forEach { it.printStackTrace() } - assert(testScope.uncaughtExceptions.isEmpty()) { "Errors occurred during execution of the experiment" } - } -} diff --git a/simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/WorkflowMetrics.kt b/simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/WorkflowMetrics.kt deleted file mode 100644 index a8356888..00000000 --- a/simulator/opendc-experiments/opendc-experiments-sc18/src/main/kotlin/org/opendc/experiments/sc18/WorkflowMetrics.kt +++ /dev/null @@ -1,86 +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.experiments.sc18 - -import org.opendc.trace.core.EventStream -import org.opendc.trace.core.onEvent -import org.opendc.workflow.service.WorkflowEvent -import java.util.* -import kotlin.coroutines.resume -import kotlin.coroutines.suspendCoroutine - -/** - * This function collects the makespan of workflows that appear in the event stream. - */ -public suspend fun EventStream.workflowRuntime(): Map = suspendCoroutine { cont -> - val starts = mutableMapOf() - val results = mutableMapOf() - - onEvent { - starts[it.job.uid] = it.timestamp - } - onEvent { - val start = starts.remove(it.job.uid) ?: return@onEvent - results[it.job.uid] = it.timestamp - start - } - onClose { cont.resume(results) } -} - -/** - * This function collects the waiting time of workflows that appear in the event stream, which the duration between the - * workflow submission and the start of the first task. - */ -public suspend fun EventStream.workflowWaitingTime(): Map = suspendCoroutine { cont -> - val starts = mutableMapOf() - val results = mutableMapOf() - - onEvent { - starts[it.job.uid] = it.timestamp - } - onEvent { - results.computeIfAbsent(it.job.uid) { _ -> - val start = starts.remove(it.job.uid)!! - it.timestamp - start - } - } - onClose { cont.resume(results) } -} - -/** - * This function collects the response time of tasks that appear in the event stream. - */ -public suspend fun EventStream.taskResponse(): Map = suspendCoroutine { cont -> - val starts = mutableMapOf() - val results = mutableMapOf() - - onEvent { - for (task in it.job.tasks) { - starts[task.uid] = it.timestamp - } - } - onEvent { - val start = starts.remove(it.job.uid) ?: return@onEvent - results[it.task.uid] = it.timestamp - start - } - onClose { cont.resume(results) } -} -- cgit v1.2.3