summaryrefslogtreecommitdiff
path: root/opendc/opendc-compute/src
diff options
context:
space:
mode:
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