Instagram has made its performance-focused fork of Python, Cinder, publicly available as part of Facebook’s Incubator project on GitHub. Based on CPython 3.8, Cinder is designed to improve Python’s performance, with the goal of creating a faster, unified version of CPython. By open-sourcing the project, Instagram hopes to spark discussions about integrating some of its performance improvements into CPython, thus avoiding the need for redundant work on optimizing Python’s execution.
Cinder is packed with several performance optimizations that aim to boost execution speed. These include bytecode inline caching, which dynamically replaces generic opcodes with specialized versions; eager evaluation of coroutines, where async functions are immediately executed up to their first await; and a method-at-a-time JIT compiler. Additionally, Cinder experiments with using type annotations to generate type-specialized bytecode, which is then optimized by the JIT compiler for better performance. However, it’s important to note that Cinder is not yet fully polished or documented for general use.
While Instagram has released Cinder as an open-source project, they have made it clear that they do not have the capacity to support it as a fully-fledged open-source project. They also do not intend for Cinder to serve as a replacement for CPython. Instead, the project is intended to be used within Instagram’s own infrastructure to ensure better stability and performance for their specific use cases. There are no guarantees regarding Cinder’s stability, correctness, or general performance outside of Instagram’s production environment, but the company welcomes feedback from those interested in optimizing it further.
One of Cinder’s notable features is its inline caching implementation, which dynamically observes Python opcodes and replaces them with optimized versions for faster execution. Another significant optimization is its eager coroutine evaluation, which allows functions to return values directly when possible, avoiding unnecessary coroutine object creation and improving CPU performance in async-heavy workloads. Despite these enhancements, Instagram’s developers caution that Cinder should only be used by those who understand the intricacies of Python performance tuning.