GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Better uop coverage in the JIT optimizer · Issue #131798 · python/cpython

Better uop coverage in the JIT optimizer #131798

New issue
Copy link
New issue
Copy link
Open
Open
Better uop coverage in the JIT optimizer#131798
Copy link
Assignees
brandtbucher
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetopic-JITtype-featureA feature request or enhancementA feature request or enhancement

Description

@brandtbucher
brandtbucher
opened on Mar 27, 2025
Issue body actions

Out of 263 total uops, 155 of these are ignored by the tier two optimizer. These represent over half of all uops by dynamic execution count.

This issue will serve as a checklist for auditing these missing uops, and adding them where they make sense. At first glance, there's quite a bit of potential here... especially around ability to narrow known output types (like _CONTAINS_OP_SET), and the ability to narrow and remove guards on input types (like _BINARY_OP_SUBSCR_LIST_INT). As I'm going through, I'll cross out anything that doesn't seem like it makes sense to add.

First, here are the 53 missing uops that each represent at least 0.1% of all uops executed:

Details
  • _SET_IP (12.1%)
  • _CHECK_VALIDITY (10.1%)
  • _CHECK_VALIDITY_AND_SET_IP (6.5%)
  • _CHECK_PERIODIC (3.1%)
  • _MAKE_WARM (2.8%)
  • _START_EXECUTOR (1.7%)
  • _GUARD_NOS_INT (1.5%)
  • _BINARY_OP_SUBSCR_LIST_INT (1.0%)
  • _CHECK_FUNCTION (1.0%)
  • _CHECK_MANAGED_OBJECT_HAS_VALUES (0.7%)
  • _ITER_CHECK_LIST (0.7%)
  • _CONTAINS_OP_SET (0.6%)
  • _FOR_ITER_TIER_TWO (0.6%)
  • _GUARD_NOT_EXHAUSTED_LIST (0.6%)
  • _ITER_NEXT_LIST_TIER_TWO (0.6%)
  • _SAVE_RETURN_OFFSET (0.6%)
  • _CALL_LEN (0.5%)
  • _CALL_LIST_APPEND (0.5%)
  • _POP_TOP (0.5%)
  • _RESUME_CHECK (0.5%)
  • _BINARY_OP_SUBSCR_STR_INT (0.4%)
  • _GUARD_DORV_VALUES_INST_ATTR_FROM_DICT (0.4%)
  • _GUARD_KEYS_VERSION (0.4%)
  • _BINARY_OP_SUBSCR_DICT (0.3%)
  • _CALL_BUILTIN_FAST (0.3%)
  • _CHECK_STACK_SPACE_OPERAND (0.3%)
  • _GET_ITER (0.3%)
  • _STORE_SUBSCR (0.3%)
  • _GUARD_NOT_EXHAUSTED_RANGE (0.2%)
  • _BINARY_SLICE (0.2%)
  • _BUILD_LIST (0.2%)
  • _CALL_BUILTIN_O (0.2%)
  • _CALL_NON_PY_GENERAL (0.2%)
  • _CHECK_IS_NOT_PY_CALLABLE (0.2%)
  • _GUARD_NOS_FLOAT (0.2%)
  • _ITER_CHECK_RANGE (0.2%)
  • _ITER_CHECK_TUPLE (0.2%)
  • _LOAD_DEREF (0.2%)
  • _STORE_SUBSCR_LIST_INT (0.2%)
  • _BINARY_OP_EXTEND (0.1%)
  • _CALL_ISINSTANCE (0.1%)
  • _CALL_METHOD_DESCRIPTOR_FAST (0.1%)
  • _CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS (0.1%)
  • _CALL_METHOD_DESCRIPTOR_NOARGS (0.1%)
  • _CALL_TYPE_1 (0.1%)
  • _CHECK_ATTR_CLASS (0.1%)
  • _CONTAINS_OP_DICT (0.1%)
  • _GUARD_BINARY_OP_EXTEND (0.1%)
  • _GUARD_NOT_EXHAUSTED_TUPLE (0.1%)
  • _ITER_NEXT_TUPLE (0.1%)
  • _LIST_APPEND (0.1%)
  • _STORE_ATTR_SLOT (0.1%)
  • _STORE_SUBSCR_DICT (0.1%)

And here are the 102 missing uops that are less than 0.1%. These are less important, but still may net us some wins on individual benchmarks:

Details
  • _BINARY_OP_SUBSCR_CHECK_FUNC
  • _BINARY_OP_SUBSCR_TUPLE_INT
  • _BUILD_MAP
  • _BUILD_SET
  • _BUILD_SLICE
  • _BUILD_STRING
  • _CALL_BUILTIN_CLASS
  • _CALL_BUILTIN_FAST_WITH_KEYWORDS
  • _CALL_INTRINSIC_1
  • _CALL_INTRINSIC_2
  • _CALL_KW_NON_PY
  • _CALL_METHOD_DESCRIPTOR_O
  • _CALL_STR_1
  • _CALL_TUPLE_1
  • _CHECK_ATTR_METHOD_LAZY_DICT
  • _CHECK_EG_MATCH
  • _CHECK_EXC_MATCH
  • _CHECK_FUNCTION_VERSION_INLINE
  • _CHECK_FUNCTION_VERSION_KW
  • _CHECK_IS_NOT_PY_CALLABLE_KW
  • _CHECK_METHOD_VERSION
  • _CHECK_METHOD_VERSION_KW
  • _CHECK_PERIODIC_IF_NOT_YIELD_FROM
  • _CONVERT_VALUE
  • _COPY_FREE_VARS
  • _DELETE_ATTR
  • _DELETE_DEREF
  • _DELETE_FAST
  • _DELETE_GLOBAL
  • _DELETE_NAME
  • _DELETE_SUBSCR
  • _DEOPT
  • _DICT_MERGE
  • _DICT_UPDATE
  • _END_FOR
  • _END_SEND
  • _ERROR_POP_N
  • _EXIT_INIT_CHECK
  • _EXPAND_METHOD
  • _EXPAND_METHOD_KW
  • _FATAL_ERROR
  • _FORMAT_SIMPLE
  • _FORMAT_WITH_SPEC
  • _GET_AITER
  • _GET_ANEXT
  • _GET_AWAITABLE
  • _GET_LEN
  • _GET_YIELD_FROM_ITER
  • _GUARD_DORV_NO_DICT
  • _GUARD_GLOBALS_VERSION
  • _GUARD_TOS_FLOAT
  • _GUARD_TOS_INT
  • _GUARD_TYPE_VERSION_AND_LOCK
  • _IMPORT_FROM
  • _IMPORT_NAME
  • _IS_NONE
  • _LIST_EXTEND
  • _LOAD_ATTR_NONDESCRIPTOR_NO_DICT
  • _LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES
  • _LOAD_BUILD_CLASS
  • _LOAD_COMMON_CONSTANT
  • _LOAD_FAST_LOAD_FAST
  • _LOAD_FROM_DICT_OR_DEREF
  • _LOAD_GLOBAL
  • _LOAD_GLOBAL_BUILTINS
  • _LOAD_GLOBAL_MODULE
  • _LOAD_LOCALS
  • _LOAD_NAME
  • _LOAD_SUPER_ATTR_ATTR
  • _LOAD_SUPER_ATTR_METHOD
  • _MAKE_CALLARGS_A_TUPLE
  • _MAKE_CELL
  • _MAKE_FUNCTION
  • _MAP_ADD
  • _MATCH_CLASS
  • _MATCH_KEYS
  • _MATCH_MAPPING
  • _MATCH_SEQUENCE
  • _MAYBE_EXPAND_METHOD_KW
  • _NOP
  • _POP_EXCEPT
  • _POP_TWO_LOAD_CONST_INLINE_BORROW
  • _PUSH_EXC_INFO
  • _PUSH_NULL_CONDITIONAL
  • _SETUP_ANNOTATIONS
  • _SET_ADD
  • _SET_FUNCTION_ATTRIBUTE
  • _SET_UPDATE
  • _STORE_ATTR
  • _STORE_ATTR_INSTANCE_VALUE
  • _STORE_ATTR_WITH_HINT
  • _STORE_DEREF
  • _STORE_FAST_LOAD_FAST
  • _STORE_FAST_STORE_FAST
  • _STORE_GLOBAL
  • _STORE_NAME
  • _STORE_SLICE
  • _TIER2_RESUME_CHECK
  • _UNARY_INVERT
  • _UNARY_NEGATIVE
  • _UNPACK_SEQUENCE_LIST
  • _WITH_EXCEPT_START

Linked PRs

  • GH-131798: Allow the JIT to remove more int/float/str guards #131800
  • GH-131798: Remove guard for known type in TO_BOOL_STR #131816
  • gh-131798: JIT: Narrow the return type of _CONTAINS_OP_SET to bool #132057
  • gh-131798: JIT: Narrow the return type of _BINARY_OP_SUBSCR_STR_INT to str #132153
  • gh-131798: Allow the JIT to remove an extra _TO_BOOL_BOOL for _CONTAINS_OP_DICT #132269
  • GH-131798: Skip self/NULL checks for some known non-methods #132278
  • GH-131798: Remove JIT guards for dict, frozenset, list, set, and tuple #132289
  • gh-131798: JIT: Split CALL_TYPE_1 into several uops #132419
  • gh-131798: Use sym_new_type instead of sym_new_not_null for _BUILD_LIST, _BUILD_SLICE, and _BUILD_MAP #132434
  • gh-131798: Use sym_new_type instead of sym_new_not_null for _BUILD_STRING, _BUILD_SET #132564
  • gh-131798: JIT: Split CALL_STR_1 into several uops #132849
  • gh-131798: JIT: Split CALL_TUPLE_1 into several uops #132851
  • gh-131798: JIT: Narrow the return type of _CALL_LEN to int #132940
  • gh-131798: JIT: Propagate the result in _BINARY_OP_SUBSCR_TUPLE_INT #133003
  • gh-131798: JIT: Narrow the return type of isinstance for some known arguments #133172
  • gh-131798: Split CALL_LEN into several uops #133180
  • gh-131798: JIT: Split CALL_ISINSTANCE into several uops #133339
  • gh-131798: JIT: Narrow the return type of _GET_LEN to int #133345
  • gh-131798: JIT: Narrow the return type of _BINARY_SLICE to original container type #133527
  • gh-131798: JIT: Assign type to sliced string #133609
  • gh-131798: Split CALL_LIST_APPEND into serveral uops #134240
  • gh-131798: JIT: Add _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW #134268
  • gh-131798: JIT: Optimize _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW #134369
  • GH-131798: Narrow types more aggressively in the JIT #134373
  • GH-131798: Optimize cached class attributes and methods in the JIT #134403
  • gh-131798: JIT: replace _LOAD_SMALL_INT with _LOAD_CONST_INLINE_BORROW #134406
  • gh-131798: JIT: Further optimize _CALL_ISINSTANCE for class tuples #134543
  • gh-131798: Small improvements to remove_unneeded_uops #134554
  • gh-131798: JIT: Assign type to sliced string/list/tuple #134671
  • gh-131798: Optimize _ITER_CHECK_TUPLE #134803
  • gh-131798: JIT: replace _CHECK_METHOD_VERSION with _CHECK_FUNCTION_VERSION_INLINE #135022
  • gh-131798: JIT: Optimize _CALL_TYPE_1 when the result is known #135194
  • gh-131798: Optimize _UNARY_INVERT #135222
  • gh-131798: Optimize _UNARY_NEGATIVE #135223
  • gh-131798: JIT: Optimize _CALL_LEN when the length is known #135260
  • gh-131798: Remove bounds check when indexing into tuples with a constant index #137607
  • gh-131798: Support generator frames in the JIT optimizer #143340
  • gh-131798: JIT optimizer: Support custom binary op and property frames #143735
  • GH-131798: Optimize _GUARD_TOS_SLICE #144470
  • gh-131798: Optimize _ITER_CHECK_RANGE and _ITER_CHECK_LIST in the JIT #144583
  • gh-131798: Split CHECK_FUNCTION_VERSION into two guards in the JIT #145080
  • gh-131798: JIT: optimize _LOAD_COMMON_CONSTANT #146104
  • gh-GH-131798: optimize jit attribute loads on immutable types #146449
  • gh-131798: JIT: split call method and call builtin opcodes into smaller uops #146463
  • gh-131798: Narrow the return type of _FORMAT_SIMPLE and _FORMAT_WITH_SPEC to str #146639
  • gh-131798: JIT inline function addresses of builtin methods  #146906
  • gh-131798: relax GUARD_CALLABLE checks for self type checks #148069
  • gh-131798: split recursion check to _CHECK_RECURSION_LIMIT and combine checks #148070
  • gh-131798: split _CALL_BUILTIN_CLASS to smaller uops #148094
  • gh-131798: Add MATCH_SEQUENCE/MAPPING to the JIT optimizer #148124
  • gh-131798: fold super method lookups in JIT #148231
  • gh-131798: constant fold classmethod and staticmethod in JIT #148331
  • gh-131798: Add _IS_NONE to the JIT optimizer #148369
  • gh-131798: Split FOR_ITER_GEN into smaller uops #148372
  • gh-131798: do not watch immutable types in JIT #148383
  • gh-131798: JIT inline function pointer address for extended binary op #148384
  • gh-131798: constant fold special method lookup in JIT #148432
  • gh-131798: Split _CHECK_AND_ALLOCATE_OBJECT into smaller uops #148433
  • gh-131798: Add _CHECK_IS_NOT_PY_CALLABLE to the JIT optimizer #148434
  • gh-131798: optimize through keyword and bound method calls in the JIT #148466
  • gh-131798: JIT: Optimize _CHECK_IS_NOT_PY_CALLABLE_EX and _CHECK_IS_NOT_PY_CALLABLE_KW #148494
  • gh-131798: Constant-fold _CONTAINS_OP_DICT for frozendict #148548
  • gh-gh-131798: optimize LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN in the JIT #148555
  • gh-131798: Fix _ITER_CHECK_RANGE type in the JIT #148607
  • gh-131798: Add _GET_ITER_TRAD to JIT optimizer #148724
  • gh-131798: Add tier-2 list specialization for STORE_SLICE #149446
  • gh-131798: Propagate iterator types from GET_ITER in the JIT #157011
