Skip to content
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

Release the GIL whenever possible #1512

Closed
JDWarner opened this issue May 14, 2015 · 13 comments
Closed

Release the GIL whenever possible #1512

JDWarner opened this issue May 14, 2015 · 13 comments

Comments

@JDWarner
Copy link
Contributor

From discussion in #1493, @mrocklin pointed out the many benefits of releasing the GIL for parallelization/serialization.

For many of our Cython files and functions this would be as simple as wrapping contents in a with nogil: block

with nogil:
    # function contents here

Opening as a separate issue to facilitate discussion.

@mrocklin
Copy link

In original experiments by @cowlicks we were only able to get a 30% increase when using canny edge detection in multiple threads. I/O wasn't an issue so we assumed that the GIL was to blame.

A case study of removing the GIL and using apply_chunks from #1493 on a single algorithm might teach us something. We're happy to support from the dask side.

@stefanv
Copy link
Member

stefanv commented May 15, 2015

Yes, please--any energy going to this is good, because we have been very bad on this front.

@tacaswell
Copy link
Contributor

Commenting so I get emails from this thread, sorry for the noise.

@stefanv
Copy link
Member

stefanv commented May 20, 2015

Is there anyone who has Airspeed Velocity set up? It would be quite useful at this point.

https://github.com/spacetelescope/asv/

@yarikoptic, any advice?

@jni
Copy link
Member

jni commented May 20, 2015

@stefanv using asv reliably needs a dedicated server, in my understanding, so that the benchmarks are comparable across timepoints. (I have not yet tried this myself.)

I met someone at MPUG (Melbourne Python Users Group) who has been playing around with asv. I've pinged him over email because I don't know his Github handle. He might be able to contribute here!

@stefanv
Copy link
Member

stefanv commented May 20, 2015

Perhaps the astropy team would be willing to help, @cdeil?

@koenvb
Copy link

koenvb commented May 20, 2015

Happy to contribute here. I played around a bit with asv but as noted in the talk from scipy 2014 the benchmarks are tied to the particular machine and software. Next is the benchmarks you want to run. This is the repo with benchmarks from astropy using asv. The setup is straightforward and it just comes down to defining which benchmarks and which test matrix you want.

Seems scikit-bio wants to start using asv as well.
Maybe @anderspitman can shed some light on this.

@jni
Copy link
Member

jni commented May 20, 2015

@koenvb how about you fork scikit-image and define a couple of benchmarks? The gallery is a good place to start.

@anderspitman
Copy link

@koenvb happy to share our experience setting up asv if you have any questions. It's a great project and pretty straight forward to set up, but there are definitely some subtleties, and the operation can be a bit opaque and difficult to debug when something goes wrong.

@cdeil
Copy link
Contributor

cdeil commented May 20, 2015

I've only played around with asv. For Astropy it's @mdboom and @astrofrog that have the most experience with asv and I think are running cron jobs to continuously run asv.

Yes, you need to find a dedicated machine to run the benchmarks. But that can come later, getting familiar with asv and implementing a useful set of benchmarks can come first.

You also need to discuss a bit about what kind of benchmarks you want and how they can be helpful to you without taking too much time to implement and run and then review and discuss the results. The main aspect of asv is that it runs the same benchmark for many commits in your repo, so you'll mainly learn something useful if there's a change in performance, i.e. a regression or improvement.

@sciunto
Copy link
Member

sciunto commented May 20, 2015

Probably most of you are familiar with the GIL, but I felt the need to learn more about it. I found this article well done, with an enlightening video. http://lbolla.info/blog/2013/12/23/python-threads-cython-gil

@JDWarner
Copy link
Contributor Author

Closed by #1519

@mrocklin
Copy link

Well that was fast!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants