summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-03-31 14:21:19 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-04-08 20:19:47 +0200
commitc2250720d694c6e7e19b3c0ba2fc27a124d3cadb (patch)
treeced033df6058dab132d9a6dbb488820ad6403c6a
parent1fb04ae372f96b32f9996c43fd066c98405ba634 (diff)
exp: Add trace reader for Serverless experiments
This change adds the trace reader for the serverless experiments as described in #48.
-rw-r--r--simulator/opendc-experiments/opendc-experiments-serverless20/README.md7
-rw-r--r--simulator/opendc-experiments/opendc-experiments-serverless20/build.gradle.kts40
-rw-r--r--simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionSample.kt44
-rw-r--r--simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionTrace.kt28
-rw-r--r--simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/ServerlessTraceReader.kt94
-rw-r--r--simulator/settings.gradle.kts1
6 files changed, 214 insertions, 0 deletions
diff --git a/simulator/opendc-experiments/opendc-experiments-serverless20/README.md b/simulator/opendc-experiments/opendc-experiments-serverless20/README.md
new file mode 100644
index 00000000..40855ad0
--- /dev/null
+++ b/simulator/opendc-experiments/opendc-experiments-serverless20/README.md
@@ -0,0 +1,7 @@
+OpenDC Serverless
+=================
+
+This module contains a reproduction of the experiments of Soufiane Jounaid's BSc Computer Science thesis:
+OpenDC Serverless: Design, Implementation and Evaluation of a FaaS Platform Simulator [1]
+
+[1] https://drive.google.com/file/d/12hox3PwagpD0jNFA57tO4r2HqvOonkY3/view?usp=sharing
diff --git a/simulator/opendc-experiments/opendc-experiments-serverless20/build.gradle.kts b/simulator/opendc-experiments/opendc-experiments-serverless20/build.gradle.kts
new file mode 100644
index 00000000..4c7d97b1
--- /dev/null
+++ b/simulator/opendc-experiments/opendc-experiments-serverless20/build.gradle.kts
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2020 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.
+ */
+
+description = "Experiments for OpenDC Serverless"
+
+/* Build configuration */
+plugins {
+ `kotlin-library-conventions`
+ `experiment-conventions`
+ `testing-conventions`
+}
+
+dependencies {
+ api(platform(project(":opendc-platform")))
+ api(project(":opendc-harness"))
+ implementation(project(":opendc-serverless:opendc-serverless-service"))
+ implementation(project(":opendc-serverless:opendc-serverless-simulator"))
+ implementation(project(":opendc-telemetry:opendc-telemetry-sdk"))
+
+ implementation("io.github.microutils:kotlin-logging")
+}
diff --git a/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionSample.kt b/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionSample.kt
new file mode 100644
index 00000000..492f44b9
--- /dev/null
+++ b/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionSample.kt
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2021 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 org.opendc.experiments.serverless.trace
+
+/**
+ * A sample of a single function.
+ *
+ * @param timestamp The timestamp of the function.
+ * @param duration The average execution time of the function.
+ * @param invocations The number of invocations.
+ * @param provisionedCpu The provisioned CPU for this function in MHz.
+ * @param provisionedMem The amount of memory provisioned for this function in MB.
+ * @param cpuUsage The actual CPU usage in MHz.
+ * @param memUsage The actual memory usage in MB.
+ */
+public data class FunctionSample(
+ val timestamp: Long,
+ val duration: Long,
+ val invocations: Int,
+ val provisionedCpu: Int,
+ val provisionedMem: Int,
+ val cpuUsage: Double,
+ val memUsage: Double
+)
diff --git a/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionTrace.kt b/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionTrace.kt
new file mode 100644
index 00000000..97c98e2a
--- /dev/null
+++ b/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/FunctionTrace.kt
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2021 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 org.opendc.experiments.serverless.trace
+
+/**
+ * A trace for a single function
+ */
+public data class FunctionTrace(val id: String, val samples: List<FunctionSample>)
diff --git a/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/ServerlessTraceReader.kt b/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/ServerlessTraceReader.kt
new file mode 100644
index 00000000..87dd33fa
--- /dev/null
+++ b/simulator/opendc-experiments/opendc-experiments-serverless20/src/main/kotlin/org/opendc/experiments/serverless/trace/ServerlessTraceReader.kt
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2021 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 org.opendc.experiments.serverless.trace
+
+import java.io.File
+
+/**
+ * A trace reader for the serverless workload trace used in the OpenDC Serverless thesis.
+ */
+public class ServerlessTraceReader {
+ /**
+ * Parse the traces at the specified [path].
+ */
+ public fun parse(path: File): List<FunctionTrace> {
+ return if (path.isFile) {
+ listOf(parseSingle(path))
+ } else {
+ path.walk()
+ .filterNot { it.isDirectory }
+ .map { parseSingle(it) }
+ .toList()
+ }
+ }
+
+ /**
+ * Parse a single trace.
+ */
+ private fun parseSingle(path: File): FunctionTrace {
+ val samples = mutableListOf<FunctionSample>()
+ val id = path.nameWithoutExtension
+ var idx = 0
+
+ var timestampCol = 0
+ var invocationsCol = 0
+ var execTimeCol = 0
+ var provCpuCol = 0
+ var provMemCol = 0
+ var cpuUsageCol = 0
+ var memoryUsageCol = 0
+
+ path.forEachLine { line ->
+ if (line.startsWith("#") && line.isNotBlank()) {
+ return@forEachLine
+ }
+
+ val values = line.split(",")
+
+ /* Header parsing */
+ if (++idx == 0){
+ val header = values.mapIndexed { col, name -> Pair(name.trim(), col) }.toMap()
+ timestampCol = header["Timestamp [ms]"]!!
+ invocationsCol = header["Invocations"]!!
+ execTimeCol = header["Avg Exec time per Invocation"]!!
+ provCpuCol = header["Provisioned CPU [Mhz]"]!!
+ provMemCol = header["Provisioned Memory [mb]"]!!
+ cpuUsageCol = header["Avg cpu usage per Invocation [Mhz]"]!!
+ memoryUsageCol = header["Avg mem usage per Invocation [mb]"]!!
+ return@forEachLine
+ }
+
+ val timestamp = values[timestampCol].trim().toLong()
+ val invocations = values[invocationsCol].trim().toInt()
+ val execTime = values[execTimeCol].trim().toLong()
+ val provisionedCpu = values[provCpuCol].trim().toInt()
+ val provisionedMemory = values[provMemCol].trim().toInt()
+ val cpuUsage = values[cpuUsageCol].trim().toDouble()
+ val memoryUsage = values[memoryUsageCol].trim().toDouble()
+
+ samples.add(FunctionSample(timestamp, execTime, invocations, provisionedCpu, provisionedMemory, cpuUsage, memoryUsage))
+ }
+
+ return FunctionTrace(id, samples)
+ }
+}
diff --git a/simulator/settings.gradle.kts b/simulator/settings.gradle.kts
index 3de0da5a..b80b394e 100644
--- a/simulator/settings.gradle.kts
+++ b/simulator/settings.gradle.kts
@@ -33,6 +33,7 @@ include(":opendc-serverless:opendc-serverless-simulator")
include(":opendc-format")
include(":opendc-experiments:opendc-experiments-capelin")
include(":opendc-experiments:opendc-experiments-energy21")
+include(":opendc-experiments:opendc-experiments-serverless20")
include(":opendc-runner-web")
include(":opendc-simulator:opendc-simulator-core")
include(":opendc-simulator:opendc-simulator-resources")