8000 GH-118093: Handle some polymorphism before requiring progress in tier two by brandtbucher · Pull Request #122843 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-118093: Handle some polymorphism before requiring progress in tier two #122843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 12, 2024
Prev Previous commit
Next Next commit
Add an upper bound on side exit chaining before progress is required …
…again
  • Loading branch information
brandtbucher committed Aug 8, 2024
commit c88b70db1ef5406b2324e4d82d0dd61f4c21c68d
1 change: 1 addition & 0 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ typedef struct {
_PyBloomFilter bloom;
_PyExecutorLinkListNode links;
PyCodeObject *code; // Weak (NULL if no corresponding ENTER_EXECUTOR).
int depth;
} _PyVMData;

/* Depending on the format,
Expand Down
8 changes: 6 additions & 2 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2511,6 +2511,7 @@ dummy_func(
int optimized = _PyOptimizer_Optimize(frame, start, stack_pointer, &executor, true);
ERROR_IF(optimized < 0, error);
if (optimized) {
executor->vm_data.depth = 0;
assert(tstate->previous_executor == NULL);
tstate->previous_executor = Py_None;
GOTO_TIER_TWO(executor);
Expand Down Expand Up @@ -4547,7 +4548,8 @@ dummy_func(
Py_INCREF(executor);
}
else {
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, false);
int new_depth = (current_executor->vm_data.depth + 1) % 4;
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, new_depth == 0);
if (optimized <= 0) {
exit->temperature = restart_backoff_counter(temperature);
if (optimized < 0) {
Expand All @@ -4558,6 +4560,7 @@ dummy_func(
tstate->previous_executor = (PyObject *)current_executor;
GOTO_TIER_ONE(target);
}
executor->vm_data.depth = new_depth;
}
exit->executor = executor;
}
Expand Down Expand Up @@ -4630,7 +4633,7 @@ dummy_func(
exit->temperature = advance_backoff_counter(exit->temperature);
GOTO_TIER_ONE(target);
}
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, false);
int optimized = _PyOptimizer_Optimize(frame, target, stack_pointer, &executor, true);
if (optimized <= 0) {
exit->temperature = restart_backoff_counter(exit->temperature);
if (optimized < 0) {
Expand All @@ -4641,6 +4644,7 @@ dummy_func(
GOTO_TIER_ONE(target);
}
else {
executor->vm_data.depth = 0;
exit->temperature = initial_temperature_backoff_counter();
}
}
Expand Down
7 changes: 5 additions & 2 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0