@@ -22,20 +22,20 @@ extern "C" {
2222 Another use is for the Tier 2 optimizer to decide when to create
2323 a new Tier 2 trace (executor). Again, exponential backoff is used.
2424
25- The 16-bit counter is structured as a 12 -bit unsigned 'value'
26- and a 4 -bit 'backoff' field. When resetting the counter, the
25+ The 16-bit counter is structured as a 13 -bit unsigned 'value'
26+ and a 3 -bit 'backoff' field. When resetting the counter, the
2727 backoff field is incremented (until it reaches a limit) and the
28- value is set to a bit mask representing the value 2**backoff - 1.
29- The maximum backoff is 12 (the number of bits in the value) .
28+ value is set to a bit mask representing the value 2**(2* backoff+1) - 1.
29+ The maximum backoff is 6, since 7 is an UNREACHABLE_BACKOFF .
3030
3131 There is an exceptional value which must not be updated, 0xFFFF.
3232*/
3333
34- #define BACKOFF_BITS 4
35- #define BACKOFF_MASK 0xF
36- #define MAX_BACKOFF 12
37- #define UNREACHABLE_BACKOFF 15
38- #define MAX_VALUE 0xFFF
34+ #define BACKOFF_BITS 3
35+ #define BACKOFF_MASK 7
36+ #define MAX_BACKOFF 6
37+ #define UNREACHABLE_BACKOFF 7
38+ #define MAX_VALUE 0x1FFF
3939
4040static inline bool
4141is_unreachable_backoff_counter (_Py_BackoffCounter counter )
@@ -67,10 +67,10 @@ restart_backoff_counter(_Py_BackoffCounter counter)
6767 assert (!is_unreachable_backoff_counter (counter ));
6868 int backoff = counter .value_and_backoff & BACKOFF_MASK ;
6969 if (backoff < MAX_BACKOFF ) {
70- return make_backoff_counter ((1 << (backoff + 1 )) - 1 , backoff + 1 );
70+ return make_backoff_counter ((1 << (2 * backoff + 3 )) - 1 , backoff + 1 );
7171 }
7272 else {
73- return make_backoff_counter ((1 << MAX_BACKOFF ) - 1 , MAX_BACKOFF );
73+ return make_backoff_counter ((1 << ( 2 * MAX_BACKOFF + 1 ) ) - 1 , MAX_BACKOFF );
7474 }
7575}
7676
@@ -115,7 +115,7 @@ trigger_backoff_counter(void)
115115// as we always end up tracing the loop iteration's
116116// exhaustion iteration. Which aborts our current tracer.
117117#define JUMP_BACKWARD_INITIAL_VALUE 4000
118- #define JUMP_BACKWARD_INITIAL_BACKOFF 12
118+ #define JUMP_BACKWARD_INITIAL_BACKOFF 6
119119static inline _Py_BackoffCounter
120120initial_jump_backoff_counter (void )
121121{
@@ -128,7 +128,7 @@ initial_jump_backoff_counter(void)
128128 * otherwise when a side exit warms up we may construct
129129 * a new trace before the Tier 1 code has properly re-specialized. */
130130#define SIDE_EXIT_INITIAL_VALUE 4000
131- #define SIDE_EXIT_INITIAL_BACKOFF 12
131+ #define SIDE_EXIT_INITIAL_BACKOFF 6
132132
133133static inline _Py_BackoffCounter
134134initial_temperature_backoff_counter (void )
0 commit comments