diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-06-21 14:34:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-21 14:34:10 +0200 |
| commit | ba32561e4b0e00c00d528df615a58e396e0fddc0 (patch) | |
| tree | 06bbb8161910a81b3dc1160b180650660bc50be4 /opendc-simulator/opendc-simulator-compute/src | |
| parent | b8b0f39028af90fa54b42a00214b2ea9a5e48e2e (diff) | |
| parent | 966715d7df139a431293f5c2fc67916fbcc1ecfb (diff) | |
simulator: Optimize resource interpreter implementation
This pull request implements several optimizations in the resource interpreter implementation.
* Interpreter is now shared across hosts in experiments
* Interpreter allocations are pooled where possible
* Resource lifecycle concept is eliminated
* Optimized flag management in interpreter
Diffstat (limited to 'opendc-simulator/opendc-simulator-compute/src')
2 files changed, 6 insertions, 7 deletions
diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt index d24ed1f3..c560cd28 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt +++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractHypervisor.kt @@ -129,6 +129,10 @@ public abstract class SimAbstractHypervisor( override fun close() { super.close() + for (cpu in cpus) { + cpu.close() + } + _vms.remove(this) } } @@ -137,9 +141,9 @@ public abstract class SimAbstractHypervisor( * A [SimProcessingUnit] of a virtual machine. */ private class VCpu( - private val source: SimResourceProvider, + private val source: SimResourceCloseableProvider, override val model: ProcessingUnit - ) : SimProcessingUnit, SimResourceProvider by source { + ) : SimProcessingUnit, SimResourceCloseableProvider by source { override var capacity: Double get() = source.capacity set(_) { diff --git a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt index 93d306cf..3a70680c 100644 --- a/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt +++ b/opendc-simulator/opendc-simulator-compute/src/main/kotlin/org/opendc/simulator/compute/SimAbstractMachine.kt @@ -115,11 +115,6 @@ public abstract class SimAbstractMachine( isTerminated = true cancel() - interpreter.batch { - for (cpu in cpus) { - cpu.close() - } - } } /* SimResourceSystem */ |
