Dear Nextflow swarm intelligence, I was profiling ...
# nostupidquestions
t
Dear Nextflow swarm intelligence, I was profiling the computational performance of a Nextflow pipeline and observed something I don't understand yet. My wf runs the
SAMTOOLS_FLAGSTAT
nf-core module using one thread (see commandSh.png). Now, I checked the "Raw usage" and "% Allocated" tabs in the report.html (see cpuAllocated.png) and their stats tell me that some of the instances of
SAMTOOLS_FLAGSTAT
used up to 142% of the allocated CPUs (red circle highlighting in cpuAllocated.png). Besides the fact that imho you can never use more CPUs than allocated, this should also just not be possible according to Nextflow's CPU-usage formula. The formula should never result in something higher than 100%. Any ideas what's going on here?
a
You are actually telling Samtools to use 2 threads, since
--threads
is the additional threads to use apart from the main thread. And a tool can absolutely use more CPUs than allocated by Nextflow. This depends a lot on your executor. With local, nothing enforces the Nextflow allocation, with SLURM it's up to your settings how strict your scheduler enforces that jobs don't exceed their allocation.
m
It's also possible your executor can update the resources requested. This happens with one of our clusters as we have a certain memory per cpu, and if we request a certain amount of memory, the cpus requested also gets bumped. This tends to make our jobs appear very resource inefficient.
t
Thanks a lot for your feedback. That fact samtools specifies additional threads and not threads as given blew my mind. I learned something today (very late).
Also, maybe a bit philosophical: (1) Why is nothing constraining the resources locally? ...and: (2) Is there a flag / config setting to regulate this in SLURM execution?
It seems crazy for me to think that using
label 'process_single'
is actually doing very little. Why are we even specifying this if it is virtually never enforced (it seems)?
a
If you use the local executor, the
cpus
directive is still important for Nextflow to know how many tasks it can run at the same time given the total amount of CPUs available to the executor. But Nextflow needs to rely on the tool/user to actually stick to the requested amount.
t
(1) Why is nothing constraining the resources locally?
The only thing to constrain it would be the kernel, and implementing mechanisms to make the kernel do that is well beyond Nextflow's scope -- that is something a scheduler does (like SLURM; sorry, I don't how to configure it, though, but there should be plenty of docs), and Nextflow uses schedulers, but does not implement them. (In practice, if you run Nextflow with the
local
scheduler, you are either testing informally, or you have a server that you control, and you can implement guard rails in the Nextflow config with things like
maxForks
, or you could install SLURM.)
✅ 1
p
I also think recent nextflow versions will pass some of the relevant limits to docker if that is used as container engine (which is in contrast to e.g. singularity, which makes sense since that typically is used in environments where there is a scheduler that manages these limits).