Skip to content

Instantly share code, notes, and snippets.

Debugging ruby performance - Aman Gupta

C, Linux, networks, cpu, and memory usage

  • lsof -nPp <pid>
  • tcpdump
  • write the data to a file, load it up in wireshark
  • strace, trace systems calls and signals (jump into kernelspace)
  • SIGVTALRM, ruby 1.8 every 10msec to switch threads (green threads)
  • posix-spawn instead of fork-exec, check out posix-spawn gem
  • ltrace

– ltrace -c ruby foo.rb # summary mode

wget http://rubyforge.org/frs/download.php/70304/ruby-debug-base-0.10.3.2-java.gem
gem install ruby-debug-base-0.10.3.2-java.gem
gem install columnize
rm ruby-debug-base-0.10.3.2-java.gem
gem install ruby-debug --ignore-dependencies
(defn when-its-one []
(loop []
(if (= 1 (rand-int 2000))
1
[(println "foo")
(recur)])))