Instagram Cinder Python Accelerator Open Sourced
Written by Kay Ewbank   
Thursday, 20 May 2021

Facebook has open sourced Cinder, Instagram's internal production version of CPython 3.8. Cinder has been developed to improve Python performance, and is now available as a Facebook incubator project.

Cinder contains a number of performance optimizations, including bytecode inline caching, eager evaluation of coroutines, a method-at-a-time JIT, and an experimental bytecode compiler that uses type annotations to emit type-specialized bytecode that performs better in the JIT.



Cinder, however, isn't supported; Facebook says Cinder has been made publicly available in the hope of opening conversations about the work being included in CPython at some point, and to reduce duplication of effort among people working on CPython performance.

The GitHub Readme says:

"Cinder is not polished or documented for anyone else's use. We don't have the capacity to support Cinder as an independent open-source project, nor any desire for it to become an alternative to CPython. Our goal in making this code available is a unified faster CPython. So while we do run Cinder in production, if you choose to do so you are on your own. We can't commit to fixing external bug reports or reviewing pull requests."

Cinder uses a number of techniques to improve performance, starting with immortal instances. These overcome the problem of overheads due to managing large numbers of long-lived objects. Immortal instances provide a way to opt-out objects from reference counting.

Shadowcode or shadow bytecode is another technique used in Cinder's inline caching implementation. Generic Python opcodes that are suitable for optimization are dynamically replaced with specialized versions.

Cipher also supports eager coroutine evaluation. If a call to an async function is immediately awaited, Cipher immediately executes the called function up to its first await. If the called function reaches a return without needing to await, it can then return that value directly without ever even creating a coroutine object or deferring to the event loop. This is a significant (~5%) CPU optimization in Instagram's async-heavy workload.

Cinder also includes a method-at-a-time custom JIT implemented in C++. that supports almost all Python opcodes, and can achieve 1.5-4x speed improvements on many Python performance benchmarks.

Other improvements include strict modules that combine a static analyzer that validates that executing a module's top-level code will not have side effects visible outside that module, and a Python module loader that analyzes opted-in modules and creates StrictModule objects.

Cinder also includes Static Python, an experimental bytecode compiler that emits type-specialized and type-checked Python bytecode. Used along with the Cinder JIT, it can deliver performance similar to MyPyC or Cython in many cases, while offering a pure-Python developer experience.




More Information

Cinder On GitHub

Related Articles

Python Language Summit 2020 - Python Typing

Google Promises Increased Support For Python

Python 3.8 Adds Walrus Operator


To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


Amazon App Store To Save Windows 11

One of the big, interesting, pieces of news about Windows 11 is that it will allow you to run Android applications. The problem is that Google is changing how Android apps are installed and this threa [ ... ]

W3C Promotes Web Audio API

The Web Audio API has been promoted by the W3C and is now an official standard as a JavaScript API for creating and manipulating audio content directly within web browsers.

More News





or email your comment to:

Last Updated ( Thursday, 20 May 2021 )