Skip to content

Instantly share code, notes, and snippets.

@benolee
Forked from jwinter/rails_conf_notes.org
Created April 22, 2017 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benolee/a59f7ac5eb0485d72ffd06e9a0324cd6 to your computer and use it in GitHub Desktop.
Save benolee/a59f7ac5eb0485d72ffd06e9a0324cd6 to your computer and use it in GitHub Desktop.

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

  • memcpy’ing a ton of data on the thread stack
  • rbtrace
  • rbtrace -p 20052 –slow=50 -m ‘include?(__source__)’
  • Google perftools

– – sampling profiler

  • perftool.rb (ruby wrapper around google perftools)

– Rack::PerftoolsProfiler (set number of workers down to 1 if using unicorn or passenger)

  • gdb.rb !

– where, – ruby eval – ruby objects strings – ruby threads

  • memprof
  • Memprof.track - takes a block (like bleak_house)
  • hotspots (new gem)

https://github.com/tmm1/hotspots

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