parasail-python icon indicating copy to clipboard operation
parasail-python copied to clipboard

Use of threads in library.

Open kako-f opened this issue 2 years ago • 3 comments

Hi! It's possible to specify the number of threads to use in the calculations? the original library allows to modify this value, I was wondering if the python binding is able to do this.

Thanks!

kako-f avatar Dec 30 '22 23:12 kako-f

The parasail_aligner application that comes with the C library does allow you to specify the number of threads to use. The Python bindings are only for the C APIs and not the full parasail_aligner application. The alignment functions were always single-threaded, for C or Python. If you want to align sequences in parallel using threads in python, you would need to use one of the Python built in threading modules in such a way that each thread does one or more pairwise alignments. I do not have any sample code for that, sorry.

jeffdaily avatar Jan 03 '23 16:01 jeffdaily

Hey! no worries, thanks for your insight. I can manage to create a snippet of code to utilize parasail with threads in python! 👍

Appreciated! 😄

kako-f avatar Jan 03 '23 18:01 kako-f

When trying to parallelize computations with python threads, be aware of the Global Interpreter Lock (GIL): The effect of this lock is that, at any time, only one python thread can actually make computations. This means, you do not gain any CPU performance by using python threads.

This does not make sense for applications that want to use multiple CPUs for CPU-bound applications. Still it was the right decision for python. You can learn more about this in this video: PyCon 2015-Pythons Infamous GIL by Larry Hastings.

Yaakov-Belch avatar Jun 13 '24 12:06 Yaakov-Belch