]]>
]]>

Poor man profiler

improved code to work with Percona Server

#!/bin/bash
nsamples=10
sleeptime=1
pid=$(pidof mysqld)

for x in $(seq 1 $nsamples)
  do
    gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
    sleep $sleeptime
  done |   sed 's/0x[^ ]* in//' | \
awk '
  BEGIN { s = ""; }
  /Thread/ { print s; s = ""; }
  /^\#/ { if (s != "" ) { s = s "," $2} else { s = $2 } }
  END { print s }' | \
sort | uniq -c | sort -r -n -k 1,1

The fix is needed, as original PMP does not handle cases like:

Thread 33 (Thread 0x590a7940 (LWP 9210)):
#0  0x000000000082330d in buf_page_get_mutex (flush_type=BUF_FLUSH_LRU, min_n=185, lsn_limit=0) at ./include/buf0buf.ic:303
#1  buf_page_get_mutex_enter (flush_type=BUF_FLUSH_LRU, min_n=185, lsn_limit=0) at ./include/buf0buf.ic:326
#2  buf_flush_batch (flush_type=BUF_FLUSH_LRU, min_n=185, lsn_limit=0) at buf/buf0flu.c:1352
#3  0x0000000000824380 in buf_flush_free_margin (wait=0) at buf/buf0flu.c:1561
#4  0x0000000000829e5b in buf_read_page (space=10, zip_size=0, offset=600782, trx=<value optimized out>) at buf/buf0rea.c:249
#5  0x00000000008209af in buf_page_get_gen (space=10, zip_size=0, offset=600782, rw_latch=1, guess=0x0, mode=10, file=0x9fa917 "row/row0sel.c", line=3177, mtr=0x590a37a0) at buf/buf0buf.c:2278
#6  0x0000000000808bc2 in btr_cur_search_to_nth_level (index=0x2ab7df155e18, level=0, tuple=0x2ab7e40b3728, mode=2, latch_mode=<value optimized out>, cursor=0x2ab7e4092ad8, has_search_latch=1, file=0x9fa917 "row/row0sel.c", line=3177, mtr=0x590a37a0) at btr/btr0cur.c:553
#7  0x00000000007cf7eb in btr_pcur_open_with_no_init_func (buf=0x2ab7e40ba800 "", mode=2, prebuilt=0x2ab7e40b34b8, match_mode=1, direction=0) at ./include/btr0pcur.ic:542
#8  row_sel_try_search_shortcut_for_mysql (buf=0x2ab7e40ba800 "", mode=2, prebuilt=0x2ab7e40b34b8, match_mode=1, direction=0) at row/row0sel.c:3174
#9  row_search_for_mysql (buf=0x2ab7e40ba800 "", mode=2, prebuilt=0x2ab7e40b34b8, match_mode=1, direction=0) at row/row0sel.c:3526
#10 0x0000000000770da5 in ha_innobase::index_read(unsigned char*, unsigned char const*, unsigned int, ha_rkey_function) ()

with printing source code lines

#!/bin/bash
nsamples=1
sleeptime=0
pid=$(pidof mysqld)

for x in $(seq 1 $nsamples)
  do
    gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
    sleep $sleeptime
  done |   sed 's/0x[^ ]* in//' | \
awk '
  BEGIN { s = ""; }
  /Thread/ { print s; s = ""; }
  /^\#/ { if (s != "" ) { s = s "###" $2} else { s = $2 } }
  /at/ { if (s != "" ) { s = s "(" $NF ")"} else { s = $NF } }
  END { print s }' | \
sort | uniq -c | sort -r -n -k 1,1 | sed "s/###/\n/g"
 
howto/pmp.txt · Last modified: 2011/07/17 21:05 (external edit)
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Contact Us 24 Hours A Day
SupportContact us 24×7
Emergency? Contact us for help now!
Sales North America(888) 316-9775 or
(208) 473-2904
Sales
Europe
+44-208-133-0309 (UK)
0-800-051-8984 (UK)
0-800-181-0665 (GER)
Training(855) 55TRAIN or
(925) 271-5054

 

Share This
]]> ]]>