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

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

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

1b838da2065660793d5b26f2cdc32de7?s=128

Kazuhiko Yamashita

March 20, 2018
Tweet

Transcript

  1. 12.
  2. 15.

    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
  3. 17.

    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
  4. 18.

    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͕ࢧ഑త
  5. 22.

    NSVCZTJNQMFIUUQ while (t = socket.read(1024)) if block_given? yield t next

    end ɹ #όοϑΝ͕গͳ͍ͱϧʔϓճ਺͕૿͑ͯɺ݁߹ճ਺͕૿͑ͯແବʹϝϞϦ֬อ response_text += t end ͔͠΋ɺ($͕૸Δ·Ͱ͸։์͞Εͳ͍
  6. 25.

    NSVCZTJNQMFIUUQ while (t = socket.read(1024)) if block_given? yield t next

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