|
|
Subscribe / Log in / New account

Grok the GIL (opensource.com)

Grok the GIL (opensource.com)

Posted Apr 21, 2017 11:20 UTC (Fri) by kigurai (guest, #85475)
In reply to: Grok the GIL (opensource.com) by quietbritishjim
Parent article: Grok the GIL (opensource.com)

I agree that most CPU intensive stuff is already done in C-libraries, but I am not so sure this makes the point of removing the GIL moot.
Sometimes you have a library function that does the computations in C (fast) but you need to run it on a shitload of data, and the library itself is not built for that.
Today you solve that by e.g. multiprocessing.Pool() but if the data you are operating on is large, or not picklable, then you either can't, or at least have to write quite complicated boilerplate code to share the data somehow.
Thus I would really love to instead be able to use a pool of threads that can all freely share the data I have already loaded, which is of course impossible as long as the GIL remains.


to post comments

Grok the GIL (opensource.com)

Posted Apr 21, 2017 15:46 UTC (Fri) by khim (subscriber, #9252) [Link] (2 responses)

Yup. Think TensorFlow. Highly-optimized C++ code with threading pools and everything, 99% of CPU time is spent there. 1% is spent in linear (because if GIL) python “driver”. Now think about “monster desktop” with two Monster Xeons. 96 threads, add Amdahl's law and... vila: almost half of wall-clock time is spent in python! Still think GIL is “not a big deal if core of your toolboox is in C++”?

Grok the GIL (opensource.com)

Posted Apr 21, 2017 15:51 UTC (Fri) by Sesse (subscriber, #53779) [Link] (1 responses)

As someone who has had TensorFlow optimization as a day job (in the Google Brain team)… sorry, it's a bad example. :-) But it doesn't really use Python for much except just setting up the graph and then pressing play.

Grok the GIL (opensource.com)

Posted Apr 22, 2017 18:45 UTC (Sat) by khim (subscriber, #9252) [Link]

Yes, TensorFlow does not use Python for much... and usually GIL is not a problem... yet in certain use cases almost half of wall-clock time in spent in Python. I believe dvyukov have some numbers.


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds