Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Posted Apr 21, 2017 6:10 UTC (Fri) by quietbritishjim (subscriber, #114117)Parent article: Grok the GIL (opensource.com)
Posted Apr 21, 2017 8:34 UTC (Fri)
by Sesse (subscriber, #53779)
[Link] (23 responses)
Not necessarily. There are tons of cases (basically anything related to web) where you spend your time in the Python interpreter, not in C extensions.
Posted Apr 21, 2017 9:01 UTC (Fri)
by quietbritishjim (subscriber, #114117)
[Link] (22 responses)
More broadly, if you have a Python application in any domain that's using loads of CPU in the interpreter then I think you've used the wrong language, because native code will be orders of magnitude faster. Removing the GIL is not going to change that. An obvious counter argument is that CPUs are cheap. Yes, but are they so cheap that you can afford to buy 100 times as many web servers?
It's OK that Python is hopelessly slow because it's intended as a glue language that just coordinates fast code (in-process C extensions or out-of-process via I/O). This works really well because most code is actually the same in different applications, so with this strategy the shared code gets written once in a native language (in numpy or Postgres or whatever) and the tiny amount of application-specific code gets written in Python. As I see it, the GIL doesn't have much effect on this.
Posted Apr 21, 2017 9:58 UTC (Fri)
by Sesse (subscriber, #53779)
[Link] (10 responses)
This isn't unique to Python, by the way. Perl, Python, Ruby, Lua… most applications I've seen _don't_ have this “90% of time is spend in doing XYZ, so just use libXYZ from C” pattern.
Posted Apr 21, 2017 11:04 UTC (Fri)
by excors (subscriber, #95769)
[Link] (9 responses)
That process will repeat until there are no identifiable bottlenecks, they've just got hundreds of thousands of lines of Python code that are uniformly slow, and then they'll want to make Python faster. (It's basically Amdahl's law - once you speed up everything you can, performance is likely dominated by the parts you couldn't speed up.)
Posted Apr 23, 2017 10:39 UTC (Sun)
by joib (subscriber, #8541)
[Link] (8 responses)
Meanwhile, say, Lisp, a similarly dynamic language, has had sophisticated native code compilers and generational GC for decades. Whereas in the python world efforts like unladen swallow (sp?) fail or are not widely used (pypy). What gives?
Not to pick on python specifically, ruby, perl, R, octave etc. are all equally bad. LuaJIT and modern JavaScript runtimes are the happy exceptions, though. Perhaps one shouldn't draw too much conclusions from javascript, considering the $$$ spent there, but then again, LuaJIT is basically a one-man show.
Posted Apr 23, 2017 11:00 UTC (Sun)
by Sesse (subscriber, #53779)
[Link]
Posted Apr 23, 2017 12:26 UTC (Sun)
by njs (subscriber, #40338)
[Link]
It doesn't help that Python's semantics are much richer than other dynamic languages like JS and Lua (and I suspect lisp too) in a way that makes effective JITting much harder – e.g. a basic operation like attribute lookup involves like 10 different special cases you have to check. This is what motivates PyPy's weird architecture – they need a JIT engine that can introspect "basic operations" like this and automatically generate context specific optimized variants, so they implement these operations in a high-level language ("RPython") that their JIT engine can see through.
The good news is that the PyPy devs have been doing a truly heroic job over the last ~year on polishing up their fake CPython C API layer to the point where it's starting to be able to handle gnarly old libraries like numpy, lxml, etc. So hopefully this last major roadblock will be removed soon.
Posted Apr 25, 2017 5:43 UTC (Tue)
by Cyberax (✭ supporter ✭, #52523)
[Link] (5 responses)
So far I don't know _any_ mainstream scripting languages that have proper multithreading.
Posted Apr 25, 2017 7:06 UTC (Tue)
by Sesse (subscriber, #53779)
[Link] (1 responses)
Posted Apr 25, 2017 11:50 UTC (Tue)
by niner (subscriber, #26151)
[Link]
Posted Apr 25, 2017 11:48 UTC (Tue)
by niner (subscriber, #26151)
[Link] (2 responses)
Posted Apr 25, 2017 11:49 UTC (Tue)
by rahulsundaram (subscriber, #21946)
[Link] (1 responses)
Posted Apr 29, 2017 19:08 UTC (Sat)
by flussence (guest, #85566)
[Link]
But to play the numbers game a bit, I'd like to point out that PHP provides a genuine shoe-facing hand cannon: http://php.net/pthreads
Posted Apr 21, 2017 11:20 UTC (Fri)
by kigurai (guest, #85475)
[Link] (3 responses)
Posted Apr 21, 2017 15:46 UTC (Fri)
by khim (subscriber, #9252)
[Link] (2 responses)
Posted Apr 21, 2017 15:51 UTC (Fri)
by Sesse (subscriber, #53779)
[Link] (1 responses)
Posted Apr 22, 2017 18:45 UTC (Sat)
by khim (subscriber, #9252)
[Link]
Posted Apr 21, 2017 16:40 UTC (Fri)
by niner (subscriber, #26151)
[Link] (6 responses)
Posted Apr 25, 2017 1:33 UTC (Tue)
by sciurus (guest, #58832)
[Link] (5 responses)
Posted Apr 25, 2017 3:55 UTC (Tue)
by pabs (subscriber, #43278)
[Link] (4 responses)
Posted Apr 25, 2017 10:47 UTC (Tue)
by jond (subscriber, #37669)
[Link] (3 responses)
Posted Apr 25, 2017 11:41 UTC (Tue)
by karkhaz (subscriber, #99844)
[Link]
Posted Apr 25, 2017 17:24 UTC (Tue)
by pboddie (guest, #50784)
[Link] (1 responses)
Also, while I'm impressed with things like PDF.js, I find myself using a native viewer like Okular for documents of any size, purely because the performance difference is significant. So, JavaScript-based equivalent solutions certainly have their limitations.
Posted Apr 28, 2017 15:30 UTC (Fri)
by mstone_ (subscriber, #66309)
[Link]
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
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.
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)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)
Grok the GIL (opensource.com)