gh-115168: Add pystats counter for invalidated executors (GH-115169)

This commit is contained in:
Michael Droettboom 2024-02-26 12:51:47 -05:00 committed by GitHub
parent 96c10c6485
commit b05afdd5ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 31 additions and 14 deletions

View file

@ -1348,7 +1348,7 @@ _Py_Executor_DependsOn(_PyExecutorObject *executor, void *obj)
* May cause other executors to be invalidated as well
*/
void
_Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj)
_Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj, int is_invalidation)
{
_PyBloomFilter obj_filter;
_Py_BloomFilter_Init(&obj_filter);
@ -1360,6 +1360,9 @@ _Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj)
_PyExecutorObject *next = exec->vm_data.links.next;
if (bloom_filter_may_contain(&exec->vm_data.bloom, &obj_filter)) {
_Py_ExecutorClear(exec);
if (is_invalidation) {
OPT_STAT_INC(executors_invalidated);
}
}
exec = next;
}
@ -1367,7 +1370,7 @@ _Py_Executors_InvalidateDependency(PyInterpreterState *interp, void *obj)
/* Invalidate all executors */
void
_Py_Executors_InvalidateAll(PyInterpreterState *interp)
_Py_Executors_InvalidateAll(PyInterpreterState *interp, int is_invalidation)
{
while (interp->executor_list_head) {
_PyExecutorObject *executor = interp->executor_list_head;
@ -1378,5 +1381,8 @@ _Py_Executors_InvalidateAll(PyInterpreterState *interp)
else {
_Py_ExecutorClear(executor);
}
if (is_invalidation) {
OPT_STAT_INC(executors_invalidated);
}
}
}