-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-116968: Reimplement Tier 2 counters #117144
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
Changes from 1 commit
e7e819b
8c74dfa
79036ff
54c1f8e
015bb00
1730295
95f93b7
7df0f10
925cae7
f0c7fb0
8f79a60
149e9c4
1d76112
a5ffe02
ce7726c
e2c39f2
8d22790
cd8264e
d72c2ef
f6bf194
b991843
9b9f26a
354cd81
c1de44f
1fe27c9
225ea17
63d8bc7
8aa2c75
7bd4daa
3f1c58a
8ce8068
7bb5618
63e286c
7f64392
8eee1b4
42c1f26
a80cd0a
545c60e
6c0bb30
a7c9b6d
3fee35f
df6f34c
72f6b0d
dcee362
f38d922
ef6366b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
This changes a lot of things but the end result is arguably better.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ extern "C" { | |
#define CACHE_ENTRIES(cache) (sizeof(cache)/sizeof(_Py_CODEUNIT)) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
uint16_t module_keys_version; | ||
uint16_t builtin_keys_version; | ||
uint16_t index; | ||
|
@@ -40,44 +40,44 @@ typedef struct { | |
#define INLINE_CACHE_ENTRIES_LOAD_GLOBAL CACHE_ENTRIES(_PyLoadGlobalCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PyBinaryOpCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_BINARY_OP CACHE_ENTRIES(_PyBinaryOpCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PyUnpackSequenceCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_UNPACK_SEQUENCE \ | ||
CACHE_ENTRIES(_PyUnpackSequenceCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PyCompareOpCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_COMPARE_OP CACHE_ENTRIES(_PyCompareOpCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PyBinarySubscrCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_BINARY_SUBSCR CACHE_ENTRIES(_PyBinarySubscrCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PySuperAttrCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR CACHE_ENTRIES(_PySuperAttrCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
uint16_t version[2]; | ||
uint16_t index; | ||
} _PyAttrCache; | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
uint16_t type_version[2]; | ||
union { | ||
uint16_t keys_version[2]; | ||
|
@@ -93,39 +93,39 @@ typedef struct { | |
#define INLINE_CACHE_ENTRIES_STORE_ATTR CACHE_ENTRIES(_PyAttrCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
uint16_t func_version[2]; | ||
} _PyCallCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_CALL CACHE_ENTRIES(_PyCallCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PyStoreSubscrCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_STORE_SUBSCR CACHE_ENTRIES(_PyStoreSubscrCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PyForIterCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_FOR_ITER CACHE_ENTRIES(_PyForIterCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PySendCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_SEND CACHE_ENTRIES(_PySendCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
uint16_t version[2]; | ||
} _PyToBoolCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_TO_BOOL CACHE_ENTRIES(_PyToBoolCache) | ||
|
||
typedef struct { | ||
uint16_t counter; | ||
_Py_BackoffCounter counter; | ||
} _PyContainsOpCache; | ||
|
||
#define INLINE_CACHE_ENTRIES_CONTAINS_OP CACHE_ENTRIES(_PyContainsOpCache) | ||
|
@@ -476,26 +476,26 @@ write_location_entry_start(uint8_t *ptr, int code, int length) | |
#define ADAPTIVE_COOLDOWN_VALUE 52 | ||
#define ADAPTIVE_COOLDOWN_BACKOFF 0 | ||
|
||
static inline uint16_t | ||
static inline _Py_BackoffCounter | ||
adaptive_counter_bits(uint16_t value, uint16_t backoff) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe drop the To do that cleanly we will probably need to change typedef union {
uint16_t cache;
struct {
uint8_t code;
uint8_t arg;
} op;
backoff_counter_t counter;
} _Py_CODEUNIT; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to keep them and not expose the backoff counter structure to other places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could dispense with |
||
return make_backoff_counter(value, backoff).counter; | ||
return make_backoff_counter(value, backoff); | ||
} | ||
|
||
static inline uint16_t | ||
static inline _Py_BackoffCounter | ||
adaptive_counter_warmup(void) { | ||
return adaptive_counter_bits(ADAPTIVE_WARMUP_VALUE, | ||
ADAPTIVE_WARMUP_BACKOFF); | ||
} | ||
|
||
static inline uint16_t | ||
static inline _Py_BackoffCounter | ||
adaptive_counter_cooldown(void) { | ||
return adaptive_counter_bits(ADAPTIVE_COOLDOWN_VALUE, | ||
ADAPTIVE_COOLDOWN_BACKOFF); | ||
} | ||
|
||
static inline uint16_t | ||
adaptive_counter_backoff(uint16_t counter) { | ||
return restart_backoff_counter(forge_backoff_counter(counter)).counter; | ||
static inline _Py_BackoffCounter | ||
adaptive_counter_backoff(_Py_BackoffCounter counter) { | ||
return restart_backoff_counter(counter); | ||
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temperature
is now a bit of a misnomer, since it counts down. Maybe it should be renamed tocounter
(same as inCODEUNIT
)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll keep
temperature
, despite the misnomer -- it stands out and makes it easy to grep for this particular concept.