[Python-Dev] Opcode cache in ceval loop

Yury Selivanov yselivanov.ml at gmail.com
Mon Feb 1 16:27:47 EST 2016



On 2016-02-01 4:02 PM, Sven R. Kunze wrote:
> On 01.02.2016 21:35, Yury Selivanov wrote:
>> It's important to understand that if we have a lot of cache misses 
>> after the code object was executed 1000 times, it doesn't make sense 
>> to keep trying to update that cache.  It just means that the code, in 
>> that particular point, works with different kinds of objects.
>
> So, the assumption is that the code makes the difference here not 
> time. That could be true for production code.
>
>> FWIW, I experimented with different ideas (one is to never 
>> de-optimize), and the current strategy works best on the vast number 
>> of benchmarks.
>
> Nice.
>
> Regarding the magic constants (1000, 20) what is the process of 
> updating them?

Right now they are private constants in ceval.c.

I will (maybe) expose a private API via the _testcapi module to 
re-define them (set them to 1 or 0), only to write better unittests.  I 
have no plans to make those constants public or have a public API to 
tackle them.  IMHO, this is something that almost nobody will ever use.

Yury


More information about the Python-Dev mailing list