Instagram open sources high-performance Python fork

By making the Cinder project publicly available, the company wants to open conversation about upstreaming its performance optimizations to standard Python.

Instagram open sources high-performance Python fork

Instagram’s Cinder, a performance-oriented fork of CPython 3.8, is now available as a Facebook Incubator project on GitHub. The goal of releasing the code was to produce a unified, faster CPython, the company said.

Instagram made Cinder publicly available to generate conversation about upstreaming some of the work to CPython, which is the reference implementation of Python, and reducing duplication of work pertaining to CPython performance.

Cinder features performance optimizations including bytecode inline caching, eager evaluation of coroutines, a method-at-a-time JIT compiler, and an experimental bytecode compiler that uses type annotations to emit type-specialized bytecode that runs better in the JIT. However, Cinder is neither polished nor documented for anyone’s use.

Furthermore, Instagram said there is “no capacity” to support Cinder as an open source project, nor any desire for it to become an alternative to CPython. The developers of Cinder said the goal is to make sure Cinder is sufficiently stable and fast for their production workload but they make no assurances about its stability or correctness or performance for any other workload. They extended an invitation for feedback from anyone who knows how to make Cinder faster.

Cinder’s inline caching implementation observes optimizable cases in the execution of generic Python opcodes and dynamically replaces those opcodes with specialized versions. For eager coroutine evaluation, if a call to an async function is immediately awaited, the platform executes the called function up to its first await. If the called function reaches a return without needing to await, Cinder will return that value directly without creating a coroutine object or deferring to the event loop. This provides a CPU optimization in an async-heavy workload.

Cinder is built and tested on Linux x64. Other platforms, such as MacOS, probably will not work, the developers said.

Copyright © 2021 IDG Communications, Inc.