-
-
Notifications
You must be signed in to change notification settings - Fork 32k
GH-113710: Fix updating of dict version tag and add watched dict stats #115221
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
Conversation
@@ -133,6 +133,9 @@ typedef struct _rare_event_stats { | |||
uint64_t builtin_dict; | |||
/* Modifying a function, e.g. func.__defaults__ = ..., etc. */ | |||
uint64_t func_modification; | |||
/* Modifying a dict that is being watched */ | |||
uint64_t watched_dict_modification; | |||
uint64_t watched_globals_modification; |
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.
How do these new stats relate to the existing builtin_dict
one?
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.
They only apply to any watched dict, and watched module globals respectively.
Whereas the builtin dict count tracks any modification to the builtins, which are always watched
In theory watched_globals_modification + builtin_dict == watched_dict_modification
Although, as soon as we start watching any other dicts that will no longer be true.
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.
That makes sense, thanks.
The stats look good ~800 dict watchers fired instead of 8 million. |
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.
So I take it PyDict_EVENT_CLONED
is no longer special?
It never was, it was (and still is) misnamed. |
Fixes a regression introduced by #114592 where mutating a global variable would cause repeated de-optimizations.