Skip to content
Snippets Groups Projects
Commit a1af54d8 authored by Lorenz Boguhn's avatar Lorenz Boguhn
Browse files

Add stop of a running experiment by flag

+ Reimplement waitAndLog() in BechmarkExecutor
+ skipp analysis in BenchmarkExecutorImpl
+ Skipp further experiments
parent c6739061
No related branches found
No related tags found
4 merge requests!159Re-implementation of Theodolite with Kotlin/Quarkus,!157Update Graal Image in CI pipeline,!106Introduce a Theodolite operator,!83WIP: Re-implementation of Theodolite with Kotlin/Quarkus
package theodolite.execution package theodolite.execution
import io.smallrye.mutiny.helpers.Subscriptions.cancel
import mu.KotlinLogging import mu.KotlinLogging
import theodolite.benchmark.Benchmark import theodolite.benchmark.Benchmark
import theodolite.benchmark.BenchmarkExecution import theodolite.benchmark.BenchmarkExecution
...@@ -28,6 +27,8 @@ abstract class BenchmarkExecutor( ...@@ -28,6 +27,8 @@ abstract class BenchmarkExecutor(
val slo: BenchmarkExecution.Slo val slo: BenchmarkExecution.Slo
) { ) {
var run = true
/** /**
* Run a experiment for the given parametrization, evaluate the experiment and save the result. * Run a experiment for the given parametrization, evaluate the experiment and save the result.
* *
...@@ -38,7 +39,8 @@ abstract class BenchmarkExecutor( ...@@ -38,7 +39,8 @@ abstract class BenchmarkExecutor(
abstract fun runExperiment(load: LoadDimension, res: Resource): Boolean abstract fun runExperiment(load: LoadDimension, res: Resource): Boolean
fun stop() { fun stop() {
throw InterruptedException() run = false
//throw InterruptedException()
} }
/** /**
...@@ -47,12 +49,19 @@ abstract class BenchmarkExecutor( ...@@ -47,12 +49,19 @@ abstract class BenchmarkExecutor(
*/ */
fun waitAndLog() { fun waitAndLog() {
logger.info { "Execution of a new benchmark started." } logger.info { "Execution of a new benchmark started." }
for (i in 1.rangeTo(executionDuration.toSeconds())) {
var secondsRunning = 0L
while (run && secondsRunning < executionDuration.toSeconds()) {
secondsRunning++
Thread.sleep(Duration.ofSeconds(1).toMillis()) Thread.sleep(Duration.ofSeconds(1).toMillis())
if ((i % 60) == 0L) {
logger.info { "Executed: ${i / 60} minutes" } if ((secondsRunning % 60) == 0L) {
logger.info { "Executed: ${secondsRunning / 60} minutes" }
} }
} }
logger.info { "Exucutor shutdown gracefully" }
} }
} }
...@@ -20,15 +20,19 @@ class BenchmarkExecutorImpl( ...@@ -20,15 +20,19 @@ class BenchmarkExecutorImpl(
slo: BenchmarkExecution.Slo slo: BenchmarkExecution.Slo
) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo) { ) : BenchmarkExecutor(benchmark, results, executionDuration, configurationOverrides, slo) {
override fun runExperiment(load: LoadDimension, res: Resource): Boolean { override fun runExperiment(load: LoadDimension, res: Resource): Boolean {
var result = false
val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides) val benchmarkDeployment = benchmark.buildDeployment(load, res, this.configurationOverrides)
benchmarkDeployment.setup() benchmarkDeployment.setup()
this.waitAndLog() this.waitAndLog()
val result = AnalysisExecutor(slo = slo).analyse(load = load, res = res, executionDuration = executionDuration) if (this.run) {
result =
AnalysisExecutor(slo = slo).analyse(load = load, res = res, executionDuration = executionDuration)
benchmarkDeployment.teardown() benchmarkDeployment.teardown()
this.results.setResult(Pair(load, res), result) this.results.setResult(Pair(load, res), result)
}
return result return result
} }
} }
...@@ -19,7 +19,7 @@ class TheodoliteExecutor( ...@@ -19,7 +19,7 @@ class TheodoliteExecutor(
private var kubernetesBenchmark: KubernetesBenchmark private var kubernetesBenchmark: KubernetesBenchmark
) { ) {
private val executionThread = Thread() { private val executionThread = Thread() {
if(config == null || kubernetesBenchmark == null) { if (config == null || kubernetesBenchmark == null) {
logger.error { "Execution or Benchmark not found" } logger.error { "Execution or Benchmark not found" }
} else { } else {
val config = buildConfig() val config = buildConfig()
...@@ -98,7 +98,9 @@ class TheodoliteExecutor( ...@@ -98,7 +98,9 @@ class TheodoliteExecutor(
val config = buildConfig() val config = buildConfig()
// execute benchmarks for each load // execute benchmarks for each load
for (load in config.loads) { for (load in config.loads) {
config.compositeStrategy.findSuitableResource(load, config.resources) if (isRunning) {
config.compositeStrategy.findSuitableResource(load, config.resources)
}
} }
logger.info { "Stop Thread" } logger.info { "Stop Thread" }
} }
...@@ -109,6 +111,7 @@ class TheodoliteExecutor( ...@@ -109,6 +111,7 @@ class TheodoliteExecutor(
isRunning = false isRunning = false
try { try {
executor.stop() executor.stop()
Shutdown(config, kubernetesBenchmark).run()
} catch (e: InterruptedException) { } catch (e: InterruptedException) {
logger.warn { "Execution stopped" } logger.warn { "Execution stopped" }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment