Title: Optimizer calls `getenv` on every optimization run · Issue #116772 · python/cpython · GitHub
Open Graph Title: Optimizer calls `getenv` on every optimization run · Issue #116772 · python/cpython
X Title: Optimizer calls `getenv` on every optimization run · Issue #116772 · python/cpython
Description: Bug report Bug description: The optimizer currently calls getenv during every optimization attempt. This has a small, but statistically significant 0.5% impact on performance. Do we need to do this each time, or could we read it to a fla...
Open Graph Description: Bug report Bug description: The optimizer currently calls getenv during every optimization attempt. This has a small, but statistically significant 0.5% impact on performance. Do we need to do this...
X Description: Bug report Bug description: The optimizer currently calls getenv during every optimization attempt. This has a small, but statistically significant 0.5% impact on performance. Do we need to do this...
Opengraph URL: https://github.com/python/cpython/issues/116772
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Optimizer calls `getenv` on every optimization run","articleBody":"# Bug report\n\n### Bug description:\n\nThe optimizer currently calls `getenv` during every optimization attempt. This has a small, but [statistically significant 0.5% impact on performance](https://github.com/faster-cpython/benchmarking-public/blob/main/results/bm-20240313-3.13.0a5%2B-cb999fb-JIT/bm-20240313-linux-x86_64-mdboom-dont_getenv-3.13.0a5%2B-cb999fb-vs-base.png). Do we need to do this each time, or could we read it to a flag during initialization?\n\n```diff\ndiff --git a/Python/optimizer.c b/Python/optimizer.c\nindex 88c45f2e73c..b55556d30ab 100644\n--- a/Python/optimizer.c\n+++ b/Python/optimizer.c\n@@ -1010,8 +1010,7 @@ uop_optimize(\n return err;\n }\n OPT_STAT_INC(traces_created);\n- char *env_var = Py_GETENV(\"PYTHON_UOPS_OPTIMIZE\");\n- if (env_var == NULL || *env_var == '\\0' || *env_var > '0') {\n+ if (true) {\n err = _Py_uop_analyze_and_optimize(frame, buffer,\n UOP_MAX_TRACE_LENGTH,\n curr_stackentries, &dependencies);\n```\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-126439\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/mdboom","@type":"Person","name":"mdboom"},"datePublished":"2024-03-14T00:43:19Z","url":"https://github.com/python/cpython/issues/116772"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:c44399d7-155f-3fed-a6dd-a628f6941626 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BAC:3A73AA:3A8E43A:4A237C3:6B02368A |
| html-safe-nonce | 220aafa0e8df0f327adfd99be16fd6771e59bc76d2bff04fdd813e18d9f85200 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkFDOjNBNzNBQTozQThFNDNBOjRBMjM3QzM6NkIwMjM2OEEiLCJ2aXNpdG9yX2lkIjoiNTcyMTM1NTg3NzAxMzkyNzU2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d4b33368b9ec10fb4e53c1d713792a2c1a869732fb21d18a760adfad7ebbc527 |
| hovercard-subject-tag | issue:2185163001 |
| 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/116772/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f90d241e195523243a044e38b7a059723f2f1cef93a80503d95f43e17bb48991/python/cpython/issues/116772 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f90d241e195523243a044e38b7a059723f2f1cef93a80503d95f43e17bb48991/python/cpython/issues/116772 |
| og:image:alt | Bug report Bug description: The optimizer currently calls getenv during every optimization attempt. This has a small, but statistically significant 0.5% impact on performance. Do we need to do this... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mdboom |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width