facebookincubator / cinder

Cinder is Meta's internal performance-oriented production version of CPython.
https://trycinder.com
Other
3.49k stars 121 forks source link

Cinder vs. Python 3.11 #76

Closed belm0 closed 2 years ago

belm0 commented 2 years ago

I haven't tried it on my application yet, but Python 3.11 is said to give about a 25% speedup on benchmarks.

With Cinder, maybe we can expect 2x on static modules with full typing, and 5x with cinder-specific typing. But that only applies to the portion of the application that we convert to static.

The apparent quandary: go to Python 3.11 and take the free 25% across the board, or stay on 3.8 (or 3.10) and work hard migrating to Cinder (includes learning, tooling), which offers a higher upper-bound on performance?

I see that a 3.10 port is active, but is there any guidance on when Cinder might support 3.11 so that this isn't an either-or decision?

itamaro commented 2 years ago

Thanks for the question @belm0 !

I'm not familiar with your application. If it's a real-world production application, I would recommend sticking with CPython (3.10 now, 3.11 when it is released), since Cinder isn't officially supported for use-cases outside Meta.

Currently there are no plans to porting Cinder to 3.11. Once the 3.10 port is done, the next version we plan to port to is 3.12. Ideally by 3.12 you would get a good amount of Cinder's optimizations "for free", as we are working to contribute as much as we can upstream (see https://discuss.python.org/t/making-cinder-more-broadly-available/14062), and even take advantage of Cinder JIT and Static Python via an extension module on stock CPython 3.12 (if we are able to merge the C APIs we need to support this functionality from an extension).

In the meantime, I agree it can take a lot of effort to adopt something like Static Python in an existing application, but it may be reasonably realistic to try running your unmodified application using Cinder (potentially with the JIT and Lazy Imports enabled) and benchmark it. If you benchmark your application with stock 3.8 as a baseline, and with stock 3.11 and Cinder 3.8 as two comparisons, we would be interested in your results! (and I believe the Faster CPython project would also be interested in any real-world benchmark results you may be able to share 😄 )

belm0 commented 2 years ago

Thank you!

If it's a real-world production application, I would recommend sticking with CPython, since Cinder isn't officially supported for use-cases outside Meta.

I'm able to manage the risks of early adoption, so not much concern there.

it may be reasonably realistic to try running your unmodified application using Cinder (potentially with the JIT and Lazy Imports enabled) and benchmark it

I've experimented with Cinder now and then for over a year. The results of letting Cinder have-at-it haven't been promising-- though I haven't tried the recent feature of only jitting above a call-count threshold (I'm skeptical, based on experiments manually flagging hot functions for jit).

I'm needing a solution within the next 12 months, so waiting for Python 3.12 or subsequent Cinder Python 3.12 is too far out. Not the answer I'd hoped for, but I guess I'll have to go down both roads (Python 3.11 and Cinder static modules) and let them race.

thinkwelltwd commented 2 years ago

I've also been giving Cinder a close look, but not wanting to run on v3.8 if it could be avoided. Like @belm0, am willing to manage the risks of early adoption. So I've watched the 3.10 branch with interest...

Once the 3.10 port is done

@itamaro do you have any input on how much is currently ported to 3.10? Is it 10/50/90% complete?

itamaro commented 2 years ago

how much is currently ported to 3.10? Is it 10/50/90% complete?

I think 10% would be a fair estimate. I'm hoping to ramp up the porting rate and get to 100% over the next few months (~3-ish?)

itamaro commented 2 years ago

@belm0 sorry this wasn't the answer you hoped for! definitely interested in any results you may have from taking both roads and letting them race :) any chance you can share some more info on your application?

belm0 commented 2 years ago

It's an embedded, production application that is heavily async. I presented a bit about it at PyCon a few years ago: https://trio.discourse.group/t/talk-productive-concurrency-with-trio-pycon-jp

belm0 commented 2 years ago

Initial test on my app shows 10% improvement from Python 3.8 to 3.11. It's disappointing that it landed at the bottom of the advertised "10-60%" speedup.

itamaro commented 2 years ago

Initial test on my app shows 10% improvement from Python 3.8 to 3.11. It's disappointing that it landed at the bottom of the advertised "10-60%" speedup.

that's not bad for a (mostly) effortless upgrade! 😄

carljm commented 2 years ago

Going to close this issue since I don't think there's anything specifically actionable for us here. 3.10 port is in progress, we are aiming to have it done in the next couple months; should be clear when we consider it done because the 3.8 branch will go inactive :)