Reacted by You Jiacheng, Joe Fang, Nadeshiko Manju, jason, Noam Cohen, tobiichi3227, Mingzhu Yan, Vladimir, Yongtao Huang, baseplate-admin and 1 more

Activity

Next
  1. brandtbucher
    added
    3.14bugs and security fixesbugs and security fixes
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    performancePerformance or resource usagePerformance or resource usage
    topic-JIT
    on Mar 27, 2025
  2. brandtbucher
    self-assigned this
    on Mar 27, 2025
  3. brandtbucher
    added a commit that references this issue on Mar 30, 2025

    GH-131798: Remove type checks for _TO_BOOL_STR (GH-131816)

    685fd74
  4. brandtbucher commented on Apr 1, 2025

    @brandtbucher
    brandtbucher
    on Apr 1, 2025
    MemberAuthor
    More actions

    @diegorusso is going to add _CALL_LEN.

  5. brandtbucher
    added a commit that references this issue on Apr 1, 2025

    GH-131798: Allow the JIT to remove more int/float/str guards (GH-131800)

    1a9d4a1
  6. brandtbucher commented on Apr 3, 2025

    @brandtbucher
    brandtbucher
    on Apr 3, 2025
    MemberAuthor
    More actions

    @fluhus is going to add _BINARY_SLICE.

  7. brandtbucher commented on Apr 3, 2025

    @brandtbucher
    brandtbucher
    on Apr 3, 2025
    MemberAuthor
    More actions

    @Klaus117 is going to improve _TO_BOOL_INT.

  8. brandtbucher
    added a commit that references this issue on Apr 5, 2025

    GH-131798: Narrow the result of _CONTAINS_OP_SET to bool in the JIT (G…

    85bc489
  9. picnixz
    added
    type-featureA feature request or enhancementA feature request or enhancement
    and removed
    3.14bugs and security fixesbugs and security fixes
    on Apr 5, 2025
  10. brandtbucher commented on Apr 7, 2025

    @brandtbucher
    brandtbucher
    on Apr 7, 2025
    MemberAuthor
    More actions

    @Zheaoli is going to add _CONTAINS_OP_DICT.

    Reacted by Nadeshiko Manju
  11. Zheaoli
    added a commit that references this issue on Apr 8, 2025

    pythongh-131798: Allow the JIT to remove an extra _TO_BOOL_BOOL for _…

    9053639
  12. 186 remaining items

    Load more actions
  13. ljfp
    added 7 commits that reference this issue on Apr 25, 2026

    pythongh-131798: Split `_CHECK_AND_ALLOCATE_OBJECT` into smaller uops (…

    8aac827

    pythongh-131798: optimize through keyword and bound method calls in t…

    ff5f784

    pythongh-131798: JIT: Optimize `_CHECK_IS_NOT_PY_CALLABLE_EX` and `_C…

    9dca9b8

    pythongh-131798: Constant-fold `_CONTAINS_OP_DICT` for frozendict (py…

    1cfaf74

    gh-pythongh-131798: optimize `LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN` in t…

    4a77ac5

    pythongh-131798: constant fold special method lookups in JIT (python#…

    d5aa60d

    pythongh-131798: Fix `_ITER_CHECK_RANGE` type in the JIT (python#148607)

    2e46afa
  14. gostak-dd
    added 8 commits that reference this issue on Jun 2, 2026

    pythonGH-131798: Narrow the return type of _GET_LEN to int (pythonGH-…

    b8e48ba

    pythonGH-131798: Narrow types more aggressively in the JIT (pythonGH-…

    3d66658

    pythonGH-131798: Turn _LOAD_SMALL_INT into _LOAD_CONST_INLINE_BORROW …

    3cfa9a2

    pythonGH-131798: Optimize cached class attributes and methods in the …

    adc4893

    pythonGH-131798: Optimize away isinstance calls in the JIT (pythonGH-…

    6bb5112

    pythonGH-131798: Optimize away isinstance calls in the JIT (pythonGH-…

    55fbc43

    pythongh-131798: Small improvements to `remove_unneeded_uops` (python…

    b27c12e

    pythongh-131798: Optimize `_ITER_CHECK_TUPLE` (pythonGH-134803)

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

Metadata

Metadata

Assignees

  • @brandtbucher
    brandtbucher

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetopic-JITtype-featureA feature request or enhancementA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.