Facebook company published the source texts of the project Cinder , developing branch from CPYTHON 3.8.5 , the main reference programming language Python. Cinder applies to Facebook’s working infrastructure to ensure the operation of the Instagram service and includes optimization to improve performance.
The code is published to discuss the possibility of transferring prepared optimizations to the main composition of CPYthon and to help other projects engaged in the performance of CPYTHON. At the same time, Facebook is not going to support Cinder in the form of a separate open project and the code is represented as used in the company’s infrastructure, without additional hairstyle of code and documentation.
Cinder is also not trying to promote as an alternative to CPYTHON – the main purpose of the development is the desire to improve the CPYTHON itself.
Code is noted as quite reliable and proven in the working environment, but in case of identifying problems, they will have to be solved independently, since Facebook does not guarantee that it will respond to external error messages and puls. At the same time, FECEBOOK does not exclude constructive cooperation with the community and is ready to discuss ideas how to make Cinder even faster or how to speed up the transferred changes to the main composition of CPYthon.
Basic optimizations implemented in Cinder:
- inline-caching of bytecode (“Shadow Bytecode”). The essence of the method in identifying situations to perform a typical capode that can be optimized and dynamic replacement of such a capode to faster specialized options (for example, replacing frequently called functions).
- active computation of the Soprogram (Eager Coroutine Evaluation). For calls async functions that are immediately processed (await does not wait, the function reaches the RETURN statement earlier), the result of such functions is directly substituted without creating a signal and without attracting event processing cycle. In the facebook used in the Facebook, in which ASYNC / AWAIT is actively used, optimization leads to acceleration by about 5%.