This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eelizondo
Recipients eelizondo, gregory.p.smith, nascheme, pablogsal, pitrou, tim.peters
Date 2020-04-12.01:01:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1586653293.47.0.652328879867.issue40255@roundup.psfhosted.org>
In-reply-to
Content
> the CPU performance implications of adding a branch instruction to Py_INCREC and Py_DECREF were, unsurprisingly, quite high.

Yeah, makes sense. I guess it really depends on the specific profile of your application.

For Instagram this was an overall net positive change and we still have it in prod. The amount of page faults from Copy on Writes was so large that reducing it resulted in a net CPU win (even with the added branching). And of course, a huge reduction in memory usage.


> Microbenchmarks don't tell a good story, the python performance test suite should

Agreed. I only added the Richards benchmark as a reference. I'm hoping someone can pick it up and have more concrete numbers on an average Python workload.


> Given that most people's applications don't fork workers, I do not expect to see such an implementation ever become the default.

In any case, I gated this change with ifdefs. In case we don't have it by default, we can always can easily enable it with a simple `-DPy_IMMORTAL_INSTANCES` flag to the compiler.

> Also note that this is an ABI change as those INCREF and DECREF definitions are intentionally public .h file

This has indeed been a bit of a pain for us as well. Due to how our tooling is set-up, there's a small number of third party libraries that are still causing Copy on Writes. Fortunately, that's the only drawback. Even if your immortalized object goes through an extension that has a different Py_{DECREF,INCREF} implementation, the reference count will still be so large that it will never be deallocated.
History
Date User Action Args
2020-04-12 01:01:33eelizondosetrecipients: + eelizondo, tim.peters, nascheme, gregory.p.smith, pitrou, pablogsal
2020-04-12 01:01:33eelizondosetmessageid: <1586653293.47.0.652328879867.issue40255@roundup.psfhosted.org>
2020-04-12 01:01:33eelizondolinkissue40255 messages
2020-04-12 01:01:32eelizondocreate