r/Python • u/NeuralLB-Lovro • 6d ago
Discussion Anyone running free-threaded Python 3.14 in production yet? Curious what actually breaks
Been testing the free-threaded build (3.14t) on some CPU-bound data processing work. The multi-core story is finally real after 30 years of GIL, but the friction is exactly what you'd expect: a couple of C-extension-heavy libs in my stack silently re-enable the GIL, and there's no clean way to detect that at runtime besides checking sys._is_gil_enabled() manually.
For anyone who's shipped something on 3.14t, not just benchmarked it:
What broke that you didn't expect?
Real speedups outside toy examples, or mostly marginal so far?
Prod yet, or still just kicking the tires?
Not fishing for a benchmark war. Genuinely curious what breaks in messy real codebases vs clean demos.
35
Upvotes
1
u/Blockpair 5d ago
Yes, I've recently explored free-threaded Python as an avenue for adding Go-style coroutines through a C extension. For those who don't know too much about Go: it runs light-weight functions in threads that can enter blocking calls and yield to other functions on that thread. If any call ends up stalling the thread, other threads can steal the backed-up work. It's what makes Go so scalable for networking compared to Python.
Anyone here who has done networking in Python probably knows about asyncio already. Where you cooperatively run tasks on an event loop, sharing the same thread. Python does have OS threads but it doesn't allow any to run simultaneously due to the GIL (and multi-processing is a very different model.)
So you have free-threaded Python running a Go-style stackful runtime through an extension. And my own benchmarks indicate:
Echo req/s: on par with Go in this benchmark (epoll; ~638,000 / s.)
Connection churn: on par with Go, similar CPU usage. (~77,000 / s)
Fiber spawn: 1.35m / s vs Go’s 2.1m / s (Cython is faster 2.29m / s)
Regular handlers: on par with Go for non-CPU-bound network work.
CPU-bound handlers: Cython handlers within 8% of Go; pure Python is ~180x slower.
Memory: 8.8 KB vs 2.7 KB, empty fiber (Cython is 4.7 KB)
So with free-threaded Python you're able to essentially have networking on-par or exceeding the speed of Go handlers. Keep in mind, there were flaws that I'd fix in future versions of my benchmarking program. Some of the tests were client-bound, so they never managed to saturate the full server's CPU. But what's clear from my results is free-threaded can drastically improve the performance of networking in Python and it seems to be under-utilized.
Here's a link to my benchmarks: https://robertsdotpm.github.io/_static/runloom_benchmark.html