Skip to content

Direct unit tests for compiler optimisations #93678

Description

@iritkatriel

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.

Activity

  1. added
    type-featureA feature request or enhancement
    testsTests in the Lib/test dir
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    on Jun 10, 2022
  2. self-assigned this
    on Jun 10, 2022
  3. added 2 commits that reference this issue on Jun 14, 2022
  4. added 6 commits that reference this issue on Jul 19, 2022
  5. tiran commented on Jul 26, 2022

    @tiran
    Member

    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.

  6. iritkatriel commented on Jul 26, 2022

    @iritkatriel
    MemberAuthor

    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.

  7. 4 remaining items

  8. tiran commented on Jul 26, 2022

    @tiran
    Member

    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.

  9. iritkatriel commented on Jul 26, 2022

    @iritkatriel
    MemberAuthor

    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?

  10. tiran commented on Jul 27, 2022

    @tiran
    Member

    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
    
  11. iritkatriel commented on Jul 27, 2022

    @iritkatriel
    MemberAuthor

    I created #95335 to track the WASM problem.

  12. added a commit that references this issue on Jul 27, 2022
  13. added 4 commits that reference this issue on Aug 10, 2022
  14. added a commit that references this issue on Aug 24, 2022
  15. added a commit that references this issue on Aug 24, 2022
  16. added a commit that references this issue on Aug 25, 2022
  17. added a commit that references this issue on Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)testsTests in the Lib/test dirtype-featureA feature request or enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions