Skip to content

GH-112383: Fix test_loop_quicken when an executor is installed #113153

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

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Dec 15, 2023

test.test_dis.DisWithFileTests.test_loop_quicken fails when tier two is enabled, since the ENTER_EXECUTOR instruction isn't handled correctly:

% ./python.exe -m test test_dis
Using random seed: 969128318
0:00:00 load avg: 3.43 Run 1 test sequentially
0:00:00 load avg: 3.43 [1/1] test_dis

== Tests result: SUCCESS ==

1 test OK.

Total duration: 445 ms
Total tests: run=127
Total test files: run=1/1
Result: SUCCESS
% ./python.exe -Xuops -m test test_dis
Using random seed: 2915026187
0:00:00 load avg: 3.55 Run 1 test sequentially
0:00:00 load avg: 3.55 [1/1] test_dis
test test_dis failed -- Traceback (most recent call last):
  File "/Users/brandtbucher/cpython/Lib/test/test_dis.py", line 1214, in test_loop_quicken
    self.do_disassembly_compare(got, expected)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/brandtbucher/cpython/Lib/test/test_dis.py", line 895, in do_disassembly_compare
    self.assertEqual(got, expected)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
AssertionError: '828 [599 chars]   16\n\n829   L2:     END_FOR\n              [31 chars]e)\n' != '828 [599 chars]   16 (to L1)\n\n829   L2:     END_FOR\n      [39 chars]e)\n'
  828           RESUME_CHECK             0
  
  829           BUILD_LIST               0
                LOAD_CONST               1 ((1, 2, 3))
                LIST_EXTEND              1
                LOAD_CONST               2 (3)
                BINARY_OP                5 (*)
                GET_ITER
        L1:     FOR_ITER_LIST           14 (to L2)
                STORE_FAST               0 (i)
  
  830           LOAD_GLOBAL_MODULE       1 (load_test + NULL)
                LOAD_FAST                0 (i)
                CALL_PY_WITH_DEFAULTS    1
                POP_TOP
-               JUMP_BACKWARD           16
+               JUMP_BACKWARD           16 (to L1)
?                                         ++++++++
  
  829   L2:     END_FOR
                RETURN_CONST             0 (None)


test_dis failed (1 failure)

== Tests result: FAILURE ==

1 test failed:
    test_dis

Total duration: 449 ms
Total tests: run=127 failures=1
Total test files: run=1/1 failed=1
Result: FAILURE

Instead of the current approach of trying to "fix" the test output in the presence of ENTER_EXECUTOR, just skip the test.

@iritkatriel
Copy link
Member

I think ultimately we want this to work. Can we adjust the expected value instead of disabling so that we won't forget to reverse the change once it's fixed?

@brandtbucher brandtbucher changed the title GH-112383: Skip test_loop_quicken an executor is installed GH-112383: Fix test_loop_quicken when an executor is installed Dec 15, 2023
@brandtbucher
Copy link
Member Author

Good idea. I've updated the comment, too.

@brandtbucher brandtbucher enabled auto-merge (squash) December 15, 2023 16:47
@brandtbucher brandtbucher merged commit d074832 into python:main Dec 15, 2023
Comment on lines +1216 to +1217
"ENTER_EXECUTOR 16",
"JUMP_BACKWARD 16 (to L1)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need an API on executor objects so you can access the vm_data field. We the API to get the executors should be an (unstable) method on PyCodeObject, not a function in _testinternalcapi.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need it though? Given the code object, we can always recover the original opcode and oparg using co_code (instead of _co_code_adaptive, which gives us the executor and index).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that works too. I guess my main point was that we shouldn't blindly assume ENTER_EXECUTOR sits on top of JUMP_BACKWARD. Although that is currently the case (and will still be so if/when my side-exits PR lands).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants