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: Merge BINARY_*/INPLACE_* into BINARY_OP
Type: performance Stage: resolved
Components: Interpreter Core Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: brandtbucher Nosy List: Mark.Shannon, brandtbucher, gvanrossum, iritkatriel
Priority: normal Keywords: patch

Created on 2021-10-27 22:13 by brandtbucher, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29255 closed brandtbucher, 2021-10-27 22:15
PR 29418 closed brandtbucher, 2021-11-05 05:06
PR 29482 merged brandtbucher, 2021-11-09 01:07
PR 29532 merged brandtbucher, 2021-11-12 04:02
PR 29565 merged brandtbucher, 2021-11-15 21:38
PR 30073 open iritkatriel, 2021-12-12 15:47
Messages (7)
msg405136 - (view) Author: Brandt Bucher (brandtbucher) * (Python committer) Date: 2021-10-27 22:13
...as discussed in https://github.com/faster-cpython/ideas/issues/101.

This change merges all BINARY_*/INPLACE_* instructions, except for a few special cases:

- BINARY_ADD/INPLACE_ADD, which interact with sq_concat/sq_inplace_concat and already have their own specialization family.
- BINARY_MULTIPLY/INPLACE_MULTIPLY, which interact with sq_repeat/sq_inplace_repeat and already have their own specialization family.
- BINARY_POWER/INPLACE_POWER, which are technically ternary operators under-the-hood.
- BINARY_MODULO/INPLACE_MODULO, which contain a special fast path for string formatting (but likely can be rolled in later as a specialization).

It has no mean impact on pyperformance, shrinks the eval loop, and makes it much simpler to implement operator specializations.
msg405179 - (view) Author: Mark Shannon (Mark.Shannon) * (Python committer) Date: 2021-10-28 12:14
Do you have results for pyperformance?
msg405221 - (view) Author: Brandt Bucher (brandtbucher) * (Python committer) Date: 2021-10-28 18:40
Slower (29):
- unpack_sequence: 43.7 ns +- 0.9 ns -> 45.7 ns +- 1.1 ns: 1.04x slower
- float: 80.5 ms +- 0.9 ms -> 83.5 ms +- 1.3 ms: 1.04x slower
- regex_effbot: 3.15 ms +- 0.03 ms -> 3.26 ms +- 0.04 ms: 1.04x slower
- go: 165 ms +- 1 ms -> 171 ms +- 3 ms: 1.03x slower
- pickle_dict: 26.8 us +- 0.1 us -> 27.5 us +- 0.1 us: 1.03x slower
- scimark_monte_carlo: 77.5 ms +- 0.8 ms -> 79.3 ms +- 1.3 ms: 1.02x slower
- sqlalchemy_imperative: 18.6 ms +- 0.5 ms -> 18.9 ms +- 0.9 ms: 1.02x slower
- chaos: 76.7 ms +- 0.7 ms -> 78.1 ms +- 0.8 ms: 1.02x slower
- logging_format: 6.73 us +- 0.09 us -> 6.84 us +- 0.08 us: 1.02x slower
- richards: 56.9 ms +- 0.9 ms -> 57.7 ms +- 1.0 ms: 1.01x slower
- chameleon: 7.48 ms +- 0.10 ms -> 7.58 ms +- 0.12 ms: 1.01x slower
- json_loads: 25.4 us +- 0.2 us -> 25.7 us +- 0.2 us: 1.01x slower
- sympy_expand: 501 ms +- 5 ms -> 507 ms +- 4 ms: 1.01x slower
- logging_silent: 116 ns +- 3 ns -> 117 ns +- 2 ns: 1.01x slower
- django_template: 37.2 ms +- 0.5 ms -> 37.7 ms +- 0.4 ms: 1.01x slower
- regex_v8: 23.2 ms +- 0.1 ms -> 23.4 ms +- 0.3 ms: 1.01x slower
- regex_dna: 212 ms +- 1 ms -> 214 ms +- 1 ms: 1.01x slower
- xml_etree_process: 59.1 ms +- 0.6 ms -> 59.6 ms +- 0.6 ms: 1.01x slower
- xml_etree_generate: 80.4 ms +- 0.7 ms -> 81.2 ms +- 0.8 ms: 1.01x slower
- scimark_lu: 138 ms +- 3 ms -> 140 ms +- 3 ms: 1.01x slower
- logging_simple: 6.15 us +- 0.08 us -> 6.20 us +- 0.09 us: 1.01x slower
- regex_compile: 144 ms +- 2 ms -> 145 ms +- 1 ms: 1.01x slower
- spectral_norm: 107 ms +- 1 ms -> 108 ms +- 2 ms: 1.01x slower
- 2to3: 271 ms +- 1 ms -> 272 ms +- 1 ms: 1.00x slower
- sympy_integrate: 22.0 ms +- 0.2 ms -> 22.1 ms +- 0.1 ms: 1.00x slower
- sympy_str: 303 ms +- 4 ms -> 304 ms +- 3 ms: 1.00x slower
- dulwich_log: 67.6 ms +- 0.3 ms -> 67.8 ms +- 0.3 ms: 1.00x slower
- python_startup_no_site: 5.90 ms +- 0.00 ms -> 5.91 ms +- 0.01 ms: 1.00x slower
- python_startup: 8.51 ms +- 0.01 ms -> 8.52 ms +- 0.01 ms: 1.00x slower

