News for hackers. Stuff that matters.
Re:Free-threaded CPython is ready to experiment with by mihaic on Friday July 12, 2024 @05:21PM (#40949564)
Does anyone know if there is more serious single threaded performance degradation (more than a few percent for instance)? I couldn't find any benchmarks, just some generic reassurance that everything is fine.
Re:Free-threaded CPython is ready to experiment with by ngoldbaum on Friday July 12, 2024 @05:30PM (#40949628)
Right now there is a significant single-threaded performance cost. Somewhere from 30-50%. Part of what my colleague Ken Jin and others are working on is getting back some of that lost performance by applying some optimizations. Expect single-threaded performance to improve for Python 3.14 next year.
Re:Free-threaded CPython is ready to experiment with by arp242 on Friday July 12, 2024 @06:25PM (#40950025)
To be honest, that seems a lot. Even today a lot of code is single-threaded, and this performance hit will also affect a lot of code running in parallel today.

There have been patches to remove the GIL going back to the 90s and Python 1.5 or thereabouts. But the performance impact has always been the show-stopper.

Re:Free-threaded CPython is ready to experiment with by ngoldbaum on Friday July 12, 2024 @06:46PM (#40950144)
It’s an experimental release in 3.13. Another example: objects that will have deffered reference counts in 3.14 are made immortal in 3.13 to avoid scaling issues from reference count thrashing. This wasn’t originally the plan but deferred reference counting didn’t land in time for 3.13. It will be several years before free-threading becomes the default, at that point there will no longer be any single-threaded performance drop. Of course that assumes everything shakes out as planned, we’ll see.

This post is a call to ask people to “kick the tires”, experiment, and report issues they run into, not announcing that all work is done.

Re:Free-threaded CPython is ready to experiment with by andmkl on Friday July 12, 2024 @08:27PM (#40950708)
That would be in the order of previous GIL-removal projects, which were abandoned for that reason.
Re:Free-threaded CPython is ready to experiment with by imtringued on Saturday July 13, 2024 @02:13PM (#40955752)
That kind of negates the whole purpose of multi threading. An application running on two cores might end up slower, not faster. We know that the python developers are kind of incompetent when it comes to performance, but the numbers you are quoting are so bad they probably aren't correct in the first place.
Re:Free-threaded CPython is ready to experiment with by ngoldbaum on Monday July 15, 2024 @09:33AM (#40967761)
Clarifying a few days later: single-threaded performance in the normal ABI with the GIL does not have the same performance degradation. You only see the performance hit if you’re testing the experimental 3.13 free-threaded release.
Re:Free-threaded CPython is ready to experiment with by deschutes on Friday July 12, 2024 @05:32PM (#40949644)
To my understanding there is and there isn't. The driving force behind this demonstrated that it was possible to speed up the existing CPython interpreter by more than the performance cost of free threading with changes to the allocator and various other things.

So the net is actually a small performance win but lesser than if there was no free threading. That said, many of the techniques he identified were immediately incorporated into CPython and so I would expect benchmarks to show some regression as compared with the single threaded interpreter of the previous revision.

Re:Free-threaded CPython is ready to experiment with by nhumrich on Saturday July 13, 2024 @12:20AM (#40951740)
Irrelevant, because even if there was, you would use the normal GIL python for it.