summaryrefslogtreecommitdiff
path: root/opendc/opendc-compute/src
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-04-01 18:32:04 +0200
committerGeorgios Andreadis <info@gandreadis.com>2020-04-01 18:32:04 +0200
commit896c6e2fa2cb84be2f383b39bf81c40101647694 (patch)
treeea9d927e9e0678aef014156a95168570494fa924 /opendc/opendc-compute/src
parentc4493dfef3daca816378760f7abf6ed0d2475099 (diff)
Optimizes the performance interference model logic
Credits to Fabian for the idea!
Diffstat (limited to 'opendc/opendc-compute/src')
-rw-r--r--opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt15
1 files changed, 13 insertions, 2 deletions
diff --git a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt
index 3086f4e6..00368c43 100644
--- a/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt
+++ b/opendc/opendc-compute/src/main/kotlin/com/atlarge/opendc/compute/virt/driver/SimpleVirtDriver.kt
@@ -50,6 +50,7 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import java.util.UUID
import kotlin.math.ceil
@@ -87,6 +88,17 @@ class SimpleVirtDriver(
override val events: Flow<HypervisorEvent> = eventFlow
+ init {
+ events.onEach {
+ val imagesRunning = vms.map { it.server.image }.toSet()
+ vms.forEach {
+ val performanceModel =
+ it.server.image.tags[IMAGE_PERF_INTERFERENCE_MODEL] as? PerformanceInterferenceModel?
+ performanceModel?.computeIntersectingItems(imagesRunning)
+ }
+ }
+ }
+
override suspend fun spawn(
name: String,
image: Image,
@@ -193,13 +205,12 @@ class SimpleVirtDriver(
val totalRemainder = remainder.sum()
val totalBurst = burst.sum()
- val imagesRunning = vms.map { it.server.image }.toSet()
for (vm in vms) {
// Apply performance interference model
val performanceModel =
vm.server.image.tags[IMAGE_PERF_INTERFERENCE_MODEL] as? PerformanceInterferenceModel?
- val performanceScore = performanceModel?.apply(imagesRunning, serverLoad) ?: 1.0
+ val performanceScore = performanceModel?.apply(serverLoad) ?: 1.0
for ((i, req) in vm.requests.withIndex()) {
// Compute the fraction of compute time allocated to the VM