New submission from Yury Selivanov:

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.

----------
assignee: yselivanov
components: Interpreter Core
files: load_globals_cache.patch
keywords: patch
messages: 276485
nosy: gvanrossum, haypo, yselivanov
priority: critical
severity: normal
stage: patch review
status: open
title: Implement LOAD_GLOBAL opcode cache
type: performance
versions: Python 3.6
Added file: http://bugs.python.org/file44668/load_globals_cache.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28158>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to