Created
September 22, 2015 23:04
-
-
Save juliantaylor/c09ead69e711ab47858e to your computer and use it in GitHub Desktop.
python gil stap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stap -g pygil.stp <pid> <minlocktime-in-mus> | |
global init = 0 | |
global gpid = $1 | |
global lock_start = 0 | |
global mintime = $2 | |
# may need to be libpython on some systems | |
probe process("/usr/bin/python-dbg").function("PyThread_acquire_lock") | |
{ | |
if (init == 0) { | |
printf("init %d %d\n", gpid, mintime) | |
lock_start = gettimeofday_us() | |
init = 1 | |
} | |
if (pid() == gpid) { | |
lock_start = gettimeofday_us() | |
} | |
} | |
probe process("/usr/bin/python-dbg").function("PyThread_release_lock") | |
{ | |
if (pid() == gpid) { | |
if (init && gettimeofday_us() - lock_start > mintime) { | |
printf("unlock %d\n", gettimeofday_us() - lock_start); | |
raise(%{ SIGSTOP %}); # attach gdb, py-list | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment