Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Linuxコマンドでボトルネックを調べる

 Linuxコマンドでボトルネックを調べる

俺の話を聞け!!LT大会 #8でトークした資料です

Kazuhiko Yamashita

March 20, 2018
Tweet

More Decks by Kazuhiko Yamashita

Other Decks in Technology

Transcript

  1. WBMHSJOEͰϝϞϦͷΞϩέʔγϣϯΛݟΔ # valgrind curl http://localhost/resource/example > /dev/null … ==18619== HEAP

    SUMMARY: ==18619== in use at exit: 0 bytes in 0 blocks ==18619== total heap usage: 1,863 allocs, 1,863 frees, 211,125 bytes allocated # valgrind /home/pyama/mruby test.rb … ==12811== HEAP SUMMARY: ==12811== in use at exit: 0 bytes in 0 blocks ==12811== total heap usage: 51,721 allocs, 51,721 frees, 12,028,345,116 bytes allocated
  2. TUSBDFͰγεςϜίʔϧͷ౷ܭΛऔΔ # strace -fc /home/pyama/mruby test.rb % time seconds usecs/call

    calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 73.00 0.006317 2 3361 munmap 23.27 0.002014 11 183 brk 2.62 0.000227 0 1734 read 1.11 0.000096 0 3380 mmap 0.00 0.000000 0 3 write 0.00 0.000000 0 16 open 0.00 0.000000 0 23 close NVONBQ͕ࢧ഑త IUUQTMJOVYKNPTEOKQIUNM-%1@NBOQBHFTNBONNBQIUNM
  3. QFSGΛར༻ͯ͠ίʔϧάϥϑΛऔಘ͢Δ IUUQNSVCZPSHEPDTBQJIFBEFSTNSVCZ@'TUSJOHIIUNMNSC@TUS@QMVTGVODUJPO # perf record --call-graph dwarf -- /home/pyama/mruby test.rb

    # perf report -g -G —stdio 94.35% 0.03% mruby mruby [.] mrb_str_plus | ---mrb_str_plus | --20.06%-- mrb_vm_exec mrb_vm_run … NSC@TUS@QMVT͕ࢧ഑త
  4. NSVCZTJNQMFIUUQ while (t = socket.read(1024)) if block_given? yield t next

    end ɹ #όοϑΝ͕গͳ͍ͱϧʔϓճ਺͕૿͑ͯɺ݁߹ճ਺͕૿͑ͯແବʹϝϞϦ֬อ response_text += t end ͔͠΋ɺ($͕૸Δ·Ͱ͸։์͞Εͳ͍
  5. NSVCZTJNQMFIUUQ while (t = socket.read(1024)) if block_given? yield t next

    end response_text << t end ͞ΒʹDPODBUʹ͢Δ͜ͱͰɺແବͳྖҬ֬อΛ΍ΊΔ