diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-04-08 16:00:02 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-08 16:00:02 +0200 |
| commit | 3fd45fc5befb1fc9a67d4494e8a3786a5dceae3a (patch) | |
| tree | 739a8569545608068141288eb25ae80ce2597b7d /simulator/opendc-runner-web/src/main | |
| parent | 5d3b759b18fb0a4278b43dea6a9db478b07804a5 (diff) | |
| parent | 638dd7a33d5f7f0b8fcca9c99cdc92819cf0847c (diff) | |
exp: Add experiment for OpenDC Energy project
This pull requests adds an experiment to the repository for the OpenDC Energy project.
This experiment currently runs the Solvinity traces and tests how different energy
models perform.
* Add new experiment `opendc-experiments-energy21`
* Link experiment to `ConsoleRunner` so that the experiment can be run from the
command line.
* `BatchRecorder` is now used to emit all metrics at once after the hypervisor
finishes a slice.
Diffstat (limited to 'simulator/opendc-runner-web/src/main')
| -rw-r--r-- | simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/WebExperimentMonitor.kt | 127 |
1 files changed, 19 insertions, 108 deletions
diff --git a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/WebExperimentMonitor.kt b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/WebExperimentMonitor.kt index fcd43ea7..8f39b8ac 100644 --- a/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/WebExperimentMonitor.kt +++ b/simulator/opendc-runner-web/src/main/kotlin/org/opendc/runner/web/WebExperimentMonitor.kt @@ -36,52 +36,11 @@ import kotlin.math.max */ public class WebExperimentMonitor : ExperimentMonitor { private val logger = KotlinLogging.logger {} - private val currentHostEvent = mutableMapOf<Host, HostEvent>() - private var startTime = -1L - override fun reportVmStateChange(time: Long, server: Server, newState: ServerState) { - if (startTime < 0) { - startTime = time - - // Update timestamp of initial event - currentHostEvent.replaceAll { _, v -> v.copy(timestamp = startTime) } - } - } + override fun reportVmStateChange(time: Long, server: Server, newState: ServerState) {} override fun reportHostStateChange(time: Long, host: Host, newState: HostState) { logger.debug { "Host ${host.uid} changed state $newState [$time]" } - - val previousEvent = currentHostEvent[host] - - val roundedTime = previousEvent?.let { - val duration = time - it.timestamp - val k = 5 * 60 * 1000L // 5 min in ms - val rem = duration % k - - if (rem == 0L) { - time - } else { - it.timestamp + duration + k - rem - } - } ?: time - - reportHostSlice( - roundedTime, - 0, - 0, - 0, - 0, - 0.0, - 0.0, - 0, - host - ) - } - - private val lastPowerConsumption = mutableMapOf<Host, Double>() - - override fun reportPowerConsumption(host: Host, draw: Double) { - lastPowerConsumption[host] = draw } override fun reportHostSlice( @@ -92,69 +51,26 @@ public class WebExperimentMonitor : ExperimentMonitor { interferedBurst: Long, cpuUsage: Double, cpuDemand: Double, + powerDraw: Double, numberOfDeployedImages: Int, host: Host, - duration: Long ) { - val previousEvent = currentHostEvent[host] - when { - previousEvent == null -> { - val event = HostEvent( - time, - 5 * 60 * 1000L, - host, - numberOfDeployedImages, - requestedBurst, - grantedBurst, - overcommissionedBurst, - interferedBurst, - cpuUsage, - cpuDemand, - lastPowerConsumption[host] ?: 200.0, - host.model.cpuCount - ) - - currentHostEvent[host] = event - } - previousEvent.timestamp == time -> { - val event = HostEvent( - time, - previousEvent.duration, - host, - numberOfDeployedImages, - requestedBurst, - grantedBurst, - overcommissionedBurst, - interferedBurst, - cpuUsage, - cpuDemand, - lastPowerConsumption[host] ?: 200.0, - host.model.cpuCount - ) - - currentHostEvent[host] = event - } - else -> { - processHostEvent(previousEvent) - - val event = HostEvent( - time, - time - previousEvent.timestamp, - host, - numberOfDeployedImages, - requestedBurst, - grantedBurst, - overcommissionedBurst, - interferedBurst, - cpuUsage, - cpuDemand, - lastPowerConsumption[host] ?: 200.0, - host.model.cpuCount - ) - - currentHostEvent[host] = event - } - } + processHostEvent( + HostEvent( + time, + 5 * 60 * 1000L, + host, + numberOfDeployedImages, + requestedBurst, + grantedBurst, + overcommissionedBurst, + interferedBurst, + cpuUsage, + cpuDemand, + powerDraw, + host.model.cpuCount + ) + ) } private var hostAggregateMetrics: AggregateHostMetrics = AggregateHostMetrics() @@ -231,12 +147,7 @@ public class WebExperimentMonitor : ExperimentMonitor { val vmFailedCount: Int = 0 ) - override fun close() { - for ((_, event) in currentHostEvent) { - processHostEvent(event) - } - currentHostEvent.clear() - } + override fun close() {} public fun getResult(): Result { return Result( |
