Author yselivanov
Recipients gvanrossum, vstinner, yselivanov
Date 2016-09-14.20:48:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473886080.87.0.000411119678127.issue28158@psf.upfronthosting.co.za>
In-reply-to
Content
The attached patch implements an opcode cache for LOAD_GLOBAL opcode, making it 2x faster.

The idea is to use the new co_extra field of code objects & PEP 509 to attach a cache structure pointing directly to the resolved global name.  When globals or builtins are updated, the cache is invalidated.

The patch adds a new file "ceval_cache.h" which provides some infrastructure to ease the pain of implementing new caches for other opcode types.  I can strip down all macros from that file if Victor finds it too hard to review.

Here's a simple script I used to make sure that the cache is working: https://gist.github.com/1st1/a9660aabdcf6b8bc6205b9fe39a82bba

You can also set OPCACHE_COLLECT_STATS to 1 to get debug stats output for the cache.
History
Date User Action Args
2016-09-14 20:48:01yselivanovsetrecipients: + yselivanov, gvanrossum, vstinner
2016-09-14 20:48:00yselivanovsetmessageid: <1473886080.87.0.000411119678127.issue28158@psf.upfronthosting.co.za>
2016-09-14 20:48:00yselivanovlinkissue28158 messages
2016-09-14 20:48:00yselivanovcreate