-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
slurm_utils.py submit_job function is very slow #79
Comments
Hi @atermanini ,
I am afraid yourr slurm system is a bit sluggish. |
Hi @maarten-k thanks very much for your help. The results are:
On our system the submission with sbatch is fast. I am experimenting this delay of near one second only with the cookiecutter template. For debugging, I got the jobscript from the temporary folder of snakemake (snakejob.align_seq.2.sh), and I also printed the "cmd" variable which is passed to the sp.check_output(cmd) inside the submit_job function:
Here is my testing pipeline code
The files are just empty files generated with: I hope you can help me finding why this is happening. Thanks again, |
Looks like slurm is not the culprit and to be honest I do not know for now
Did you profile the |
Hi @maarten-k , by profiling the submit_job function (just printing the difference between datetime.now() before and after each block of code), I saw that the command:
is taking the majority of the time: from 0.6 to 1 or seconds (see screenshot in attachment).
Usually, the first three-four jobs that are spawned has even higher times (2-3 seconds), then timing goes down and stay between 0.5 - 1 second. I don't know if this can be helpful: I am running snakemake inside a conda environment which is installed in my home folder. Please let me know if I can make some more tests. |
The slowness is because each submission starts a new Python interpreter to run slurm-submit.py. See #73 |
Hi @frankier, I am not sure that the problem is the opening of a new Python interpreter. For sure this takes time, however the slurm-submit.py takes around 0.7 second to be executed, and 0.6 seconds (90%) is taken by the "res = sp.check_output(cmd)" command, therefore I think that it is something more specific to this function call. What do you think? Best, |
Looks like I jumped the gun there since it seems like that's not where your slowness is. Did you try the alternative profile anyway? Whether it works faster or not might provide extra information. |
Hi @frankier , I will try the alternative profile suggested and let you know. Thanks again, |
HI @frankier , with the "Simple SLURM" and status-sacct.sh the submission of jobs was more fast, I was able to have a peak of around 470 running jobs. Each job executes a simple "sleep 30s" shell command. The jobs are 1000 in total. The execution seems to be stable. Thanks, |
Hi @atermanini , sorry for the delay. Thank you for your detailed report and the identification of the bottleneck you are experiencing when submitting your jobs. I will try to find some time to look into this. I personally haven't really had any problems with the submissions being a bit slow for the simple reason that I haven't dealt with the number of jobs that you are. Cheers, Per |
@atermanini This was the exact same problem I was having when I decided to create smk-simple-slurm. I knew from previous experience with Snakemake prior to the introduction of the
@frankier Thanks for sharing! My working assumption is still that all the extra Python invocations are causing the slow down, but I admit I didn't perform a detailed diagnosis of the exact bottlenecks. I just assumed that Snakemake (ie Python) shelling out to Bash just to re-invoke Python again over and over (for each job submission and each time each job status is checked) was contributing to the problem. In case it could be useful for comparing submission speeds, I created the benchmark below to convince myself that Snakemake could submit jobs faster (ie that Slurm itself wasn't the culprit). |
Just chiming in - I am new to this profile (I am the developer of the LSF profile but have just moved to an institute that uses slurm). If you have advanced argument conversion on I believe there is an additional call to slurm/{{cookiecutter.profile_name}}/slurm_utils.py Lines 324 to 329 in e725a99
I have no profiled with and without this advanced argument parsing, but it must surely add to overhead? I guess a first question would be: is this needed? I kind of feel that if a user is asking for time longer than the partition allows, that's their issue not this profile's? |
@mbhall88 yes the advanced argument hack with multiple calls to sinfo call is certainly not ideal. Storing the cluster configuration in a file and loading once would be one way to improve this step. Regarding whether it is needed or not, the initial motivation was to solve cases where time/memory was automatically increased (e.g. doubled in a lambda function) on failed jobs. Admittedly, this need has proven less evident with the new flags to set resources. I'll mark it for reworking/removal. Still, the issue with slow submission for many short jobs remains. |
Hello,
I am using this cookiecutter template with the last snakemake and SLURM.
For pipelines that spawn jobs that takes a small amount of time to be executed (eg 30 or less seconds), even spawning 1000 independents jobs I cannot reach more than 30-40 running jobs per time. Therefore, I am not able to use the full power of the HPC.
After many checks, I found that snakemake takes at least 1 seconds to spawn a new job.
The majority of this time is taken by the last code line in the slurm-submit.py script, which takes around 0.7 seconds.
print(slurm_utils.submit_job(jobscript, **sbatch_options))
Going to the slurm_utils.py, and inspecting the submit_job function with some timing checks, I can confirm that this is where the majority of the time is taken.
Is there any way to optimize this function?
Here we are using several pipelines that spawn thousand of independent jobs, and that takes no more than 30 seconds to be completed. If snakemake is spawning a jobs each second, it is difficult to take advantage of our cluster.
Please let me know if I can help with more details / code to replicate the problem.
Thanks very much,
Best,
Alberto
The text was updated successfully, but these errors were encountered: