FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-116772: Cache `getenv` result in `optimizer.c` to reduce calls by Wulian233 · Pull Request #126439 · python/cpython · GitHub

Repository navigation

gh-116772: Cache getenv result in optimizer.c to reduce calls - #126439

Closed
Wulian233 wants to merge 5 commits into
python:mainfrom
Wulian233:getenv
Closed

Wulian233 wants to merge 5 commits into
python:mainfrom
Wulian233:getenv

Conversation

Wulian233 commented Nov 5, 2024 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Contributor

This is my first time PR for part C, which looks like it might be a small improvement, hopefully I'm not doing anything wrong🙂

About 0.5% faster? (from issue)

Comment thread Python/optimizer.c Outdated
Comment on lines +1228 to +1229
static int uop_optimize_initialized = 0;
static int uop_optimize_flag = 0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This isn't thread safe or subinterpreter safe. You might want to store the value in a PyThreadState / PyInterpreterState in pylifecycle.c instead.

Wulian233 marked this pull request as draft November 5, 2024 12:44
Comment thread Python/optimizer.c Outdated

Copy link
Copy Markdown
Member

@mdboom did you have a change planned for this?

mdboom commented Nov 6, 2024

Copy link
Copy Markdown
Contributor

@mdboom did you have a change planned for this?

No, I don't have a plan. Thanks to @Wulian233 for taking this on.

Wulian233 marked this pull request as ready for review April 29, 2025 11:14
Comment thread Python/optimizer.c
initialize_uops_optimize_flag(void) {
if (!uops_optimize_initialized) {
PyInterpreterState *interp = _PyInterpreterState_GET();
char *env_var = Py_GETENV("PYTHON_UOPS_OPTIMIZE");

Fidget-Spinner Apr 29, 2025 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you please do this instead at where we check for PYTHON_JIT ? So in pylifecycle.c.

Set the thread state/interp state there as well.

Wulian233 closed this Dec 15, 2025
Wulian233 deleted the getenv branch December 15, 2025 12:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL