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 — Direct unit tests for compiler optimisations · Issue #93678 · python/cpython

Direct unit tests for compiler optimisations #93678

New issue
Copy link
New issue
Copy link
Closed
#96274
Closed
Direct unit tests for compiler optimisations#93678
#96274
Copy link
Assignees
iritkatriel
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirTests in the Lib/test dirtype-featureA feature request or enhancementA feature request or enhancement

Description

@iritkatriel
iritkatriel
opened on Jun 10, 2022
Issue body actions

We currently do not have a way to directly test compiler optimisations, and the tests we have are not always reliable (more background).

We need to be able to feed a sequence of bytecode instructions into the optimiser from python, and get its output back into python. Then we can write tests.

Reacted by Dennis Sweeney and Erlend E. Aasland

Activity

Next
  1. iritkatriel
    added
    type-featureA feature request or enhancementA feature request or enhancement
    testsTests in the Lib/test dirTests in the Lib/test dir
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Jun 10, 2022
  2. iritkatriel
    self-assigned this
    on Jun 10, 2022
  3. iritkatriel
    added 2 commits that reference this issue on Jun 14, 2022

    GH-93678: reduce boilerplate and code repetition in the compiler (GH-…

    af15cc5

    GH-93678: refactor compiler so that optimizer does not need the assem…

    889772f
  4. serhiy-storchaka
    added a commit that references this issue on Jun 26, 2022

    Revert 30935 defer bpo45162 to 312 (#94285)

    1ffde3e
  5. iritkatriel
    added 6 commits that reference this issue on Jul 19, 2022

    gh-93678: move normalize_basic_block and extend_block call into optim…

    ea11c17

    pythongh-93678: extract 'struct cfg' from the compiler so that the CF…

    98b4902

    pythongh-93678: extract 'struct cfg' from the compiler so that the CF…

    7188aca

    gh-93678: extract 'struct cfg_builder' from the compiler so that the …

    75c0c1b

    pythongh-93678: extract 'struct cfg' from the compiler so that the CF…

    d88ba72
  6. tiran commented on Jul 26, 2022

    @tiran
    tiran
    on Jul 26, 2022
    Member
    More actions

    The PR seems to have increase stack consumption slightly. Some tests are now failing on WASI because the WASM runtime is running out of stack space, https://buildbot.python.org/all/#/builders/1046/builds/278

    In the past I have solved similar issues by replacing a hard-coded limit (e.g. 1000) with the current recursion limit. WASI has a lower default recursion limit.

  7. iritkatriel commented on Jul 26, 2022

    @iritkatriel
    iritkatriel
    on Jul 26, 2022
    MemberAuthor
    More actions

    The PR seems to have increase stack consumption slightly. Some tests are now failing on WASI because the WASM runtime is running out of stack space, https://buildbot.python.org/all/#/builders/1046/builds/278

    In the past I have solved similar issues by replacing a hard-coded limit (e.g. 1000) with the current recursion limit. WASI has a lower default recursion limit.

    Thanks for the ping. I would guess it's because we now have things like compiler_new_block calling cfg_builder_new_block. It basically glue to avoid changing all the calls. I'll inline/replace them in a future PR.

    Reacted by Christian Heimes
  8. 4 remaining items

  9. tiran commented on Jul 26, 2022

    @tiran
    tiran
    on Jul 26, 2022
    Member
    More actions

    I have added a temporary band-aid in GH-95296. Feel free to remove the skips if you have a solution for the additional stack use.

    Reacted by Irit Katriel
  10. iritkatriel commented on Jul 26, 2022

    @iritkatriel
    iritkatriel
    on Jul 26, 2022
    MemberAuthor
    More actions

    I have added a temporary band-aid in GH-95296. Feel free to remove the skips if you have a solution for the additional stack use.

    Is there a way I can reproduce it?

  11. tiran commented on Jul 27, 2022

    @tiran
    tiran
    on Jul 27, 2022
    Member
    More actions

    Here is a full WASM stack trace generated with

    WASMTIME_BACKTRACE_DETAILS=1 \
      wasmtime run --env PYTHONPATH=/builddir/wasi/$(cat pybuilddir.txt) --mapdir /::../../ -- \
      python.wasm -m test -v test_compile -m test_compiler_recursion_limit
    

    wasi_stacktrace.txt

    test_compiler_recursion_limit (test.test_compile.TestSpecifics.test_compiler_recursion_limit) ... Error: failed to run main module `python.wasm`
    
    Caused by:
        0: failed to invoke command default
        1: wasm trap: out of bounds memory access
           wasm backtrace:
               0: 0x15d8eb - compiler_visit_expr
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5868:37
               1: 0x15ee62 - compiler_call
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:4846:5
                         - compiler_visit_expr1
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5802:16
                         - compiler_visit_expr
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5870:15
               2: 0x15ee62 - compiler_call
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:4846:5
                         - compiler_visit_expr1
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5802:16
                         - compiler_visit_expr
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5870:15
               3: 0x15ee62 - compiler_call
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:4846:5
                         - compiler_visit_expr1
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5802:16
                         - compiler_visit_expr
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5870:15
               4: 0x15ee62 - compiler_call
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:4846:5
                         - compiler_visit_expr1
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5802:16
                         - compiler_visit_expr
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5870:15
               5: 0x15ee62 - compiler_call
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:4846:5
                         - compiler_visit_expr1
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5802:16
                         - compiler_visit_expr
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5870:15
               6: 0x15ee62 - compiler_call
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:4846:5
                         - compiler_visit_expr1
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5802:16
                         - compiler_visit_expr
                               at /python-wasm/cpython/builddir/wasi/../../Python/compile.c:5870:15
    
  12. iritkatriel commented on Jul 27, 2022

    @iritkatriel
    iritkatriel
    on Jul 27, 2022
    MemberAuthor
    More actions

    I created #95335 to track the WASM problem.

  13. iritkatriel
    added a commit that references this issue on Jul 27, 2022

    pythongh-93678: inline a few compiler functions to reverse the recent…

    5f881d9
  14. iritkatriel
    added 4 commits that reference this issue on Aug 10, 2022

    pythongh-93678: extract 'struct cfg' from the compiler so that the CF…

    520fd4b

    pythongh-93678: added _testinternalcapi.optimize_cfg() function and t…

    2790434

    pythongh-93678: added _testinternalcapi.optimize_cfg() function and t…

    b6014af

    pythongh-93678: added _testinternalcapi.optimize_cfg() function and t…

    7d44721
  15. iritkatriel
    added a commit that references this issue on Aug 24, 2022

    gh-93678: add _testinternalcapi.optimize_cfg() and test utils for com…

    420f39f
  16. mdboom
    added a commit that references this issue on Aug 24, 2022

    pythongh-93678: add _testinternalcapi.optimize_cfg() and test utils f…

    81912fc
  17. iritkatriel
    added a commit that references this issue on Aug 25, 2022

    pythongh-93678: apply remove_redundant_jumps in optimize_cfg

    79a0268
  18. iritkatriel
    closed this as completedin #96274on Sep 1, 2022
  19. iritkatriel
    added a commit that references this issue on Sep 1, 2022

    gh-93678: apply remove_redundant_jumps in optimize_cfg (GH-96274)

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

Metadata

Metadata

Assignees

  • @iritkatriel
    iritkatriel

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirTests in the Lib/test dirtype-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.