This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Specialize COMPARE_OP
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Dennis Sweeney, Mark.Shannon, brandtbucher
Priority: normal Keywords: patch

Created on 2021-11-23 21:00 by Dennis Sweeney, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29734 merged Dennis Sweeney, 2021-11-23 21:00
PR 31040 merged Dennis Sweeney, 2022-02-01 01:14
PR 31516 merged brandtbucher, 2022-02-22 23:57
Messages (5)
msg406887 - (view) Author: Dennis Sweeney (Dennis Sweeney) * (Python committer) Date: 2021-11-23 21:00
Some specialization statistics:

https://gist.github.com/sweeneyde/49cc3a9d074d56cf095cb0a42d13d7a4

Including 3 opcodes: COMPARE_OP_INT and COMPARE_OP_FLOAT and COMPARE_OP_STR (equality only) seems to give pretty good specialization numbers, better than just 2.
msg406930 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-11-24 13:53
Is COMPARE_OP worth specializing by itself?

Most comparisons are followed by a jump, and much of the overhead is in the branching around the choice of operator as well as pushing and popping (with inc/decrefs) a value that has only one bit of information (True/False).
msg407577 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-12-03 11:29
New changeset 03768c4d139df46212a091ed931aad03bec18b57 by Dennis Sweeney in branch 'main':
bpo-45885: Specialize COMPARE_OP (GH-29734)
https://github.com/python/cpython/commit/03768c4d139df46212a091ed931aad03bec18b57
msg412441 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-03 13:33
New changeset 674ab66ebdf06f187e193a3d7bde13b71ba0f9af by Dennis Sweeney in branch 'main':
bpo-45885: Add more stats for COMPARE_OP in specialize.c (GH-31040)
https://github.com/python/cpython/commit/674ab66ebdf06f187e193a3d7bde13b71ba0f9af
msg413784 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2022-02-23 11:06
New changeset 375a56bd4015596c0cf44129c8842a1fe7199785 by Brandt Bucher in branch 'main':
bpo-45885: Don't un-adapt `COMPARE_OP` when collecting stats (GH-31516)
https://github.com/python/cpython/commit/375a56bd4015596c0cf44129c8842a1fe7199785
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 90043
2022-02-23 11:06:35Mark.Shannonsetmessages: + msg413784
2022-02-22 23:57:25brandtbuchersetnosy: + brandtbucher

pull_requests: + pull_request29643
2022-02-03 13:33:04Mark.Shannonsetmessages: + msg412441
2022-02-01 01:14:45Dennis Sweeneysetpull_requests: + pull_request29223
2021-12-03 23:45:56Dennis Sweeneysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-12-03 11:29:16Mark.Shannonsetmessages: + msg407577
2021-11-24 13:53:03Mark.Shannonsetnosy: + Mark.Shannon
messages: + msg406930
2021-11-23 21:00:53Dennis Sweeneysetkeywords: + patch
stage: patch review
pull_requests: + pull_request27972
2021-11-23 21:00:24Dennis Sweeneycreate