summaryrefslogtreecommitdiff
path: root/opendc/opendc-core/src/main
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-04-15 12:16:42 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-04-15 12:16:42 +0200
commita77829c7a8cf300a99a695423d85f905e0209286 (patch)
treef31200cdc3f108ea9b6d622df44a972ed5eed46d /opendc/opendc-core/src/main
parentae23970faa77c89408a4e98cb9259fb53e222bd3 (diff)
perf: Optimize performance interference
Diffstat (limited to 'opendc/opendc-core/src/main')
-rw-r--r--opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt83
1 files changed, 0 insertions, 83 deletions
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
deleted file mode 100644
index 04056394..00000000
--- a/opendc/opendc-core/src/main/kotlin/com/atlarge/opendc/core/workload/PerformanceInterferenceModel.kt
+++ /dev/null
@@ -1,83 +0,0 @@
-package com.atlarge.opendc.core.workload
-
-import com.atlarge.opendc.core.resource.Resource
-import kotlin.random.Random
-
-/**
- * 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.
- *
- * @param items The [PerformanceInterferenceModelItem]s that make up this model.
- */
-data class PerformanceInterferenceModel(
- val items: Set<PerformanceInterferenceModelItem>,
- val random: Random = Random(0)
-) {
- private var intersectingItems: List<PerformanceInterferenceModelItem> = emptyList()
- private var comparator = Comparator<PerformanceInterferenceModelItem> { lhs, rhs ->
- var cmp = lhs.performanceScore.compareTo(rhs.performanceScore)
- if (cmp != 0) {
- return@Comparator cmp
- }
-
- cmp = lhs.minServerLoad.compareTo(rhs.minServerLoad)
- if (cmp != 0) {
- return@Comparator cmp
- }
-
- 0
- }
-
- fun computeIntersectingItems(colocatedWorkloads: Set<Resource>) {
- val colocatedWorkloadIds = colocatedWorkloads.map { it.name }
- intersectingItems = items.filter { item ->
- colocatedWorkloadIds.intersect(item.workloadNames).size > 1
- }.sortedWith(comparator)
- }
-
- fun apply(currentServerLoad: Double): Double {
- if (intersectingItems.isEmpty()) {
- return 1.0
- }
- val score = intersectingItems
- .firstOrNull { it.minServerLoad <= currentServerLoad }
-
- // Apply performance penalty to (on average) only one of the VMs
- return if (score != null && random.nextInt(score.workloadNames.size) == 0) {
- score.performanceScore
- } else {
- 1.0
- }
- }
-}
-
-/**
- * Model describing how a specific set of workloads causes performance variability for each workload.
- *
- * @param workloadNames The names of the workloads that together cause performance variability for each workload in the set.
- * @param minServerLoad The minimum total server load at which this interference is activated and noticeable.
- * @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 workloadNames: Set<String>,
- val minServerLoad: Double,
- val performanceScore: Double
-) {
- override fun equals(other: Any?): Boolean {
- if (this === other) return true
- if (javaClass != other?.javaClass) return false
-
- other as PerformanceInterferenceModelItem
-
- if (workloadNames != other.workloadNames) return false
-
- return true
- }
-
- override fun hashCode(): Int = workloadNames.hashCode()
-}