Skip to content

Instantly share code, notes, and snippets.

@ferd
Created August 7, 2013 13:13
Show Gist options
  • Save ferd/6173915 to your computer and use it in GitHub Desktop.
Save ferd/6173915 to your computer and use it in GitHub Desktop.
# Parse Erlang Crash Dumps and correlate mailbox size to the currently running
# function.
#
# Once in the procs section of the dump, all processes are displayed with
# =proc:<0.M.N> followed by a list of their attributes, which include the
# message queue length and the program counter (what code is currently
# executing).
BEGIN {
threshold = 10000 # mailbox size
procs = 0 # are we in the =procs entries?
print "MESSAGE QUEUE LENGTH: CURRENT FUNCTION"
print "======================================"
}
# Only bother with the =proc: entries. Anything else is useless.
procs == 0 && /^=proc/ { procs = 1 } # entering the =procs entries
procs == 1 && /^=/ && !/^=proc/ { exit 0 } # we're done
# Message queue length: 1210
# 1 2 3 4
/^Message queue length: / && $4 >= threshold { flag=1; ct=$4 }
/^Message queue length: / && $4 < threshold { flag=0 }
# Program counter: 0x00007f5fb8cb2238 (io:wait_io_mon_reply/2 + 56)
# 1 2 3 4 5 6
flag == 1 && /^Program counter: / { print ct ":", substr($4,2) }
@ferd
Copy link
Author

ferd commented Aug 7, 2013

Example run:

awk -f queue_fun.awk $PATH_TO_DUMP
MESSAGE QUEUE LENGTH: CURRENT FUNCTION
======================================
10641: io:wait_io_mon_reply/2
12646: io:wait_io_mon_reply/2
32991: io:wait_io_mon_reply/2
2183837: io:wait_io_mon_reply/2
730790: io:wait_io_mon_reply/2
80194: io:wait_io_mon_reply/2
22453: io:wait_io_mon_reply/2
24439: io:wait_io_mon_reply/2
21573: io:wait_io_mon_reply/2
12717: io:wait_io_mon_reply/2
17033: io:wait_io_mon_reply/2
12159: io:wait_io_mon_reply/2
24158: io:wait_io_mon_reply/2
33519: io:wait_io_mon_reply/2
54288: io:wait_io_mon_reply/2
34937: io:wait_io_mon_reply/2
10117: io:wait_io_mon_reply/2
47337: io:wait_io_mon_reply/2
239671: io:wait_io_mon_reply/2
838289: io:wait_io_mon_reply/2
11599: io:wait_io_mon_reply/2
16556: io:wait_io_mon_reply/2
220460: io:wait_io_mon_reply/2
532142: io:wait_io_mon_reply/2
13867: io:wait_io_mon_reply/2
10412: io:wait_io_mon_reply/2
2554519: some_server:handle_info/3
12443: io:wait_io_mon_reply/2
168785: io:wait_io_mon_reply/2
26314: io:wait_io_mon_reply/2
17999: io:wait_io_mon_reply/2
94517: io:wait_io_mon_reply/2
26487: io:wait_io_mon_reply/2
24444: io:wait_io_mon_reply/2
18194: io:wait_io_mon_reply/2
267798: io:wait_io_mon_reply/2
20067: io:wait_io_mon_reply/2
18210: io:wait_io_mon_reply/2
12423: io:wait_io_mon_reply/2
36490: io:wait_io_mon_reply/2
241485: io:wait_io_mon_reply/2
23208: io:wait_io_mon_reply/2
19096: io:wait_io_mon_reply/2
21424: io:wait_io_mon_reply/2
11101: io:wait_io_mon_reply/2
13888: io:wait_io_mon_reply/2
14061: io:wait_io_mon_reply/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment