diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2020-02-26 20:36:39 +0100 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2020-02-26 20:36:39 +0100 |
| commit | 9aed76152a03eaf76256691708c70508d12722c4 (patch) | |
| tree | 00e79ed9af36fbab83c0056698468df8a9efffaf /opendc/opendc-format/src/main | |
| parent | c44e9dce4da5deb900df11109dac51c1926cfabd (diff) | |
Model memory usage in VMs
Diffstat (limited to 'opendc/opendc-format/src/main')
4 files changed, 160 insertions, 5 deletions
diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt index 55061492..ac44337a 100644 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc18/Sc18EnvironmentReader.kt @@ -25,7 +25,7 @@ package com.atlarge.opendc.format.environment.sc18 import com.atlarge.opendc.compute.core.ProcessingUnit -import com.atlarge.opendc.compute.core.ServerFlavor +import com.atlarge.opendc.compute.core.MemoryUnit import com.atlarge.opendc.compute.metal.driver.SimpleBareMetalDriver import com.atlarge.opendc.compute.metal.service.ProvisioningService import com.atlarge.opendc.compute.metal.service.SimpleProvisioningService @@ -69,8 +69,7 @@ class Sc18EnvironmentReader(input: InputStream, mapper: ObjectMapper = jacksonOb else -> throw IllegalArgumentException("The cpu id $id is not recognized") } } - val flavor = ServerFlavor(cores) - SimpleBareMetalDriver(UUID.randomUUID(), "node-${counter++}", flavor) + SimpleBareMetalDriver(UUID.randomUUID(), "node-${counter++}", cores, listOf(MemoryUnit("", "", 2300.0, 16000))) } } } diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc20/Model.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc20/Model.kt new file mode 100644 index 00000000..3ef1d9eb --- /dev/null +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc20/Model.kt @@ -0,0 +1,45 @@ +package com.atlarge.opendc.format.environment.sc20 + +import com.fasterxml.jackson.annotation.JsonSubTypes +import com.fasterxml.jackson.annotation.JsonTypeInfo + +/** + * A datacenter setup. + * + * @property name The name of the setup. + * @property rooms The rooms in the datacenter. + */ +internal data class Setup(val name: String, val rooms: List<Room>) + +/** + * A room in a datacenter. + * + * @property type The type of room in the datacenter. + * @property objects The objects in the room. + */ +internal data class Room(val type: String, val objects: List<RoomObject>) + +/** + * An object in a [Room]. + * + * @property type The type of the room object. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type") +@JsonSubTypes(value = [JsonSubTypes.Type(name = "RACK", value = RoomObject.Rack::class)]) +internal sealed class RoomObject(val type: String) { + /** + * A rack in a server room. + * + * @property machines The machines in the rack. + */ + internal data class Rack(val machines: List<Machine>) : RoomObject("RACK") +} + +/** + * A machine in the setup that consists of the specified CPU's represented as + * integer identifiers and ethernet speed. + * + * @property cpus The CPUs in the machine represented as integer identifiers. + * @property memories The memories in the machine represented as integer identifiers. + */ +internal data class Machine(val cpus: List<Int>, val memories: List<Int>) diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc20/Sc20EnvironmentReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc20/Sc20EnvironmentReader.kt new file mode 100644 index 00000000..5eb711cc --- /dev/null +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/environment/sc20/Sc20EnvironmentReader.kt @@ -0,0 +1,106 @@ +/* + * MIT License + * + * Copyright (c) 2019 atlarge-research + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.atlarge.opendc.format.environment.sc20 + +import com.atlarge.opendc.compute.core.MemoryUnit +import com.atlarge.opendc.compute.core.ProcessingUnit +import com.atlarge.opendc.compute.metal.driver.SimpleBareMetalDriver +import com.atlarge.opendc.compute.metal.service.ProvisioningService +import com.atlarge.opendc.compute.metal.service.SimpleProvisioningService +import com.atlarge.opendc.core.Environment +import com.atlarge.opendc.core.Platform +import com.atlarge.opendc.core.Zone +import com.atlarge.opendc.core.services.ServiceRegistryImpl +import com.atlarge.opendc.format.environment.EnvironmentReader +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue +import kotlinx.coroutines.runBlocking +import java.io.InputStream +import java.util.UUID + +/** + * A parser for the JSON experiment setup files used for the SC20 paper. + * + * @param input The input stream to read from. + * @param mapper The Jackson object mapper to use. + */ +class Sc20EnvironmentReader(input: InputStream, mapper: ObjectMapper = jacksonObjectMapper()) : EnvironmentReader { + /** + * The environment that was read from the file. + */ + private val environment: Environment + + init { + val setup = mapper.readValue<Setup>(input) + var counter = 0 + val nodes = setup.rooms.flatMap { room -> + room.objects.flatMap { roomObject -> + when (roomObject) { + is RoomObject.Rack -> { + roomObject.machines.map { machine -> + val cores = machine.cpus.map { id -> + when (id) { + 1 -> ProcessingUnit("Intel", "Core(TM) i7-6920HQ", "amd64", 4100.0, 4) + 2 -> ProcessingUnit("Intel", "Core(TM) I7-6920HQ", "amd64", 3500.0, 2) + else -> throw IllegalArgumentException("The cpu id $id is not recognized") + } + } + val memories = machine.memories.map { id -> + when (id) { + 1 -> MemoryUnit("Samsung", "PC DRAM K4A4G045WD", 1600.0, 4_000L) + else -> throw IllegalArgumentException("The cpu id $id is not recognized") + } + } + SimpleBareMetalDriver(UUID.randomUUID(), "node-${counter++}", cores, memories) + } + } + } + } + } + + val provisioningService = SimpleProvisioningService() + runBlocking { + for (node in nodes) { + provisioningService.create(node) + } + } + + val serviceRegistry = ServiceRegistryImpl() + serviceRegistry[ProvisioningService.Key] = provisioningService + + val platform = Platform( + UUID.randomUUID(), "sc20-platform", listOf( + Zone(UUID.randomUUID(), "zone", serviceRegistry) + ) + ) + + environment = Environment(setup.name, null, listOf(platform)) + } + + override fun read(): Environment = environment + + override fun close() {} +} diff --git a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt index f4ed0f57..c3db9d33 100644 --- a/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt +++ b/opendc/opendc-format/src/main/kotlin/com/atlarge/opendc/format/trace/vm/VmTraceReader.kt @@ -55,6 +55,7 @@ class VmTraceReader(traceDirectory: File) : TraceReader<VmWorkload> { var timestampCol = 0 var coreCol = 0 var cpuUsageCol = 0 + var provisionedMemoryCol = 0 val traceInterval = 5 * 60 * 1000L traceDirectory.walk() @@ -64,6 +65,8 @@ class VmTraceReader(traceDirectory: File) : TraceReader<VmWorkload> { val flopsHistory = mutableListOf<FlopsHistoryFragment>() var vmId = -1L var cores = -1 + var requiredMemory = -1L + BufferedReader(FileReader(vmFile)).use { reader -> reader.lineSequence() .filter { line -> @@ -79,6 +82,7 @@ class VmTraceReader(traceDirectory: File) : TraceReader<VmWorkload> { timestampCol = header["Timestamp [ms]"]!! coreCol = header["CPU cores"]!! cpuUsageCol = header["CPU usage [MHZ]"]!! + provisionedMemoryCol = header["Memory capacity provisioned [KB]"]!! return@forEachIndexed } @@ -86,6 +90,7 @@ class VmTraceReader(traceDirectory: File) : TraceReader<VmWorkload> { val timestamp = values[timestampCol].trim().toLong() - 5 * 60 cores = values[coreCol].trim().toInt() val cpuUsage = values[cpuUsageCol].trim().toDouble() + requiredMemory = (values[provisionedMemoryCol].trim().toDouble() / 1000).toLong() val flops: Long = (cpuUsage * cores * 1_000_000L * 5 * 60).toLong() @@ -110,8 +115,8 @@ class VmTraceReader(traceDirectory: File) : TraceReader<VmWorkload> { val uuid = UUID(0L, vmId) val vmWorkload = VmWorkload( - uuid, "<unnamed>", UnnamedUser, - VmImage(uuid, "<unnamed>", emptyMap(), flopsHistory, cores) + uuid, "VM Workload $vmId", UnnamedUser, + VmImage(uuid, vmId.toString(), emptyMap(), flopsHistory, cores, requiredMemory) ) entries[vmId] = TraceEntryImpl( flopsHistory.firstOrNull()?.tick ?: -1, |
