Title: Conditional backward edges should help "warm up" code · Issue #93554 · python/cpython · GitHub
Open Graph Title: Conditional backward edges should help "warm up" code · Issue #93554 · python/cpython
X Title: Conditional backward edges should help "warm up" code · Issue #93554 · python/cpython
Description: #93229 introduced a regression in how aggressively we quicken some for loops. Minimal example: def f(x: bool) -> None: for i in range(1_000_000): if x: pass f(True) will quicken this code, but f(False) will not, even though both contain ...
Open Graph Description: #93229 introduced a regression in how aggressively we quicken some for loops. Minimal example: def f(x: bool) -> None: for i in range(1_000_000): if x: pass f(True) will quicken this code, but f(Fa...
X Description: #93229 introduced a regression in how aggressively we quicken some for loops. Minimal example: def f(x: bool) -> None: for i in range(1_000_000): if x: pass f(True) will quicken this code, but f...
Opengraph URL: https://github.com/python/cpython/issues/93554
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Conditional backward edges should help \"warm up\" code","articleBody":"#93229 introduced a regression in how aggressively we quicken some `for` loops. Minimal example:\r\n\r\n```py\r\ndef f(x: bool) -\u003e None:\r\n for i in range(1_000_000):\r\n if x:\r\n pass\r\n```\r\n\r\n`f(True)` will quicken this code, but `f(False)` will not, even though both contain the same number of back edges. The issue is that we only quicken on *unconditional* backwards jumps, not on conditional ones.\r\n\r\nWe've known about this limitation for some time, in particular with regard to `while` loops. Since we check the loop condition at the bottom of `while` loops, one call is not enough to quicken `w`:\r\n\r\n```py\r\ndef w() -\u003e None:\r\n i = 0\r\n while i \u003c 1_000_000:\r\n i += 1\r\n```\r\n\r\n@markshannon has expressed a preference for having all branches be forward (i.e. replacing backward `POP_JUMP_IF_FALSE(x)` instructions with `POP_JUMP_FORWARD_IF_TRUE(1); JUMP_BACKWARD(x)` in the assembler). @iritkatriel believes that this shouldn't be too difficult, based on recent assembler rewrites.\r\n\r\nCC @sweeneyde \n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-119485\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/brandtbucher","@type":"Person","name":"brandtbucher"},"datePublished":"2022-06-06T22:49:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":11},"url":"https://github.com/93554/cpython/issues/93554"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:962ec34a-e029-b1dd-ffa7-607dd1662d12 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C10E:71616:9A404:DAFAE:696A6A50 |
| html-safe-nonce | 7edcd61475fa907fff98ce5e8cfe3c56e3183937539d1e354402cb2f8eafb1b8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTBFOjcxNjE2OjlBNDA0OkRBRkFFOjY5NkE2QTUwIiwidmlzaXRvcl9pZCI6IjY5MzEwMjU0MjI5NzE0NjQyNzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 34cae1c7499e6a4ab3d045e73b7a10159abbe2a299e63765f082f6d32ccf3d5c |
| hovercard-subject-tag | issue:1262514862 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/93554/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e410ad32426178fac2e6322f81195938ef9f436957aebe5daea52817167f0d9b/python/cpython/issues/93554 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e410ad32426178fac2e6322f81195938ef9f436957aebe5daea52817167f0d9b/python/cpython/issues/93554 |
| og:image:alt | #93229 introduced a regression in how aggressively we quicken some for loops. Minimal example: def f(x: bool) -> None: for i in range(1_000_000): if x: pass f(True) will quicken this code, but f(Fa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | brandtbucher |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6fea32d5b7276b841b7a803796d9715bc6cfb31ed549fdf9de2948ac25d12ba6 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f2d9f6432a5a115ec709295ae70623f33bb80aee |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width