9 ms·
Notes from the Meeting on Python GIL Removal Between Python Core and Sam Gross
- ctoth 5y agoI can't help but read all the interjections from the core developers as a strong indication of why all these sorts of things tend to fail on the vine. From Unladen Swallow onward there have been these groups off doing interesting and awesome experiments to try and make Python faster, and they never actually make it into something that Python end-users can use (yes, I know US had shortcomings). This is the work of one (admittedly super smart) guy over two years. Just like Nuitka, something else that was supposed to be impossible but just keeps making steady progress. Maybe I'm just seeing design by committee? The lone geniuses can only go so far. Maybe the problem is that Python can't quite decide what it wants to be because it's too many things for too many people already. Is the concept of Python the language, as opposed to Python the ecosystem, valuable enough so that a Python that broke backwards compatibility with all the C extensions would be useful as its own multicore-capable runtime? PyPy seemed to think so for a while and now has gone hard in the other direction, reimplementing (faking?) a bunch of the CPython extension API so maybe this approach would never work. I don't know, but seeing things like: > there is a large number of “dark matter” Python (and C extension) code out there that isn’t open-source. We need to be careful not to break it since it might not be feasible for its users to make required changes, or to report problems back upstream to us. In particular, some C extensions protect their own internal state with the GIL. This is a big worry, and might be a big hindrance to adoption of a GIL-free Python. really make me wonder if the community as a whole would conclude the same on these critical sorts of decisions which shape the future of the language if they were put forward and not just made by a couple people in a closed meeting. Would you prefer to support some weird arbitrary nameless closed source extensions, or have a multicore Python? This obviously depends on who you are and what you're doing, which leads us back to Python being too much for too many, but even here we can get a feeling for how many people do what with the language.
- shepardrtc 5y ago> Would you prefer to support some weird arbitrary nameless closed source extensions, or have a multicore Python? There's nothing wrong with staying on an older LTS version of Python. Let the people with the nameless closed-source stuff stick with that. The beauty of open source is that they can fork the older, GIL-ful version of Python and maintain it, if they like. Multicore would be a tremendous boon to the language.
- ldng 5y agoThe problem is those nameless usually want the cake and eat it too but will complain rudely when their toys breaks.
- rbanffy 5y ago> Let the people with the nameless closed-source stuff stick with that. Let's hope it becomes a teachable moment.
- vlovich123 5y agoIs there some particular reason to believe the Python team is even able to get good insight into regressions in the long tail of python packages? Also it's important to remember that a lot of of material contributions to the community (either to the foundation, via jobs, or even open-sourcing part of their internal stack) might be coming from closed source in some way. It's not wise to ignore that & I think the core team is rightfully cognizant of needing to balance that (balance - not tip to one extreme or the other).
- rectang 5y agoConcurrency is impossible to prove sound without language-level guarantees. https://www2.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-1.pdf https://www2.eecs.berkeley.edu/Pubs/TechRpts/2006/EECS-2006-... I'm astounded that a change which will release untold heisenbugs into the wild is being considered. It changes my view of Python. In terms of inducing subtle, silent breakage in existing code, it reminds me of this horrifying change from PHP 8: https://www.php.net/manual/en/migration80.incompatible.php#migration80.incompatible.core.string-number-comparision https://www.php.net/manual/en/migration80.incompatible.php#m...
- rbanffy 5y ago> really make me wonder if the community as a whole would conclude the same on these critical sorts of decisions which shape the future of the language if they were put forward and not just made by a couple people in a closed meeting. I for one couldn't care less if some proprietary binaries fail on Python 3.11 or so. That's why we keep multiple versions around (at last company, I could only use up to 3.6 because that was the version in the Sacred CentOS AMI) And, of course, a very critical piece of code was depending on a bug in regex that was fixed in 3.8 or so, and decided to break during a demo (where I was using 3.9 instead of 3.6).
- unityByFreedom 5y agoI agree. If you're doing something so special in your code that nobody is publicly doing it and you're unable to update the code to make it compatible, then don't upgrade. That's the risk you took when coding it. We shouldn't go out on a limb for hypotheticals that cannot be confirmed. Force them to demonstrate an example publicly so all the cards are on the table. Proprietary code is fine and you can still share concepts by extracting out the issues. Sorry to hear about your demo. Sounds not fun! At least that's in the past :)
- formerly_proven 5y ago> there is a large number of “dark matter” Python (and C extension) code out there that isn’t open-source. We need to be careful not to break it since it might not be feasible for its users to make required changes, or to report problems back upstream to us. In particular, some C extensions protect their own internal state with the GIL. This is a big worry, and might be a big hindrance to adoption of a GIL-free Python. Probably doesn't work across minor versions anyway, most stuff isn't built against the limited API.
- bigdict 5y agoIf this proof of concept is accepted, Facebook will put more resources to move the project forward.
- simonh 5y agoI don't think it's very coherent to criticise the team because "Python can't quite decide what it wants to be", but also criticise them for not adopting all these crazy cool changes that would fundamentally change Python. Taking a highly conservative approach to breaking changes is absolutely not the same thing as being indecisive. The Python team has learned from experience how disruptive breaking changes can be.
- pganssle 5y ago> I can't help but read all the interjections from the core developers as a strong indication of why all these sorts of things tend to fail on the vine. I think this might be a misunderstanding of the nature of the event that these notes are generated from, unless I'm misunderstanding your objection. The point of this Q&A as I saw it was to explore the feasibility of the idea and fully flesh out the costs and benefits so that we can make informed decisions about how to proceed. The "random interjections" are notes of caution about what trade-offs need to be made. For example, it is very easy to overlook "dark matter" code because we don't have access to it, but it's almost certainly the majority of Python code out there. It is also not a complete deal-breaker to say that some change could break unknown proprietary extensions — otherwise we'd never be able to change anything; the key is that the changes have to be worth it. A lot of that depends on details — if it's easy to update C extensions for nogil mode (even if they were designed without parallelism in mind), then making breaking changes to remove the GIL might not be so bad. If nogil mode requires that most C extensions totally overhaul their reference counting and C API usage and the changes require restructuring code rather than something that can be done with automated search and replace, that's a much bigger cost and will probably come with a long term fork of the ecosystem (which is a huge pain to deal with) and it might not be worth it. Avoiding this sort of criticism will not make the underlying problems go away, and I think everyone involved understood that this meeting was intended to bring to light any objections that might guide the work towards ultimate resolution.
- mvanveen 5y agoJust came in here briefly to opine that there is a very real risk of fork if the Python core community does not at least offer a viable alternative expediently. The economic pressures surrounding the benefits of gross’s changes will likely influence this more than any tears shed over subtle backwards incompatibility. I believe it was Dropbox that famously released their own private internal Python build a while back and included some concurrency patches. Many teams might go the route of working from Sam Gross’ work and if we see subtle changes in underlying runtime concurrency semantics or something else backwards incompatible that’s it- either that adoption will roll downhill to a new standard or Python core will have to answer with a suitable GIL-less alternative. I for one do not want to think about “ANSI Python” runtimes or give the MSFTs etc of the world an opening to divide the user base.
- rbanffy 5y ago> I believe it was Dropbox that famously released their own private internal Python build a while back and included some concurrency patches. Google also had their Unladen Swallow version, but it seems they lost interest at some point.
- liuliu 5y agoUnladen Swallow is a 20% project. Besides, LLVM's JIT turns out to be an disappointment and I believe that no modern interpreted language uses LLVM's JIT at this moment.
- williamstein 5y agoDoesn’t Julia?
- kristofferc 5y agoJulia is not interpreted.
- 5y ago
- deleted 5y ago[deleted]
- mixedmath 5y agoThese are exceptionally clear notes. They're easy to read and feel comprehensive. I also note that the author is the current CPython developer in residence (a recently created position).
- bigdict 5y agoWhy is it never mentioned that Sam the lone genius Gross who is "interested in PyTorch training workflows" is a fulltime Facebook employee? Not that it's bad but it should be mentioned that it's a corporate initiative.
- deleted 5y ago[deleted]
- fulafel 5y agoThere's funding and then there's research. I'd share headline credit about initiative to the person as well.
- jamesmishra 5y agoIs it actually a corporate initiative? The project is hosted on Sam's personal GitHub[1]. [1]: https://github.com/colesbury/nogil https://github.com/colesbury/nogil
- oefrha 5y agoIt may not be a Facebook initiative in the corporate strategy sense, but it's definitely a Facebook project, done on Facebook's dime. From the horse's mouth: https://lwn.net/ml/python-dev/CAGr09bRSwfinXNe4acTrpR8bM7nYhEJqeTT5sg96eDhn91RMWg@mail.gmail.com/ https://lwn.net/ml/python-dev/CAGr09bRSwfinXNe4acTrpR8bM7nYh...
- maccard 5y agoWould you consider python a Dropbox or google product given that Guido worked for both of those companies on python for close to 15 years?
- oefrha 5y agoAny component he soloed while on company time, yes, I would consider that an $employer project (not product, the work is donated under the PSF license and a CLA). We’re talking about ~2 years of paid full time work here.
- XorNot 5y agoI wonder if a midpoint for this sort of work would be if a major distro or several declared they would move to GIL-free Python? System python at least is generally only recommended to be used for system libs, and that's a relatively supportable set. Developers use virtualenv's and their own specific interpreter, but it would certainly move the needle on what language people were by default scripting and thinking in.
- kzrdude 5y agoThis here: "The GIL will still be optionally available as an interpreter startup-time option" seems like a midpoint. Maybe it will even be GIL-by-default for some versions.
- didip 5y agoI think Python core developers should not worry about closed-source enterprise Python code. If users are gaining performance, they will bend over backward porting their code to this new version. At minimum, I predict, all FAANGMULA would jumped in the bandwagon and create a pretty big ripple effect.
- rolisz 5y agoI have heard of FAANG. I guess M stands for Microsoft. Who's ULA?
- joshuamorton 5y agoUber Lyft Airbnb most likely (this generally is shorthand for public unicorns and similar well respected major companies that contribute to open source).
- aserafini 5y ago100% agree, it is also impossible to quantify so can never really be a useful factor in decision making. And Python is not a business with customers. It’s an open source volunteer project.
- josefx 5y agoI am surprised that closed source is suddenly an issue when it comes to the GIL, but half the world breaking on the python 3 transition was not only intended but actively pushed by various members of the community. Since Linux managed to get rid of the BLK then python should be able to get rid of the GIL.
- stjohnswarts 5y agoThey said they would make the non-GIL version opt in (command line flag?) so they wouldn't be breaking the old stuff anyway. It's a solved problem. If anyone moving to a new version of python can't take the time to understand such a small change, then that's on them.
- frazbin 5y agoI think there's a pretty good chance this stuff gets incorporated: "On a personal level, we are impressed by Sam’s work so far and invited him to join the CPython project. I’m happy to report he is interested, and to help him ramp up to become a core developer, I will be mentoring him. Guido and Neil Schemenauer will help me review code for the interpreter bits I’m unfamiliar with."
- caffzz 5y agoEmbrace, extend, extinguish. Sam will be in for a rude awakening with these people.
- WayToDoor 5y agoThis is python, not Microsoft we are talking about
- clxzzz 5y agoContributors can be extinguished after they have done their duty. One of the most famous contributors ever spoke about "minibosses" the last time he was seen dealing with the Python core bureaucrats. The situation is even worse now.
- BiteCode_dev 5y agoCan you give us more details about this ? Do you have a particular story in mind ? It seems a lot of fresh blood is comming to the python project recently, so I'm interested in what you have to say. But why are you using a throwaway account ? And that you that have been answering the other comments with also newly created accounts ?
- WesolyKubeczek 5y agoI can share the sentiment that PSF and the core team has become something like “old boys club”, and no, new core developers didn’t change this ambience you get when you read their forums/mailing lists and twitters (better avoid twitters though). I don’t have anything about a community being an old boys’ club (would be nice to be in one some day, I reckon it’s what older people’s equivalent of a “safe space” is), it’s that they try hard to pretend they are something else that irks me. But for the life of me I couldn’t find “python” and “minibosses” mentioned in the same document on the internet, except for an integration testing package and a computer game. So I think the story alluded to is bogus. There’s a minuscule likelihood of it all being a twitter drama with key characters then nuking their tweets or deleting their accounts, but if it was of any significance some blog would have echoed it.
- jancsika 5y agoSuppose a Python module written in C registers a method that ends up making a call to C functions larry(), moe(), and then curly() to mutate a global variable "global_mutable_temp" before finally returning a value generated from global_mutable_temp. 1. Supposing this method doesn't currently crash under GIL python, would it be true that this method will also run without crashing on the non-GIL python interpreter? 2. Would it be true that the non-GIL python interpreter will introduce a race to this method (resulting in a runtime error) that didn't exist under the GIL interpreter?
- bionhoward 5y agoNo, yes, and that code should be rewritten, GIL or not
- kombine 5y agoI think switching the version to 4 is the most viable path. Make the last GILed python 3 an LTS release that interested parties can hold on to, eg. Ubuntu can keep python 3 as a default for a long time. One can always use conda to run multiple versions simultaneously.
- IshKebab 5y agoYou mean Python 4? That would be absolutely insane. Have you already forgotten the 2/3 transition? They aren't making that mistake again.
- berkut 5y agoMaybe not, but as someone in the VFX/CG industry where Python 3 is only just being moved to this year (still on 2.7 mostly) because we didn't really need unicode, getting rid of the GIL in 3.0 would have very likely made us jump to Python 3 almost instantly years ago. Different people want different things I guess...
- jas0so 5y agoJust because the version increments doesnt mean it'll be as painful a transition.
- nicolaslem 5y agoAnd yet the popularity of Python exploded during the 2 to 3 transition. As someone who has migrated a few codebases from 2 to 3, I will gladly do it again to 4 if that brings a GILless Python.
- boublepop 5y agoExactly. The 10% of python programmers who used and loved python 2, keep talking about the community “almost dying” at a time when 90% of it joined with a clear preference for python 3. It’s ridicules.
- kzrdude 5y agoThe site is currently past its hosting limit for the day. https://archive.md/Zb8p2 https://archive.md/Zb8p2 (Archived through google cache, so two layers of cache.)
- ambivalence 5y agoThanks for the link. I just moved the website to Netlify from Fastmail. Hopefully the DNS on your side will update soon.
- kzrdude 5y agoIt's working with the new host from here now. :)
- antman 5y agoTLDR of my understanding: What python commitee considered as infeasible was almost done by a lone hero. Since the previous decision to change the format of the print function (that no one asked for) broke everybody's code for no reason and took ten years to be adopted, they will not push (for the one change everyone wants) for the foreseable future. Although it does not seem to be that impossible after all. I am glad they will invite Sam, the lone gero we needed and hope he will be given some ownership of the task and not get him swamped with commiteeisms through a embrace, not extend and extinguish. He is on a success path, the commitee is in no path at all. Just put a timeline and call it a fail if don't succeed and quit avoiding it through "discussions". We got it, it's not planned for the X.XX+1 version, each version.
- landmark3 5y agoand here I am writing a CRUD app with flask :( Impressive work (2 years working full time knowing that it might never be merged is incredible)
- orf 5y agoIt’s down, archive link: https://archive.md/Zb8p2 https://archive.md/Zb8p2
- gadrev 5y ago> What’s the level of perceived risk that the nogil project will end up not being viable for inclusion in CPython? (...) > It all depends on how well the community adapts C extensions so they don’t cause downright crashes of the interpreter. Then, the remaining long tail is community adopting free threads in their applications in a way that is both correct and scales well. Those two are the biggest challenges but we have to be optimistic. Even if it's 10% of the mess the path py2->py3 was, it still worries me. I hope I'm wrong and it's much less than that (for the fatal cases ATL, and similar/non improved perf for the rest)
- mihaic 5y agoBesides the internal politics, I think the greatest blocker with improving python performance is not giving whomever is running the code any control. If I don't use any naughty C plugins, or if I can assure you that I've annotated all my types and can allow a large class of optimizations, why can't I run my code with some VM flags? It's one language, but why can't I tune my VM to my needs? I can't imagine Java not letting users tune their GC.
- csmpltn 5y agoPython is used by a lot of "semi-technical" people (data scientists, researchers, hobbyists, etc). Removing the GIL isn't going to make their life any easier.
- chrisseaton 5y agoAre these people writing a lot of low-level multi-threaded code?
- WesolyKubeczek 5y agoNor won’t it make their lives any harder.
- jokoon 5y agoI remember that the python SQLite module is problematic because of the GIL. Would that solve that problem? What other sort of problem does it solve? But on the other hand, isn't simple to just dedicate a script per core?