Faster (13):
- pickle_list: 4.48 us +- 0.04 us -> 4.31 us +- 0.03 us: 1.04x faster
- scimark_fft: 355 ms +- 10 ms -> 348 ms +- 3 ms: 1.02x faster
- nqueens: 90.1 ms +- 0.7 ms -> 88.3 ms +- 0.8 ms: 1.02x faster
- xml_etree_iterparse: 107 ms +- 3 ms -> 105 ms +- 2 ms: 1.02x faster
- nbody: 115 ms +- 2 ms -> 113 ms +- 3 ms: 1.02x faster
- fannkuch: 427 ms +- 4 ms -> 420 ms +- 4 ms: 1.02x faster
- unpickle_list: 5.05 us +- 0.04 us -> 4.96 us +- 0.06 us: 1.02x faster
- telco: 6.38 ms +- 0.25 ms -> 6.29 ms +- 0.13 ms: 1.01x faster
- json_dumps: 12.6 ms +- 0.1 ms -> 12.5 ms +- 0.1 ms: 1.01x faster
- pyflate: 539 ms +- 9 ms -> 533 ms +- 3 ms: 1.01x faster
- crypto_pyaes: 87.5 ms +- 0.6 ms -> 86.6 ms +- 1.2 ms: 1.01x faster
- raytrace: 331 ms +- 2 ms -> 330 ms +- 2 ms: 1.00x faster
- mako: 11.9 ms +- 0.1 ms -> 11.9 ms +- 0.1 ms: 1.00x faster

Benchmark hidden because not significant (16): deltablue, hexiom, meteor_contest, pathlib, pickle, pickle_pure_python, pidigits, scimark_sor, scimark_sparse_mat_mult, sqlalchemy_declarative, sqlite_synth, sympy_sum, tornado_http, unpickle, unpickle_pure_python, xml_etree_parse

Geometric mean: 1.00x slower
msg406147 - (view) Author: Brandt Bucher (brandtbucher) * (Python committer) Date: 2021-11-11 06:56
New changeset 9178f533ff5ea7462a2ca22cfa67afd78dad433b by Brandt Bucher in branch 'main':
bpo-45636: Merge all numeric operators (GH-29482)
https://github.com/python/cpython/commit/9178f533ff5ea7462a2ca22cfa67afd78dad433b
msg406148 - (view) Author: Brandt Bucher (brandtbucher) * (Python committer) Date: 2021-11-11 07:02
Tasks for tomorrow:
- Reimplement the string formatting fast-path as a proper specialization.
- Try indexing into an array of function pointers instead of switching.
- Experiment more generic specializations for all operators (for instance, when lhs.__class__ is rhs.__class__, or when only one valid implementation exists).
msg406355 - (view) Author: Brandt Bucher (brandtbucher) * (Python committer) Date: 2021-11-15 16:58
New changeset ec382fac0db6d9159c2d3496a70b7a605545957e by Brandt Bucher in branch 'main':
bpo-45636: Remove the old %-formatting fast-path (GH-29532)
https://github.com/python/cpython/commit/ec382fac0db6d9159c2d3496a70b7a605545957e
msg406403 - (view) Author: Brandt Bucher (brandtbucher) * (Python committer) Date: 2021-11-16 13:54
New changeset 6a84d61c55f2e543cf5fa84522d8781a795bba33 by Brandt Bucher in branch 'main':
bpo-45636: Simplify BINARY_OP (GH-29565)
https://github.com/python/cpython/commit/6a84d61c55f2e543cf5fa84522d8781a795bba33
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89799
2021-12-12 15:47:51iritkatrielsetpull_requests: + pull_request28294
2021-12-12 15:46:30iritkatrielsetpull_requests: - pull_request28293
2021-12-12 15:44:37iritkatrielsetnosy: + iritkatriel

pull_requests: + pull_request28293
2021-11-19 10:53:23Mark.Shannonsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-11-16 13:54:06brandtbuchersetmessages: + msg406403
2021-11-15 21:38:55brandtbuchersetpull_requests: + pull_request27813
2021-11-15 16:58:31brandtbuchersetmessages: + msg406355
2021-11-12 04:02:43brandtbuchersetpull_requests: + pull_request27782
2021-11-11 07:02:34brandtbuchersetmessages: + msg406148
2021-11-11 06:58:39brandtbuchersettitle: Merge BINARY_*/INPLACE_* into BINARY_OP/INPLACE_OP -> Merge BINARY_*/INPLACE_* into BINARY_OP
2021-11-11 06:56:35brandtbuchersetmessages: + msg406147
2021-11-09 01:07:23brandtbuchersetpull_requests: + pull_request27733
2021-11-05 05:06:50brandtbuchersetpull_requests: + pull_request27671
2021-10-28 18:40:14brandtbuchersetmessages: + msg405221
2021-10-28 12:14:13Mark.Shannonsetmessages: + msg405179
2021-10-27 22:15:15brandtbuchersetkeywords: + patch
stage: patch review
pull_requests: + pull_request27519
2021-10-27 22:13:52brandtbuchercreate