-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Closed
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetopic-JIT
Description
The backoff counter, _Py_BackoffCounter, supports exponential backoff and a value up to 4095.
Backoff is exponential in powers 2.
There are two issues with this:
- It is a bit slow to backoff: specialization and JIT optimizer failures are rarely transient, so we are wasting effort with backoffs like 2, 4, 8,...
- It has a relatively low limit of 4095 forcing re-specialization/trace recording every 4095 iteration at most.
The fix is simple, increase the power from 2 to 4. This means we only need 3 bits for the backoff and we get a higher maximum of 8191.
We can also use a lookup table, to ensure that the number of iteration until the next specialization/jit is a prime number
| Backoff | Value | Iterations (value + 1) |
|---|---|---|
| 0 | 1 | 2 |
| 1 | 6 | 7 |
| 6 | 8190 | 8191 |
| 7 | UNREACHABLE_BACKOFF |
Linked PRs
efimov-mikhailstonebig and Sacul0457
Metadata
Metadata
Assignees
Labels
3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)performancePerformance or resource usagePerformance or resource usagetopic-JIT