mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
gh-116968: Reimplement Tier 2 counters (#117144)
Introduce a unified 16-bit backoff counter type (``_Py_BackoffCounter``), shared between the Tier 1 adaptive specializer and the Tier 2 optimizer. The API used for adaptive specialization counters is changed but the behavior is (supposed to be) identical. The behavior of the Tier 2 counters is changed: - There are no longer dynamic thresholds (we never varied these). - All counters now use the same exponential backoff. - The counter for ``JUMP_BACKWARD`` starts counting down from 16. - The ``temperature`` in side exits starts counting down from 64.
This commit is contained in:
parent
63bbe77d9b
commit
060a96f1a9
19 changed files with 313 additions and 235 deletions
|
@ -419,22 +419,20 @@ _PyCode_Quicken(PyCodeObject *code)
|
|||
int caches = _PyOpcode_Caches[opcode];
|
||||
if (caches) {
|
||||
// The initial value depends on the opcode
|
||||
int initial_value;
|
||||
switch (opcode) {
|
||||
case JUMP_BACKWARD:
|
||||
initial_value = 0;
|
||||
instructions[i + 1].counter = initial_jump_backoff_counter();
|
||||
break;
|
||||
case POP_JUMP_IF_FALSE:
|
||||
case POP_JUMP_IF_TRUE:
|
||||
case POP_JUMP_IF_NONE:
|
||||
case POP_JUMP_IF_NOT_NONE:
|
||||
initial_value = 0x5555; // Alternating 0, 1 bits
|
||||
instructions[i + 1].cache = 0x5555; // Alternating 0, 1 bits
|
||||
break;
|
||||
default:
|
||||
initial_value = adaptive_counter_warmup();
|
||||
instructions[i + 1].counter = adaptive_counter_warmup();
|
||||
break;
|
||||
}
|
||||
instructions[i + 1].cache = initial_value;
|
||||
i += caches;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue