diff --git a/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sConfig.groovy b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sConfig.groovy index 2010162..add4f2e 100644 --- a/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sConfig.groovy +++ b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sConfig.groovy @@ -242,6 +242,12 @@ class K8sConfig implements ConfigScope { """) final String runtimeRecordPath + @ConfigOption + @Description(""" + Selects a scheduling strategy + """) + final String schedulingStrategy + /* required by extension point -- do not remove */ K8sConfig() { this(Collections.emptyMap()) @@ -280,6 +286,8 @@ class K8sConfig implements ConfigScope { workDir = opts.workDir ?: "${launchDir}/work" runtimeRecordPath = opts.runtimeRecordPath as String ?: "${workDir}/runtimes.csv" + schedulingStrategy = opts.schedulingStrategy as String ?: "Hash" + // -- shortcut to pod image pull-policy if( imagePullPolicy ) pod.imagePullPolicy = imagePullPolicy diff --git a/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sExecutor.groovy b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sExecutor.groovy index 5de3fe8..e2ad07f 100644 --- a/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sExecutor.groovy +++ b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/K8sExecutor.groovy @@ -17,6 +17,7 @@ package nextflow.k8s import groovy.transform.CompileDynamic +import nextflow.k8s.strategies.K8sDVFSSchedulingStrategy import nextflow.k8s.strategies.K8sHashSchedulingStrategy import java.util.concurrent.TimeUnit @@ -98,7 +99,17 @@ class K8sExecutor extends Executor implements ExtensionPoint { this.runtimeRecorder = new K8sRuntimeRecorder(k8sConfig.recordTaskRuntimes, k8sConfig.runtimeRecordPath) this.runtimeEstimator = new K8sRuntimeEstimator(k8sConfig.runtimeRecordPath) - this.taskScheduler = new K8sTaskScheduler(getNodeList(), new K8sHashSchedulingStrategy()) + K8sSchedulingStrategy strategy = null + if (k8sConfig.schedulingStrategy == "Hash") { + strategy = new K8sHashSchedulingStrategy() + } else if (k8sConfig.schedulingStrategy == "DVFS") { + strategy = new K8sDVFSSchedulingStrategy() + } else { + log.error "[K8s] invalid scheduling strategy $k8sConfig.schedulingStrategy, falling back on \"Hash\"" + strategy = new K8sHashSchedulingStrategy() + } + + this.taskScheduler = new K8sTaskScheduler(getNodeList(), strategy) this.schedulerThread = new Thread(this.taskScheduler) this.schedulerThread.start() } diff --git a/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/strategies/K8sDVFSSchedulingStrategy.groovy b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/strategies/K8sDVFSSchedulingStrategy.groovy new file mode 100644 index 0000000..f38079a --- /dev/null +++ b/nextflow/plugins/nf-k8s/src/main/nextflow/k8s/strategies/K8sDVFSSchedulingStrategy.groovy @@ -0,0 +1,22 @@ +package nextflow.k8s.strategies + +import nextflow.k8s.K8sSchedulingDecision +import nextflow.k8s.K8sSchedulingRequest +import nextflow.k8s.K8sSchedulingStrategy +import nextflow.k8s.K8sTaskScheduler + +/** + * Implements a scheduling strategy utilizing dvfs to reduce the energy consumption + * of workflow execution, while attempting to maintain the same makespan. + */ +class K8sDVFSSchedulingStrategy implements K8sSchedulingStrategy { + @Override + K8sSchedulingDecision schedule(K8sTaskScheduler scheduler, List queue) { + return null + } + + @Override + boolean scheduleImmediately(K8sTaskScheduler scheduler, List queue) { + return false + } +}