diff options
Diffstat (limited to 'opendc/opendc-compute/src/main')
2 files changed, 13 insertions, 63 deletions
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<ProcessorContext> = 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 - } -} |
