diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-07-31 21:27:02 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-08-03 11:33:44 +0200 |
| commit | f6932d264db5b2e185ec7ea7aaec84dfb83f8fe9 (patch) | |
| tree | 523c63768501fefe9c2b9e1d12132c9a29ae1081 /opendc-web | |
| parent | 5deb055565606c94fc29bd594832586f3dfdf3de (diff) | |
feat(web/runner): Automatically compute experiment parallelism
This change updates the runner configuration to support specifying the
parallelism as zero to let the runtime decide the appropriate number of
threads based on the available CPU cores on the machine.
Diffstat (limited to 'opendc-web')
| -rw-r--r-- | opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java index b243dbc3..c1f356bc 100644 --- a/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java +++ b/opendc-web/opendc-web-runner-quarkus/src/main/java/org/opendc/web/runner/runtime/OpenDCRunnerRecorder.java @@ -44,11 +44,19 @@ public class OpenDCRunnerRecorder { */ public RuntimeValue<OpenDCRunner> createRunner(OpenDCRunnerRuntimeConfig config) { URI apiUrl = URI.create(config.apiUrl); + + int parallelism = config.parallelism; + if (parallelism < 0) { + throw new IllegalArgumentException("Parallelism must be non-negative"); + } else if (parallelism == 0) { + parallelism = Math.min(1, Runtime.getRuntime().availableProcessors() - 1); + } + OpenDCRunnerClient client = new OpenDCRunnerClient(apiUrl, null); OpenDCRunner runner = new OpenDCRunner( client, new File(config.tracePath), - config.parallelism, + parallelism, config.jobTimeout, config.pollInterval, config.heartbeatInterval |
