bpo-43760: Check for tracing using 'bitwise or' instead of branch in dispatch. by markshannon · Pull Request #28723 · python/cpython · GitHub
Skip to content

bpo-43760: Check for tracing using 'bitwise or' instead of branch in dispatch. - #28723

Merged
markshannon merged 4 commits into
python:mainfrom
faster-cpython:use-tracing-bitwise
Oct 5, 2021
Merged

markshannon merged 4 commits into
python:mainfrom
faster-cpython:use-tracing-bitwise

Conversation

@markshannon

@markshannon markshannon commented Oct 4, 2021

Copy link
Copy Markdown
Member

About 1% faster

Use bitwise or instead of additional jump to handle tracing in dispatch.

What was:

    if (use_tracing)
        goto tracing_dispatch
    goto *jump_table[opcode];

becomes:

     goto *jump_table[opcode | use_tracing];

use_tracing is now either 0 or 255

Special opcode 255 (DO_TRACING) handles tracing and then jumps to the original instruction.

The main complexity comes from needing access to the last instruction when tracing. This means that we update frame->f_lasti and next_instr at the start of the instruction, instead of at the end of the previous instruction.

https://bugs.python.org/issue43760

@markshannon markshannon added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 4, 2021
@bedevere-bot

Copy link
Copy Markdown

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Oct 4, 2021
@markshannon

Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants