From 40ac395ee59dbb4ae16b7b77581cd14245c71f39 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 28 Feb 2020 15:14:02 +0100 Subject: Give vCPUs access to their hosted VM This should make performance interference based onn the colocated VMs possible. --- .../virt/driver/hypervisor/VmServerContext.kt | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt (limited to 'opendc') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt new file mode 100644 index 00000000..f8fb2033 --- /dev/null +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt @@ -0,0 +1,61 @@ +package com.atlarge.opendc.compute.virt.driver.hypervisor + +import com.atlarge.odcsim.SimulationContext +import com.atlarge.opendc.compute.core.Server +import com.atlarge.opendc.compute.core.ServerState +import com.atlarge.opendc.compute.core.execution.ProcessorContext +import com.atlarge.opendc.compute.core.execution.ServerManagementContext +import com.atlarge.opendc.compute.core.monitor.ServerMonitor +import kotlinx.coroutines.Job +import kotlinx.coroutines.launch + +/** + * The execution context of an image running as a server. + * + * @property server The server instance of this execution context. + * @property monitor The monitor that should be informed on changes. + * @property scheduler The local VM scheduler. + * @property onExit The callback to be invoked on exit of the server. + * @param ctx The simulation context in which this server is running. + */ +class VmServerContext( + override var server: Server, + val monitor: ServerMonitor, + val scheduler: VmScheduler, + val onExit: () -> Unit, + ctx: SimulationContext +) : ServerManagementContext { + private var initialized: Boolean = false + + internal val job: Job = ctx.domain.launch { + init() + try { + server.image(this@VmServerContext) + exit() + } catch (cause: Throwable) { + exit(cause) + } + } + + override val cpus: List = scheduler.createVirtualCpus(server.flavor, this) + + override suspend fun init() { + if (initialized) { + throw IllegalStateException() + } + + val previousState = server.state + server = server.copy(state = ServerState.ACTIVE) + monitor.onUpdate(server, previousState) + initialized = true + } + + override suspend fun exit(cause: Throwable?) { + val previousState = server.state + val state = if (cause == null) ServerState.SHUTOFF else ServerState.ERROR + server = server.copy(state = state) + onExit() + monitor.onUpdate(server, previousState) + initialized = false + } +} -- cgit v1.2.3 From 185c0ab39225e1c6d45122626f90e79c2f2f3cc4 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 28 Feb 2020 15:23:45 +0100 Subject: Make onExit suspending --- .../atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'opendc') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt index f8fb2033..60fdf082 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt @@ -22,7 +22,7 @@ class VmServerContext( override var server: Server, val monitor: ServerMonitor, val scheduler: VmScheduler, - val onExit: () -> Unit, + val onExit: suspend () -> Unit, ctx: SimulationContext ) : ServerManagementContext { private var initialized: Boolean = false -- cgit v1.2.3 From 78417251806e079c998380a76ab3533de373289b Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Mon, 2 Mar 2020 13:15:11 +0100 Subject: [ci skip] Add performance interference model start --- .../core/workload/PerformanceInterferenceModel.kt | 50 ++++++++++++++++++ .../opendc/experiments/sc20/TestExperiment.kt | 5 ++ .../resources/env/performance-interference.json | 2 + .../trace/PerformanceInterferenceModelReader.kt | 38 ++++++++++++++ .../com/atlarge/opendc/format/trace/sc20/Model.kt | 6 +++ .../sc20/Sc20PerformanceInterferenceReader.kt | 61 ++++++++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100644 opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt create mode 100644 opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json create mode 100644 opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/PerformanceInterferenceModelReader.kt create mode 100644 opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt create mode 100644 opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20PerformanceInterferenceReader.kt (limited to 'opendc') diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt new file mode 100644 index 00000000..310b3a27 --- /dev/null +++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt @@ -0,0 +1,50 @@ +package com.atlarge.opendc.core.workload + +import java.util.UUID + +/** + * Performance Interference Model describing the variability incurred by different sets of workloads if colocated. + * + * @param items The [PerformanceInterferenceModelItem]s that make up this model. + */ +data class PerformanceInterferenceModel( + val items: Set +) { + fun apply(colocatedWorkloads: Set): Double { + val intersectingItems = items.filter { item -> + colocatedWorkloads.map { it.uid }.intersect(item.workloadIds).size > 1 + } + + if (intersectingItems.isEmpty()) { + return 1.0 + } + return intersectingItems.map { it.performanceScore }.min() ?: error("Minimum score must exist.") + } +} + +/** + * Model describing how a specific set of workloads causes performance variability for each workload. + * + * @param workloadIds The IDs of the workloads that together cause performance variability for each workload in the set. + * @param performanceScore The performance score that should be applied to each workload's performance. 1 means no + * influence, <1 means that performance degrades, and >1 means that performance improves. + */ +data class PerformanceInterferenceModelItem( + val workloadIds: Set, + val performanceScore: Double +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as PerformanceInterferenceModelItem + + if (workloadIds != other.workloadIds) return false + + return true + } + + override fun hashCode(): Int { + return workloadIds.hashCode() + } +} diff --git a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt index daa40193..7a67fc23 100644 --- a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt +++ b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt @@ -34,6 +34,7 @@ import com.atlarge.opendc.compute.metal.service.ProvisioningService import com.atlarge.opendc.compute.virt.service.SimpleVirtProvisioningService import com.atlarge.opendc.compute.virt.service.allocation.AvailableMemoryAllocationPolicy import com.atlarge.opendc.format.environment.sc20.Sc20EnvironmentReader +import com.atlarge.opendc.format.trace.sc20.Sc20PerformanceInterferenceReader import com.atlarge.opendc.format.trace.vm.VmTraceReader import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.delay @@ -67,6 +68,10 @@ fun main(args: Array) { val environment = Sc20EnvironmentReader(object {}.javaClass.getResourceAsStream("/env/setup-small.json")) .use { it.construct(root) } + val performanceInterferenceModel = Sc20PerformanceInterferenceReader( + object {}.javaClass.getResourceAsStream("/env/performance-interference.json") + ).construct() + println(simulationContext.clock.instant()) val scheduler = SimpleVirtProvisioningService( diff --git a/opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json b/opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json new file mode 100644 index 00000000..0d4f101c --- /dev/null +++ b/opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json @@ -0,0 +1,2 @@ +[ +] diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/PerformanceInterferenceModelReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/PerformanceInterferenceModelReader.kt new file mode 100644 index 00000000..f9ebba3d --- /dev/null +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/PerformanceInterferenceModelReader.kt @@ -0,0 +1,38 @@ +/* + * MIT License + * + * 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. + */ + +package com.atlarge.opendc.format.trace + +import com.atlarge.opendc.core.workload.PerformanceInterferenceModel +import java.io.Closeable + +/** + * An interface for reading descriptions of performance interference models into memory. + */ +interface PerformanceInterferenceModelReader : Closeable { + /** + * Construct a [PerformanceInterferenceModel]. + */ + fun construct(): PerformanceInterferenceModel +} diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt new file mode 100644 index 00000000..1eeecb25 --- /dev/null +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt @@ -0,0 +1,6 @@ +package com.atlarge.opendc.format.trace.sc20 + +internal data class PerformanceInterferenceEntry( + val vms: List, + val performanceScore: Double +) diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20PerformanceInterferenceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20PerformanceInterferenceReader.kt new file mode 100644 index 00000000..b2d60bb9 --- /dev/null +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Sc20PerformanceInterferenceReader.kt @@ -0,0 +1,61 @@ +/* + * MIT License + * + * 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. + */ + +package com.atlarge.opendc.format.trace.sc20 + +import com.atlarge.opendc.core.workload.PerformanceInterferenceModel +import com.atlarge.opendc.core.workload.PerformanceInterferenceModelItem +import com.atlarge.opendc.format.trace.PerformanceInterferenceModelReader +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue +import java.io.InputStream +import java.util.UUID + +/** + * A parser for the JSON performance interference setup files used for the SC20 paper. + * + * @param input The input stream to read from. + * @param mapper The Jackson object mapper to use. + */ +class Sc20PerformanceInterferenceReader(input: InputStream, mapper: ObjectMapper = jacksonObjectMapper()) : + PerformanceInterferenceModelReader { + /** + * The environment that was read from the file. + */ + private val performanceInterferenceModel: List = mapper.readValue(input) + + override fun construct(): PerformanceInterferenceModel { + return PerformanceInterferenceModel( + performanceInterferenceModel.map { item -> + PerformanceInterferenceModelItem( + item.vms.map { name -> UUID(0L, name.toLong()) }.toSet(), + item.performanceScore + ) + }.toSet() + ) + } + + override fun close() {} +} -- cgit v1.2.3 From 0dd7ae2ed80fb4f581a3e56a3f7d5d4a920a32b7 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Mon, 2 Mar 2020 17:04:02 +0100 Subject: Move performance interference to image tags --- .../core/workload/PerformanceInterferenceModel.kt | 6 ++++-- .../opendc/experiments/sc20/TestExperiment.kt | 2 +- .../resources/env/performance-interference.json | 4 ++++ .../atlarge/opendc/format/trace/vm/VmTraceReader.kt | 21 +++++++++++++++++++-- 4 files changed, 28 insertions(+), 5 deletions(-) (limited to 'opendc') diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt index 310b3a27..54052a0e 100644 --- a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt +++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt @@ -1,5 +1,6 @@ package com.atlarge.opendc.core.workload +import com.atlarge.opendc.core.resource.Resource import java.util.UUID /** @@ -10,9 +11,10 @@ import java.util.UUID data class PerformanceInterferenceModel( val items: Set ) { - fun apply(colocatedWorkloads: Set): Double { + fun apply(colocatedWorkloads: Set): Double { + val colocatedWorkloadIds = colocatedWorkloads.map { it.uid } val intersectingItems = items.filter { item -> - colocatedWorkloads.map { it.uid }.intersect(item.workloadIds).size > 1 + colocatedWorkloadIds.intersect(item.workloadIds).size > 1 } if (intersectingItems.isEmpty()) { diff --git a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt index 7a67fc23..f4be75fa 100644 --- a/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt +++ b/opendc/opendc-experiments-sc20/src/main/kotlin/com/atlarge/opendc/experiments/sc20/TestExperiment.kt @@ -81,7 +81,7 @@ fun main(args: Array) { Sc20HypervisorMonitor() ) - val reader = VmTraceReader(File(args[0])) + val reader = VmTraceReader(File(args[0]), performanceInterferenceModel) delay(1376314846 * 1000L) while (reader.hasNext()) { val (time, workload) = reader.next() diff --git a/opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json b/opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json index 0d4f101c..e2437693 100644 --- a/opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json +++ b/opendc/opendc-experiments-sc20/src/main/resources/env/performance-interference.json @@ -1,2 +1,6 @@ [ + { + "vms": [545, 223], + "performanceScore": 0.6 + } ] diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt index 2e881a6c..2867e993 100644 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt @@ -28,6 +28,7 @@ import com.atlarge.opendc.compute.core.image.FlopsHistoryFragment import com.atlarge.opendc.compute.core.image.VmImage import com.atlarge.opendc.compute.core.workload.VmWorkload import com.atlarge.opendc.core.User +import com.atlarge.opendc.core.workload.PerformanceInterferenceModel import com.atlarge.opendc.format.trace.TraceEntry import com.atlarge.opendc.format.trace.TraceReader import java.io.BufferedReader @@ -39,8 +40,12 @@ import java.util.UUID * A [TraceReader] for the VM workload trace format. * * @param traceDirectory The directory of the traces. + * @param performanceInterferenceModel The performance model covering the workload in the VM trace. */ -class VmTraceReader(traceDirectory: File) : TraceReader { +class VmTraceReader( + traceDirectory: File, + performanceInterferenceModel: PerformanceInterferenceModel +) : TraceReader { /** * The internal iterator to use for this reader. */ @@ -115,9 +120,21 @@ class VmTraceReader(traceDirectory: File) : TraceReader { } val uuid = UUID(0L, vmId) + + val relevantPerformanceInterferenceModelItems = PerformanceInterferenceModel( + performanceInterferenceModel.items.filter { it.workloadIds.contains(uuid) }.toSet() + ) + val vmWorkload = VmWorkload( uuid, "VM Workload $vmId", UnnamedUser, - VmImage(uuid, vmId.toString(), emptyMap(), flopsHistory, cores, requiredMemory) + VmImage( + uuid, + vmId.toString(), + mapOf("performance-interference" to relevantPerformanceInterferenceModelItems), + flopsHistory, + cores, + requiredMemory + ) ) entries[vmId] = TraceEntryImpl( flopsHistory.firstOrNull()?.tick ?: -1, -- cgit v1.2.3 From 4e970798cce73906de212ca26ba64cb470478a9b Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 4 Mar 2020 18:21:23 +0100 Subject: Fix rebase --- .../virt/driver/hypervisor/HypervisorVirtDriver.kt | 15 +++++- .../virt/driver/hypervisor/VmServerContext.kt | 61 ---------------------- 2 files changed, 13 insertions(+), 63 deletions(-) delete mode 100644 opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt (limited to 'opendc') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt index 3f358516..006b31e1 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt @@ -26,9 +26,9 @@ package com.atlarge.opendc.compute.virt.driver.hypervisor import com.atlarge.odcsim.SimulationContext import com.atlarge.odcsim.simulationContext -import com.atlarge.opendc.compute.core.Server import com.atlarge.opendc.compute.core.Flavor import com.atlarge.opendc.compute.core.ProcessingUnit +import com.atlarge.opendc.compute.core.Server import com.atlarge.opendc.compute.core.ServerState import com.atlarge.opendc.compute.core.execution.ServerContext import com.atlarge.opendc.compute.core.execution.ServerManagementContext @@ -37,6 +37,7 @@ import com.atlarge.opendc.compute.core.monitor.ServerMonitor import com.atlarge.opendc.compute.virt.driver.VirtDriver import com.atlarge.opendc.compute.virt.driver.VirtDriverMonitor import com.atlarge.opendc.compute.virt.monitor.HypervisorMonitor +import com.atlarge.opendc.core.workload.PerformanceInterferenceModel import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Job import kotlinx.coroutines.channels.Channel @@ -135,7 +136,17 @@ class HypervisorVirtDriver( val burst = LongArray(hostContext.cpus.size) + val imagesRunning = vms.map { it.server.image }.toSet() + for (vm in vms) { + var performanceScore = 1.0 + + // Apply performance interference model + if (vm.server.image.tags.containsKey("performance-interference")) { + performanceScore = (vm.server.image.tags["performance-interference"] + as PerformanceInterferenceModel).apply(imagesRunning) + } + for (i in 0 until min(vm.cpus.size, vm.requestedBurst.size)) { val cpu = vm.cpus[i] @@ -143,7 +154,7 @@ class HypervisorVirtDriver( val actualUsage = min(vm.limit[i], cpu.frequency / vms.size) val actualBurst = (duration * actualUsage * 1_000_000L).toLong() - burst[i] += actualBurst + burst[i] += (performanceScore * actualBurst).toLong() } } diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt deleted file mode 100644 index 60fdf082..00000000 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/VmServerContext.kt +++ /dev/null @@ -1,61 +0,0 @@ -package com.atlarge.opendc.compute.virt.driver.hypervisor - -import com.atlarge.odcsim.SimulationContext -import com.atlarge.opendc.compute.core.Server -import com.atlarge.opendc.compute.core.ServerState -import com.atlarge.opendc.compute.core.execution.ProcessorContext -import com.atlarge.opendc.compute.core.execution.ServerManagementContext -import com.atlarge.opendc.compute.core.monitor.ServerMonitor -import kotlinx.coroutines.Job -import kotlinx.coroutines.launch - -/** - * The execution context of an image running as a server. - * - * @property server The server instance of this execution context. - * @property monitor The monitor that should be informed on changes. - * @property scheduler The local VM scheduler. - * @property onExit The callback to be invoked on exit of the server. - * @param ctx The simulation context in which this server is running. - */ -class VmServerContext( - override var server: Server, - val monitor: ServerMonitor, - val scheduler: VmScheduler, - val onExit: suspend () -> Unit, - ctx: SimulationContext -) : ServerManagementContext { - private var initialized: Boolean = false - - internal val job: Job = ctx.domain.launch { - init() - try { - server.image(this@VmServerContext) - exit() - } catch (cause: Throwable) { - exit(cause) - } - } - - override val cpus: List = scheduler.createVirtualCpus(server.flavor, this) - - override suspend fun init() { - if (initialized) { - throw IllegalStateException() - } - - val previousState = server.state - server = server.copy(state = ServerState.ACTIVE) - monitor.onUpdate(server, previousState) - initialized = true - } - - override suspend fun exit(cause: Throwable?) { - val previousState = server.state - val state = if (cause == null) ServerState.SHUTOFF else ServerState.ERROR - server = server.copy(state = state) - onExit() - monitor.onUpdate(server, previousState) - initialized = false - } -} -- cgit v1.2.3 From 0f75b440d709f8a80efdb441d02b7bd47318a22c Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 4 Mar 2020 18:32:58 +0100 Subject: Fix file name ktlint suggestion --- .../src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt | 6 ------ .../opendc/format/trace/sc20/PerformanceInterferenceEntry.kt | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt create mode 100644 opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/PerformanceInterferenceEntry.kt (limited to 'opendc') diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt deleted file mode 100644 index 1eeecb25..00000000 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/Model.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.atlarge.opendc.format.trace.sc20 - -internal data class PerformanceInterferenceEntry( - val vms: List, - val performanceScore: Double -) diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/PerformanceInterferenceEntry.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/PerformanceInterferenceEntry.kt new file mode 100644 index 00000000..1eeecb25 --- /dev/null +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/sc20/PerformanceInterferenceEntry.kt @@ -0,0 +1,6 @@ +package com.atlarge.opendc.format.trace.sc20 + +internal data class PerformanceInterferenceEntry( + val vms: List, + val performanceScore: Double +) -- cgit v1.2.3 From 0930e73c319ecd01ecdae47e15f077555c12db0c Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 9 Mar 2020 20:46:28 +0100 Subject: feat: Define key for performance interference model of image --- .../compute/virt/driver/hypervisor/HypervisorVirtDriver.kt | 9 +++------ .../atlarge/opendc/core/workload/PerformanceInterferenceModel.kt | 5 +++++ .../kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'opendc') diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt index 006b31e1..6fe11c28 100644 --- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt +++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/hypervisor/HypervisorVirtDriver.kt @@ -37,6 +37,7 @@ import com.atlarge.opendc.compute.core.monitor.ServerMonitor import com.atlarge.opendc.compute.virt.driver.VirtDriver import com.atlarge.opendc.compute.virt.driver.VirtDriverMonitor import com.atlarge.opendc.compute.virt.monitor.HypervisorMonitor +import com.atlarge.opendc.core.workload.IMAGE_PERF_INTERFERENCE_MODEL import com.atlarge.opendc.core.workload.PerformanceInterferenceModel import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Job @@ -139,13 +140,9 @@ class HypervisorVirtDriver( val imagesRunning = vms.map { it.server.image }.toSet() for (vm in vms) { - var performanceScore = 1.0 - // Apply performance interference model - if (vm.server.image.tags.containsKey("performance-interference")) { - performanceScore = (vm.server.image.tags["performance-interference"] - as PerformanceInterferenceModel).apply(imagesRunning) - } + val performanceModel = vm.server.image.tags[IMAGE_PERF_INTERFERENCE_MODEL] as? PerformanceInterferenceModel? + val performanceScore = performanceModel?.apply(imagesRunning) ?: 1.0 for (i in 0 until min(vm.cpus.size, vm.requestedBurst.size)) { val cpu = vm.cpus[i] diff --git a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt index 54052a0e..5e0928b7 100644 --- a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt +++ b/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt @@ -3,6 +3,11 @@ package com.atlarge.opendc.core.workload import com.atlarge.opendc.core.resource.Resource import java.util.UUID +/** + * Meta-data key for the [PerformanceInterferenceModel] of an image. + */ +const val IMAGE_PERF_INTERFERENCE_MODEL = "image:performance-interference" + /** * Performance Interference Model describing the variability incurred by different sets of workloads if colocated. * diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt index 2867e993..2adf99b1 100644 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt @@ -28,6 +28,7 @@ import com.atlarge.opendc.compute.core.image.FlopsHistoryFragment import com.atlarge.opendc.compute.core.image.VmImage import com.atlarge.opendc.compute.core.workload.VmWorkload import com.atlarge.opendc.core.User +import com.atlarge.opendc.core.workload.IMAGE_PERF_INTERFERENCE_MODEL import com.atlarge.opendc.core.workload.PerformanceInterferenceModel import com.atlarge.opendc.format.trace.TraceEntry import com.atlarge.opendc.format.trace.TraceReader @@ -130,7 +131,7 @@ class VmTraceReader( VmImage( uuid, vmId.toString(), - mapOf("performance-interference" to relevantPerformanceInterferenceModelItems), + mapOf(IMAGE_PERF_INTERFERENCE_MODEL to relevantPerformanceInterferenceModelItems), flopsHistory, cores, requiredMemory -- cgit v1.2.3