Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split opcodes into micro-ops #104909

Closed
gvanrossum opened this issue May 24, 2023 · 1 comment
Closed

Split opcodes into micro-ops #104909

gvanrossum opened this issue May 24, 2023 · 1 comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@gvanrossum
Copy link
Member

gvanrossum commented May 24, 2023

See faster-cpython/ideas#592. This project can be parallelized, and I could use help!

Note that initially we don't have a tier-2 interpreter or instruction format defined yet, but the first stage of splitting doesn't require that.

Remaining non-viable ops

With usage stats from the latest weekly pyperformance run (not all are uop candidates):

        956,835,460 YIELD_VALUE                        
        490,121,077 SEND_GEN                            (specialization of SEND)
        429,220,003 JUMP_FORWARD                       
        410,623,920 EXTENDED_ARG                       
        390,537,200 JUMP_BACKWARD_NO_INTERRUPT         
        250,483,954 RETURN_GENERATOR                   
        239,793,181 CALL_LIST_APPEND                    (specialization of CALL)
        168,297,543 CALL_KW                            
        162,922,780 FOR_ITER_GEN                        (specialization of FOR_ITER)
        157,442,920 CALL_PY_WITH_DEFAULTS               (specialization of CALL)
        145,986,780 BINARY_SUBSCR_GETITEM               (specialization of BINARY_SUBSCR)
        135,636,840 STORE_FAST_LOAD_FAST               
         83,118,452 MAKE_CELL                          
         74,149,898 CALL_FUNCTION_EX                   
         68,587,076 CALL_ALLOC_AND_ENTER_INIT           (specialization of CALL)
         49,897,724 STORE_ATTR_WITH_HINT                (specialization of STORE_ATTR)
         49,846,886 LOAD_ATTR_PROPERTY                  (specialization of LOAD_ATTR)
          8,224,500 RERAISE                            
          6,000,000 END_ASYNC_FOR                      
          5,801,385 BEFORE_WITH                        
          2,892,780 RAISE_VARARGS                      
          1,850,040 IMPORT_FROM                        
          1,813,620 IMPORT_NAME                        
                240 CLEANUP_THROW                      
                120 BEFORE_ASYNC_WITH                  
                    ENTER_EXECUTOR                     
                    LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN   (specialization of LOAD_ATTR)

Linked PRs

@gvanrossum gvanrossum added the type-bug An unexpected behavior, bug, or error label May 24, 2023
gvanrossum added a commit that referenced this issue May 31, 2023
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
carljm added a commit to carljm/cpython that referenced this issue Jun 15, 2023
* main: (57 commits)
  pythongh-105831: Fix NEWS blurb from pythongh-105828 (python#105833)
  pythongh-105820: Fix tok_mode expression buffer in file & readline tokenizer (python#105828)
  pythongh-105751, test_ctypes: Remove disabled tests (python#105826)
  pythongh-105821: Use a raw f-string in test_httpservers.py (python#105822)
  pythongh-105751: Remove platform usage in test_ctypes (python#105819)
  pythongh-105751: Reenable disable test_ctypes tests (python#105818)
  pythongh-105751: Remove dead code in test_ctypes (python#105817)
  More reorganisation of the typing docs (python#105787)
  Improve docs for `typing.dataclass_transform` (python#105792)
  pythonGH-89812: Churn `pathlib.Path` test methods (python#105807)
  pythongh-105800: Issue SyntaxWarning in f-strings for invalid escape sequences (python#105801)
  pythongh-105751: Cleanup test_ctypes imports (python#105803)
  pythongh-105481: add HAS_JUMP flag to opcode metadata (python#105791)
  pythongh-105751: test_ctypes avoids the operator module (pythonGH-105797)
  pythongh-105751: test_ctypes: Remove @need_symbol decorator (pythonGH-105798)
  pythongh-104909: Implement conditional stack effects for macros (python#105748)
  pythongh-75905: Remove test_xmlrpc_net: skipped since 2017 (python#105796)
  pythongh-105481: Fix types and a bug for pseudos (python#105788)
  Update DSL docs for cases generator (python#105753)
  pythonGH-77273: Better bytecodes for f-strings (pythonGH-6132)
  ...
gvanrossum added a commit that referenced this issue Jul 31, 2023
There's no need to use a dummy uop to skip unused cache entries. The macro syntax lets you write `unused/1` instead.

Similarly, move `unused/5` from op `_LOAD_ATTR_INSTANCE_VALUE` to macro `LOAD_ATTR_INSTANCE_VALUE`.
gvanrossum added a commit that referenced this issue Sep 27, 2023
These are the most popular specializations of `LOAD_ATTR` and `STORE_ATTR`
that weren't already viable uops:

* Split LOAD_ATTR_METHOD_WITH_VALUES
* Split LOAD_ATTR_METHOD_NO_DICT
* Split LOAD_ATTR_SLOT
* Split STORE_ATTR_SLOT
* Split STORE_ATTR_INSTANCE_VALUE

Also:

* Add `-v` flag to code generator which prints a list of non-viable uops
  (easter-egg: it can print execution counts -- see source)
* Double _Py_UOP_MAX_TRACE_LENGTH to 128



I had dropped one of the DEOPT_IF() calls! :-(
csm10495 pushed a commit to csm10495/cpython that referenced this issue Sep 28, 2023
These are the most popular specializations of `LOAD_ATTR` and `STORE_ATTR`
that weren't already viable uops:

* Split LOAD_ATTR_METHOD_WITH_VALUES
* Split LOAD_ATTR_METHOD_NO_DICT
* Split LOAD_ATTR_SLOT
* Split STORE_ATTR_SLOT
* Split STORE_ATTR_INSTANCE_VALUE

Also:

* Add `-v` flag to code generator which prints a list of non-viable uops
  (easter-egg: it can print execution counts -- see source)
* Double _Py_UOP_MAX_TRACE_LENGTH to 128



I had dropped one of the DEOPT_IF() calls! :-(
markshannon pushed a commit that referenced this issue Oct 4, 2023
* Split LOAD_ATTR_MODULE

* Split LOAD_ATTR_WITH_HINT

* Split _GUARD_TYPE_VERSION out of the latter

* Split LOAD_ATTR_CLASS

* Split LOAD_ATTR_NONDESCRIPTOR_WITH_VALUES

* Fix indent of DEOPT_IF in macros

* Split LOAD_ATTR_METHOD_LAZY_DICT

* Split LOAD_ATTR_NONDESCRIPTOR_NO_DICT

* Fix omission of _CHECK_ATTR_METHOD_LAZY_DICT
@iritkatriel iritkatriel added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Nov 26, 2023
@gvanrossum
Copy link
Member Author

Enough of this is done to close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants