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

gh-141504: Move PYTHON_UOPS_OPTIMIZE to policy object by corona10 · Pull Request #144082 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (2) .h  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
1 change: 1 addition & 0 deletions Include/internal/pycore_interp_structs.h
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
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ typedef struct _PyOptimizationConfig {

// Optimization flags
bool specialization_enabled;
bool uops_optimize_enabled;
} _PyOptimizationConfig;

struct
Expand Down
6 changes: 1 addition & 5 deletions Python/optimizer.c
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
Original file line number Diff line number Diff line change
Expand Up @@ -1514,11 +1514,7 @@ uop_optimize(
_PyBloomFilter *dependencies = &_tstate->jit_tracer_state->prev_state.dependencies;
_PyUOpInstruction *buffer = _tstate->jit_tracer_state->code_buffer;
OPT_STAT_INC(attempts);
char *env_var = Py_GETENV("PYTHON_UOPS_OPTIMIZE");
bool is_noopt = true;
if (env_var == NULL || *env_var == '\0' || *env_var > '0') {
is_noopt = false;
}
bool is_noopt = !tstate->interp->opt_config.uops_optimize_enabled;
int curr_stackentries = _tstate->jit_tracer_state->initial_state.stack_depth;
int length = _tstate->jit_tracer_state->prev_state.code_curr_size;
if (length <= CODE_SIZE_NO_PROGRESS) {
Expand Down
8 changes: 8 additions & 0 deletions Python/pystate.c
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
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,13 @@ is_env_enabled(const char *env_name)
return env && *env != '\0' && *env != '0';
}

static inline bool
is_env_disabled(const char *env_name)
{
char *env = Py_GETENV(env_name);
return env != NULL && *env == '0';
}

static inline void
init_policy(uint16_t *target, const char *env_name, uint16_t default_value,
long min_value, long max_value)
Expand Down Expand Up @@ -619,6 +626,7 @@ init_interpreter(PyInterpreterState *interp,
SIDE_EXIT_INITIAL_BACKOFF, 0, MAX_BACKOFF);

interp->opt_config.specialization_enabled = !is_env_enabled("PYTHON_SPECIALIZATION_OFF");
interp->opt_config.uops_optimize_enabled = !is_env_disabled("PYTHON_UOPS_OPTIMIZE");
if (interp != &runtime->_main_interpreter) {
/* Fix the self-referential, statically initialized fields. */
interp->dtoa = (struct _dtoa_state)_dtoa_state_INIT(interp);
Expand Down
Loading

Back | FazBrowse Home | New Git URL