multithreading - Is there an easy way to tell how much time is spent waiting for the Python GIL? -
I have a long-running python service and I want to know how much time the cumulative wall clock is at any time Running threads were waiting for GIL (i.e. threads that were not blocked for any other reason). Is there an easy way to do this? Eg, maybe I could periodically dump some counter into its log file.
My underlying motivation is to prohibit GIL as a source of delayed delay from these long-running processes. There is no specific reason to doubt GIL (besides this it will fit in the symptoms), but no other form of logging has increased so far, therefore, if it is easy , then it will be Good for this information.
I do not think there is an easy way. Perhaps a strange way, to overcome PythhreadState's list, to rebuild Python and count every time the lock is achieved, but I suspect it's worth the effort!
I know this is a speculative question, but if you are even a little worried that delays arising due to threading are prudent to go into a multiprocessing model rather than multithreading model Could. Since the processes are both safe and more scalable in Python, they are practically almost always the best option.
Comments
Post a Comment