python / python/cpython

Needs of feature that disabling optimization pipeline in runtime

Open
#119,158 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-feature
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

@iritkatriel
This feature is needed for debugging or experimentation when handling optimized bytecode.
When I want to take a look at the sequence of bytecodes that is optimized with the specific pipeline but not all pipelines, I need to disable several pipelines from https://github.com/python/cpython/blob/30b4e9f9c42493136c58c56fee5553128bb32428/Python/flowgraph.c#L1843-L1851 and rebuild the CPython it's pretty painful because when I want to change the combination of optimization than I should rebuild CPython every time.

It would be great if there is a way to disable specific optimization pipelines at runtime when I want.
Above example is just one specific case and sometime I want to disable all _PyCfg_OptimizeCodeUnit or part of _PyCfg_OptimizeCodeUnit.

This is what I wanted to ask about at the PyCon and will happy to see your opinion about this.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Python/flowgraph.c at the _PyCfg_OptimizeCodeUnit pipeline referenced in the issue, and trace how its optimization stages are selected during runtime. Define how specific stages or the entire pipeline could be disabled without rebuilding CPython, then verify that different optimization combinations can be inspected as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.