Coder Social home page Coder Social logo

perftools.rb's Introduction

perftools.rb

gperftools for ruby code
(c) 2012 Aman Gupta (tmm1)
http://www.ruby-lang.org/en/LICENSE.txt

gperftools (formerly known as google-perftools): http://gperftools.googlecode.com

Usage (in a webapp)

Use rack-perftools_profiler:

require 'rack/perftools_profiler'
config.middleware.use ::Rack::PerftoolsProfiler, :default_printer => 'gif'

Simply add profile=true to profile a request:

curl -o 10_requests_to_homepage.gif "http://localhost:3000/homepage?profile=true&times=10"

Usage (from Ruby)

Run the profiler with a block:

require 'perftools'
PerfTools::CpuProfiler.start("/tmp/add_numbers_profile") do
  5_000_000.times{ 1+2+3+4+5 }
end

Start and stop the profiler manually:

require 'perftools'
PerfTools::CpuProfiler.start("/tmp/add_numbers_profile")
5_000_000.times{ 1+2+3+4+5 }
PerfTools::CpuProfiler.stop

Usage (externally)

Profile an existing ruby application without modifying it:

$ CPUPROFILE=/tmp/my_app_profile \
  RUBYOPT="-r`gem which perftools | tail -1`" \
  ruby my_app.rb

Profiler Modes

The profiler can be run in one of many modes, set via an environment variable before the library is loaded:

  • CPUPROFILE_REALTIME=1

    Use walltime instead of cputime profiling. This will capture all time spent in a method, even if it does not involve the CPU.

    For example, sleep() is not expensive in terms of cputime, but very expensive in walltime. walltime will also show functions spending a lot of time in network i/o.

  • CPUPROFILE_OBJECTS=1

    Profile object allocations instead of cpu/wall time. Each sample represents one object created inside that function.

  • CPUPROFILE_METHODS=1

    Profile method calls. Each sample represents one method call made inside that function.

The sampling interval of the profiler can be adjusted to collect more (for better profile detail) or fewer samples (for lower overhead):

  • CPUPROFILE_FREQUENCY=500

    Default sampling interval is 100 times a second. Valid range is 1-4000

Reporting

pprof.rb --text /tmp/add_numbers_profile

pprof.rb --pdf /tmp/add_numbers_profile > /tmp/add_numbers_profile.pdf

pprof.rb --gif /tmp/add_numbers_profile > /tmp/add_numbers_profile.gif

pprof.rb --callgrind /tmp/add_numbers_profile > /tmp/add_numbers_profile.grind
kcachegrind /tmp/add_numbers_profile.grind

pprof.rb --gif --focus=Integer /tmp/add_numbers_profile > /tmp/add_numbers_custom.gif

pprof.rb --text --ignore=Gem /tmp/my_app_profile

For more options, see pprof documentation

Examples

pprof.rb --text

Total: 1735 samples
    1487  85.7%  85.7%     1735 100.0% Integer#times
     248  14.3% 100.0%      248  14.3% Fixnum#+

pprof.rb --gif

Installation

Just install the gem, which will download, patch and compile gperftools for you:

sudo gem install perftools.rb

Or build your own gem:

git clone git://github.com/tmm1/perftools.rb
cd perftools.rb
gem build perftools.rb.gemspec
gem install perftools.rb

Use via a Gemfile:

gem 'perftools.rb', :git => 'git://github.com/tmm1/perftools.rb.git'

You'll also need graphviz to generate call graphs using dot:

brew    install graphviz ghostscript # osx
sudo apt-get install graphviz ps2pdf      # debian/ubuntu

If graphviz fails to build on OSX Lion, you may need to recompile libgd, see here

Advantages over ruby-prof

  • Sampling profiler

    • perftools samples your process using setitimer() so it can be used in production with minimal overhead.

Profiling the Ruby VM and C extensions

To profile C code, download and build an unpatched perftools (libunwind or ./configure --enable-frame-pointers required on x86_64).

Download:

wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.8/gperftools-2.8.tar.gz
tar zxvf gperftools-*.tar.gz
cd gperftools-*

Compile:

./configure --prefix=/opt
make
sudo make install

Profile:

export LD_PRELOAD=/opt/lib/libprofiler.so                 # for linux
export DYLD_INSERT_LIBRARIES=/opt/lib/libprofiler.dylib   # for osx
CPUPROFILE=/tmp/ruby_interpreter.profile ruby -e' 5_000_000.times{ "hello world" } '

Report:

pprof `which ruby` --text /tmp/ruby_interpreter.profile

TODO

  • Add support for heap profiling to find memory leaks (PerfTools::HeapProfiler)
  • Allow both C and Ruby profiling
  • Add setter for the sampling interval

Resources

perftools.rb's People

Contributors

bearded avatar benweint avatar betelgeuse avatar buonomo avatar conradirwin avatar emerose avatar evie404 avatar gstark avatar hnovikov avatar leahneukirchen avatar sdsykes avatar tmaher avatar tmm1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

perftools.rb's Issues

CPUPROFILE_OBJECTS causes segfault

I'm trying to profile a bunch of specs in two projects (to figure out why very similar spec suites take 3 minutes in one project and 30 in the other). setting CPUPROFILE_OBJECTS=1 is causing a segfault with each attempt. Segfault occurs after the spec run completes; I see normal spec output first.

System: OS X 10.7.5 Lion
Ruby:
1.9.3-p385
1.9.3-p327-fast (patched GC)

The stack trace / segfault info is nearly 3000 lines, and the crash report in ~/Library/Logs/CrashReporter is 220. Do you want any particular part of it? Possibly relevant snippets are below.

Here's the top of the crash log:

Exception Type:  EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00007fc1089c2a68

VM Regions Near 0x7fc1089c2a68:
MALLOC_TINY            00007fc107400000-00007fc107700000 [ 3072K] rw-/rwx SM=COW  
--> MALLOC_SMALL           00007fc107800000-00007fc10a000000 [ 40.0M] rw-/rwx SM=PRV  
MALLOC_TINY            00007fc10a000000-00007fc10a800000 [ 8192K] rw-/rwx SM=PRV  

And the top of the control frame from the segfault:

c:0074 p:---- s:0272 b:0272 l:000267 d:000271 IFUNC
c:0073 p:---- s:0270 b:0270 l:000269 d:000269 CFUNC  :each
c:0072 p:---- s:0268 b:0268 l:000267 d:000267 CFUNC  :group_by
c:0071 p:0014 s:0265 b:0265 l:000264 d:000264 METHOD /Volumes/Valinor/Users/evan/.rvm/gems/ruby-1.9.3-p385/gems/backports-2.6.7/lib/backports/tools.rb:29

Fails to install on 1.9.2-head

Installed 1.9.2-head with rvm. Using ubuntu 10.04. Works fine with 1.9.2-p180.

/home/monkey/.rvm/rubies/ruby-1.9.2-head/bin/ruby extconf.rb
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zxvf google-perftools-1.6.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
  -- make
checking for method.h... no
checking for vm_core.h... no
checking for method.h... no
checking for vm_core.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/monkey/.rvm/rubies/ruby-1.9.2-head/bin/ruby
/home/monkey/.rvm/gems/ruby-1.9.2-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:268:in `block (2 levels) in read': Looking for http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p204.tar.gz and all I got was a 404! (URI::NotFoundError)
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1194:in `block in transport_request'
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:2342:in `reading_body'
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1193:in `transport_request'
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1177:in `request'
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1170:in `block in request'
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:627:in `start'
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/net/http.rb:1168:in `request'
    from /home/monkey/.rvm/gems/ruby-1.9.2-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:239:in `block in read'
    from /home/monkey/.rvm/gems/ruby-1.9.2-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:286:in `connect'
    from /home/monkey/.rvm/gems/ruby-1.9.2-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:234:in `read'
    from /home/monkey/.rvm/gems/ruby-1.9.2-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:128:in `download'
    from /home/monkey/.rvm/gems/ruby-1.9.2-head/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:55:in `block in create_makefile_with_core'
    from /home/monkey/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/tempfile.rb:320:in `open'
    from /home/monkey/.rvm/gems/ruby-1.9.2-head/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:51:in `create_makefile_with_core'
    from extconf.rb:103:in `<main>'
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.2-p204.tar.gz

perftools-2.0.0 fails to build on Linux debian 2.6.32-5-amd64 VM on Vagrant.

I'm running a bundled project (bundler 1.8.25) which is using perftools.rb v2.0.0. I'm running it on a debian VM (2.6.32-5-amd64) within Vagrant

When I run bundle, it fails when installing perftools.rb (2.0.0)

gem_make.out contains:

    /home/vagrant/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zpxvf gperftools-2.0.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- patch -p1 < ../../../patches/perftools-realtime.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
  -- make
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/home/vagrant/.rvm/rubies/ruby-1.9.2-p320/bin/ruby
extconf.rb:6:in `sys': make failed, please report to https://github.com/tmm1/perfools.rb/issues/new with /silo/bundle/ruby/1.9.1/gems/perftools.rb-2.0.0/ext/src/mkmf.log and /silo/bundle/ruby/1.9.1/gems/perftools.rb-2.0.0/ext/src/gperftools-2.0/config.log (RuntimeError)
        from extconf.rb:77:in `block (2 levels) in <main>'
        from extconf.rb:72:in `chdir'
        from extconf.rb:72:in `block in <main>'
        from extconf.rb:36:in `chdir'
        from extconf.rb:36:in `<main>'

I've attached the mkmf.log and the config.log. It looks like HAVE_MMAP is not set, but it is unclear to me how to go about fixing that.

The mkmf.log: https://gist.github.com/davidann/5919666
The config.log: https://gist.github.com/davidann/5919641

Cannot gem install perftools.rb on Fedora 15

I am getting the following errors when installing perftools.rb on fedora 15, could you please assist?

[chase@ChaseFedora ~]$ gem install perftools.rb
Fetching: perftools.rb-0.5.6.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing perftools.rb:
    ERROR: Failed to build gem native extension.

        /home/chase/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
NOTE: Gem.activate is deprecated, use Specification#activate. It will be removed on or after 2011-10-01.
Gem.activate called from extconf.rb:24.
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zxvf google-perftools-1.6.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
  -- make
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/chase/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
extconf.rb:6:in `sys': make failed, please report to [email protected] with pastie.org link to /home/chase/.rvm/gems/ruby-1.9.2-p290/gems/perftools.rb-0.5.6/ext/mkmf.log and /home/chase/.rvm/gems/ruby-1.9.2-p290/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/config.log (RuntimeError)
    from extconf.rb:76:in `block (2 levels) in <main>'
    from extconf.rb:71:in `chdir'
    from extconf.rb:71:in `block in <main>'
    from extconf.rb:36:in `chdir'
    from extconf.rb:36:in `<main>'


Gem files will remain installed in /home/chase/.rvm/gems/ruby-1.9.2-p290/gems/perftools.rb-0.5.6 for inspection.
Results logged to /home/chase/.rvm/gems/ruby-1.9.2-p290/gems/perftools.rb-0.5.6/ext/gem_make.out

Fail building gem windows7

D:/tools/ruby192/bin/ruby.exe extconf.rb 
NOTE: Gem.activate is deprecated, use Specification#activate. It will be removed on or after 2011-10-01.
Gem.activate called from extconf.rb:24.
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zpxvf gperftools-2.0.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- patch -p1 < ../../../patches/perftools-realtime.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=D:/tools/ruby192/bin/ruby
extconf.rb:6:in `sys': ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared failed, please report to https://github.com/tmm1/perfools.rb/issues/new with D:/tools/ruby192/lib/ruby/gems/1.9.1/bundler/gems/perftools.rb-961890a077bd/ext/src/mkmf.log and D:/tools/ruby192/lib/ruby/gems/1.9.1/bundler/gems/perftools.rb-961890a077bd/ext/src/gperftools-2.0/config.log (RuntimeError)
    from extconf.rb:76:in `block (2 levels) in <main>'
    from extconf.rb:72:in `chdir'
    from extconf.rb:72:in `block in <main>'
    from extconf.rb:36:in `chdir'
    from extconf.rb:36:in `<main>'
"tar zpxvf gperftools-2.0.tar.gz"
gperftools-2.0/
gperftools-2.0/doc/
gperftools-2.0/doc/index.html
gperftools-2.0/doc/designstyle.css
gperftools-2.0/doc/pprof_remote_servers.html
gperftools-2.0/doc/tcmalloc.html
gperftools-2.0/doc/overview.gif
gperftools-2.0/doc/pageheap.gif
gperftools-2.0/doc/spanmap.gif
gperftools-2.0/doc/threadheap.gif
gperftools-2.0/doc/t-test1.times.txt
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.1024.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.128.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.131072.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.16384.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.2048.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.256.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.32768.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.4096.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.512.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.64.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.65536.bytes.png
gperftools-2.0/doc/tcmalloc-opspercpusec.vs.threads.8192.bytes.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.1.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.12.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.16.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.2.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.20.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.3.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.4.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.5.threads.png
gperftools-2.0/doc/tcmalloc-opspersec.vs.size.8.threads.png
gperftools-2.0/doc/overview.dot
gperftools-2.0/doc/pageheap.dot
gperftools-2.0/doc/spanmap.dot
gperftools-2.0/doc/threadheap.dot
gperftools-2.0/doc/heapprofile.html
gperftools-2.0/doc/heap-example1.png
gperftools-2.0/doc/heap_checker.html
gperftools-2.0/doc/cpuprofile.html
gperftools-2.0/doc/cpuprofile-fileformat.html
gperftools-2.0/doc/pprof-test-big.gif
gperftools-2.0/doc/pprof-test.gif
gperftools-2.0/doc/pprof-vsnprintf-big.gif
gperftools-2.0/doc/pprof-vsnprintf.gif
gperftools-2.0/doc/pprof.1
gperftools-2.0/m4/
gperftools-2.0/m4/ac_have_attribute.m4
gperftools-2.0/m4/acx_nanosleep.m4
gperftools-2.0/m4/acx_pthread.m4
gperftools-2.0/m4/compiler_characteristics.m4
gperftools-2.0/m4/install_prefix.m4
gperftools-2.0/m4/libtool.m4
gperftools-2.0/m4/ltoptions.m4
gperftools-2.0/m4/ltsugar.m4
gperftools-2.0/m4/ltversion.m4
gperftools-2.0/m4/lt~obsolete.m4
gperftools-2.0/m4/namespaces.m4
gperftools-2.0/m4/pc_from_ucontext.m4
gperftools-2.0/m4/program_invocation_name.m4
gperftools-2.0/m4/stl_namespace.m4
gperftools-2.0/packages/
gperftools-2.0/packages/rpm/
gperftools-2.0/packages/rpm/rpm.spec
gperftools-2.0/packages/rpm.sh
gperftools-2.0/packages/deb.sh
gperftools-2.0/packages/deb/
gperftools-2.0/packages/deb/README
gperftools-2.0/packages/deb/compat
gperftools-2.0/packages/deb/control
gperftools-2.0/packages/deb/copyright
gperftools-2.0/packages/deb/docs
gperftools-2.0/packages/deb/rules
gperftools-2.0/packages/deb/changelog
gperftools-2.0/packages/deb/libgperftools-dev.dirs
gperftools-2.0/packages/deb/libgperftools-dev.install
gperftools-2.0/packages/deb/libgperftools0.dirs
gperftools-2.0/packages/deb/libgperftools0.install
gperftools-2.0/packages/deb/libgperftools0.manpages
gperftools-2.0/src/
gperftools-2.0/src/base/
gperftools-2.0/src/base/logging.cc
gperftools-2.0/src/base/dynamic_annotations.c
gperftools-2.0/src/base/logging.h
gperftools-2.0/src/base/commandlineflags.h
gperftools-2.0/src/base/basictypes.h
gperftools-2.0/src/base/dynamic_annotations.h
gperftools-2.0/src/base/googleinit.h
gperftools-2.0/src/base/simple_mutex.h
gperftools-2.0/src/base/sysinfo.h
gperftools-2.0/src/base/spinlock.h
gperftools-2.0/src/base/spinlock_internal.h
gperftools-2.0/src/base/atomicops.h
gperftools-2.0/src/base/atomicops-internals-macosx.h
gperftools-2.0/src/base/atomicops-internals-linuxppc.h
gperftools-2.0/src/base/atomicops-internals-windows.h
gperftools-2.0/src/base/atomicops-internals-x86.h
gperftools-2.0/src/base/spinlock_win32-inl.h
gperftools-2.0/src/base/spinlock_linux-inl.h
gperftools-2.0/src/base/spinlock_posix-inl.h
gperftools-2.0/src/base/synchronization_profiling.h
gperftools-2.0/src/base/atomicops-internals-arm-generic.h
gperftools-2.0/src/base/atomicops-internals-arm-v6plus.h
gperftools-2.0/src/base/spinlock.cc
gperftools-2.0/src/base/spinlock_internal.cc
gperftools-2.0/src/base/atomicops-internals-x86.cc
gperftools-2.0/src/base/elf_mem_image.cc
gperftools-2.0/src/base/vdso_support.cc
gperftools-2.0/src/base/elf_mem_image.h
gperftools-2.0/src/base/vdso_support.h
gperftools-2.0/src/base/sysinfo.cc
gperftools-2.0/src/base/cycleclock.h
gperftools-2.0/src/base/arm_instruction_set_select.h
gperftools-2.0/src/base/thread_annotations.h
gperftools-2.0/src/base/elfcore.h
gperftools-2.0/src/base/linux_syscall_support.h
gperftools-2.0/src/base/linuxthreads.h
gperftools-2.0/src/base/stl_allocator.h
gperftools-2.0/src/base/thread_lister.h
gperftools-2.0/src/base/thread_lister.c
gperftools-2.0/src/base/linuxthreads.cc
gperftools-2.0/src/base/low_level_alloc.cc
gperftools-2.0/src/base/low_level_alloc.h
gperftools-2.0/src/google/
gperftools-2.0/src/google/heap-checker.h
gperftools-2.0/src/google/heap-profiler.h
gperftools-2.0/src/google/malloc_extension.h
gperftools-2.0/src/google/malloc_extension_c.h
gperftools-2.0/src/google/malloc_hook.h
gperftools-2.0/src/google/malloc_hook_c.h
gperftools-2.0/src/google/profiler.h
gperftools-2.0/src/google/stacktrace.h
gperftools-2.0/src/google/tcmalloc.h
gperftools-2.0/src/gperftools/
gperftools-2.0/src/gperftools/stacktrace.h
gperftools-2.0/src/gperftools/malloc_hook.h
gperftools-2.0/src/gperftools/malloc_hook_c.h
gperftools-2.0/src/gperftools/malloc_extension.h
gperftools-2.0/src/gperftools/malloc_extension_c.h
gperftools-2.0/src/gperftools/heap-profiler.h
gperftools-2.0/src/gperftools/heap-checker.h
gperftools-2.0/src/gperftools/profiler.h
gperftools-2.0/src/gperftools/tcmalloc.h.in
gperftools-2.0/src/solaris/
gperftools-2.0/src/solaris/libstdc++.la
gperftools-2.0/src/tests/
gperftools-2.0/src/tests/addressmap_unittest.cc
gperftools-2.0/src/tests/atomicops_unittest.cc
gperftools-2.0/src/tests/current_allocated_bytes_test.cc
gperftools-2.0/src/tests/debugallocation_test.cc
gperftools-2.0/src/tests/debugallocation_test.sh
gperftools-2.0/src/tests/frag_unittest.cc
gperftools-2.0/src/tests/getpc_test.cc
gperftools-2.0/src/tests/heap-checker-death_unittest.sh
gperftools-2.0/src/tests/heap-checker_unittest.cc
gperftools-2.0/src/tests/heap-checker_unittest.sh
gperftools-2.0/src/tests/heap-profiler_unittest.cc
gperftools-2.0/src/tests/heap-profiler_unittest.sh
gperftools-2.0/src/tests/low_level_alloc_unittest.cc
gperftools-2.0/src/tests/malloc_extension_c_test.c
gperftools-2.0/src/tests/malloc_extension_test.cc
gperftools-2.0/src/tests/malloc_hook_test.cc
gperftools-2.0/src/tests/testutil.h
gperftools-2.0/src/tests/testutil.cc
gperftools-2.0/src/tests/markidle_unittest.cc
gperftools-2.0/src/tests/maybe_threads_unittest.sh
gperftools-2.0/src/tests/memalign_unittest.cc
gperftools-2.0/src/tests/packed-cache_test.cc
gperftools-2.0/src/tests/page_heap_test.cc
gperftools-2.0/src/tests/pagemap_unittest.cc
gperftools-2.0/src/tests/profile-handler_unittest.cc
gperftools-2.0/src/tests/profiledata_unittest.cc
gperftools-2.0/src/tests/profiler_unittest.cc
gperftools-2.0/src/tests/profiler_unittest.sh
gperftools-2.0/src/tests/raw_printer_test.cc
gperftools-2.0/src/tests/realloc_unittest.cc
gperftools-2.0/src/tests/sampler_test.cc
gperftools-2.0/src/tests/sampling_test.cc
gperftools-2.0/src/tests/sampling_test.sh
gperftools-2.0/src/tests/simple_compat_test.cc
gperftools-2.0/src/tests/stack_trace_table_test.cc
gperftools-2.0/src/tests/stacktrace_unittest.cc
gperftools-2.0/src/tests/system-alloc_unittest.cc
gperftools-2.0/src/tests/tcmalloc_unittest.cc
gperftools-2.0/src/tests/tcmalloc_large_unittest.cc
gperftools-2.0/src/tests/thread_dealloc_unittest.cc
gperftools-2.0/src/third_party/
gperftools-2.0/src/third_party/valgrind.h
gperftools-2.0/src/windows/
gperftools-2.0/src/windows/google/
gperftools-2.0/src/windows/google/tcmalloc.h
gperftools-2.0/src/windows/gperftools/
gperftools-2.0/src/windows/gperftools/tcmalloc.h.in
gperftools-2.0/src/windows/gperftools/tcmalloc.h
gperftools-2.0/src/windows/port.h
gperftools-2.0/src/windows/mingw.h
gperftools-2.0/src/windows/mini_disassembler.h
gperftools-2.0/src/windows/mini_disassembler_types.h
gperftools-2.0/src/windows/preamble_patcher.h
gperftools-2.0/src/windows/port.cc
gperftools-2.0/src/windows/ia32_modrm_map.cc
gperftools-2.0/src/windows/ia32_opcode_map.cc
gperftools-2.0/src/windows/mini_disassembler.cc
gperftools-2.0/src/windows/patch_functions.cc
gperftools-2.0/src/windows/preamble_patcher.cc
gperftools-2.0/src/windows/preamble_patcher_with_stub.cc
gperftools-2.0/src/windows/get_mangled_names.cc
gperftools-2.0/src/windows/override_functions.cc
gperftools-2.0/src/windows/config.h
gperftools-2.0/src/windows/preamble_patcher_test.cc
gperftools-2.0/src/windows/shortproc.asm
gperftools-2.0/src/windows/auto_testing_hook.h
gperftools-2.0/src/windows/nm-pdb.c
gperftools-2.0/src/windows/addr2line-pdb.c
gperftools-2.0/src/config.h.in
gperftools-2.0/src/profiler.cc
gperftools-2.0/src/profile-handler.cc
gperftools-2.0/src/profiledata.cc
gperftools-2.0/src/profiledata.h
gperftools-2.0/src/profile-handler.h
gperftools-2.0/src/getpc.h
gperftools-2.0/src/stacktrace.cc
gperftools-2.0/src/stacktrace_config.h
gperftools-2.0/src/stacktrace_generic-inl.h
gperftools-2.0/src/stacktrace_libunwind-inl.h
gperftools-2.0/src/stacktrace_arm-inl.h
gperftools-2.0/src/stacktrace_powerpc-inl.h
gperftools-2.0/src/stacktrace_x86-inl.h
gperftools-2.0/src/stacktrace_win32-inl.h
gperftools-2.0/src/tcmalloc.cc
gperftools-2.0/src/common.h
gperftools-2.0/src/internal_logging.h
gperftools-2.0/src/system-alloc.h
gperftools-2.0/src/packed-cache-inl.h
gperftools-2.0/src/tcmalloc_guard.h
gperftools-2.0/src/pagemap.h
gperftools-2.0/src/sampler.h
gperftools-2.0/src/central_freelist.h
gperftools-2.0/src/linked_list.h
gperftools-2.0/src/libc_override.h
gperftools-2.0/src/libc_override_gcc_and_weak.h
gperftools-2.0/src/libc_override_glibc.h
gperftools-2.0/src/libc_override_osx.h
gperftools-2.0/src/libc_override_redefine.h
gperftools-2.0/src/page_heap.h
gperftools-2.0/src/page_heap_allocator.h
gperftools-2.0/src/span.h
gperftools-2.0/src/static_vars.h
gperftools-2.0/src/symbolize.h
gperftools-2.0/src/thread_cache.h
gperftools-2.0/src/stack_trace_table.h
gperftools-2.0/src/malloc_hook-inl.h
gperftools-2.0/src/malloc_hook_mmap_linux.h
gperftools-2.0/src/malloc_hook_mmap_freebsd.h
gperftools-2.0/src/maybe_threads.h
gperftools-2.0/src/addressmap-inl.h
gperftools-2.0/src/raw_printer.h
gperftools-2.0/src/heap-profile-table.h
gperftools-2.0/src/heap-checker.cc
gperftools-2.0/src/heap-checker-bcad.cc
gperftools-2.0/src/debugallocation.cc
gperftools-2.0/src/common.cc
gperftools-2.0/src/internal_logging.cc
gperftools-2.0/src/system-alloc.cc
gperftools-2.0/src/memfs_malloc.cc
gperftools-2.0/src/central_freelist.cc
gperftools-2.0/src/page_heap.cc
gperftools-2.0/src/sampler.cc
gperftools-2.0/src/span.cc
gperftools-2.0/src/stack_trace_table.cc
gperftools-2.0/src/static_vars.cc
gperftools-2.0/src/symbolize.cc
gperftools-2.0/src/thread_cache.cc
gperftools-2.0/src/malloc_hook.cc
gperftools-2.0/src/malloc_extension.cc
gperftools-2.0/src/maybe_threads.cc
gperftools-2.0/src/heap-profile-table.cc
gperftools-2.0/src/heap-profiler.cc
gperftools-2.0/src/raw_printer.cc
gperftools-2.0/src/memory_region_map.cc
gperftools-2.0/src/config_for_unittests.h
gperftools-2.0/src/memory_region_map.h
gperftools-2.0/src/tcmalloc.h
gperftools-2.0/src/pprof
gperftools-2.0/vsprojects/
gperftools-2.0/vsprojects/addr2line-pdb/
gperftools-2.0/vsprojects/addr2line-pdb/addr2line-pdb.vcproj
gperftools-2.0/vsprojects/addressmap_unittest/
gperftools-2.0/vsprojects/addressmap_unittest/addressmap_unittest.vcproj
gperftools-2.0/vsprojects/current_allocated_bytes_test/
gperftools-2.0/vsprojects/current_allocated_bytes_test/current_allocated_bytes_test.vcproj
gperftools-2.0/vsprojects/frag_unittest/
gperftools-2.0/vsprojects/frag_unittest/frag_unittest.vcproj
gperftools-2.0/vsprojects/libtcmalloc_minimal/
gperftools-2.0/vsprojects/libtcmalloc_minimal/libtcmalloc_minimal.vcproj
gperftools-2.0/vsprojects/low_level_alloc_unittest/
gperftools-2.0/vsprojects/low_level_alloc_unittest/low_level_alloc_unittest.vcproj
gperftools-2.0/vsprojects/malloc_extension_test/
gperftools-2.0/vsprojects/malloc_extension_test/malloc_extension_test.vcproj
gperftools-2.0/vsprojects/malloc_hook_test/
gperftools-2.0/vsprojects/malloc_hook_test/malloc_hook_test.vcproj
gperftools-2.0/vsprojects/markidle_unittest/
gperftools-2.0/vsprojects/markidle_unittest/markidle_unittest.vcproj
gperftools-2.0/vsprojects/nm-pdb/
gperftools-2.0/vsprojects/nm-pdb/nm-pdb.vcproj
gperftools-2.0/vsprojects/packed-cache_test/
gperftools-2.0/vsprojects/packed-cache_test/packed-cache_test.vcproj
gperftools-2.0/vsprojects/page_heap_test/
gperftools-2.0/vsprojects/page_heap_test/page_heap_test.vcproj
gperftools-2.0/vsprojects/pagemap_unittest/
gperftools-2.0/vsprojects/pagemap_unittest/pagemap_unittest.vcproj
gperftools-2.0/vsprojects/preamble_patcher_test/
gperftools-2.0/vsprojects/preamble_patcher_test/preamble_patcher_test.vcproj
gperftools-2.0/vsprojects/realloc_unittest/
gperftools-2.0/vsprojects/realloc_unittest/realloc_unittest.vcproj
gperftools-2.0/vsprojects/sampler_test/
gperftools-2.0/vsprojects/sampler_test/sampler_test.vcproj
gperftools-2.0/vsprojects/stack_trace_table_test/
gperftools-2.0/vsprojects/stack_trace_table_test/stack_trace_table_test.vcproj
gperftools-2.0/vsprojects/tcmalloc_minimal_large/
gperftools-2.0/vsprojects/tcmalloc_minimal_large/tcmalloc_minimal_large_unittest.vcproj
gperftools-2.0/vsprojects/tcmalloc_minimal_unittest/
gperftools-2.0/vsprojects/tcmalloc_minimal_unittest/tcmalloc_minimal_unittest.vcproj
gperftools-2.0/vsprojects/thread_dealloc_unittest/
gperftools-2.0/vsprojects/thread_dealloc_unittest/thread_dealloc_unittest.vcproj
gperftools-2.0/vsprojects/tmu-static/
gperftools-2.0/vsprojects/tmu-static/tmu-static.vcproj
gperftools-2.0/README
gperftools-2.0/configure.ac
gperftools-2.0/aclocal.m4
gperftools-2.0/AUTHORS
gperftools-2.0/COPYING
gperftools-2.0/ChangeLog
gperftools-2.0/INSTALL
gperftools-2.0/NEWS
gperftools-2.0/README_windows.txt
gperftools-2.0/TODO
gperftools-2.0/Makefile.am
gperftools-2.0/Makefile.in
gperftools-2.0/configure
gperftools-2.0/compile
gperftools-2.0/config.guess
gperftools-2.0/config.sub
gperftools-2.0/depcomp
gperftools-2.0/install-sh
gperftools-2.0/ltmain.sh
gperftools-2.0/missing
gperftools-2.0/mkinstalldirs
gperftools-2.0/libtool
gperftools-2.0/gperftools.sln
"patch -p1 < ../../../patches/perftools.patch"
patching file `Makefile.in'
Hunk #1 succeeded at 1738 (offset 371 lines).
patching file `src/profile-handler.cc'
Hunk #1 succeeded at 293 with fuzz 2 (offset 29 lines).
patching file `src/profiledata.cc'
patching file `src/profiledata.h'
patching file `src/profiler.cc'
Hunk #1 succeeded at 68 (offset 5 lines).
Hunk #3 succeeded at 288 (offset 5 lines).
patching file `src/stacktrace.cc'
Hunk #1 succeeded at 52 with fuzz 2.
Hunk #2 succeeded at 109 (offset 39 lines).
"patch -p1 < ../../../patches/perftools-notests.patch"
patching file `Makefile.in'
"patch -p1 < ../../../patches/perftools-pprof.patch"
patching file `src/pprof'
Hunk #1 succeeded at 581 (offset 21 lines).
Hunk #3 succeeded at 2892 (offset 455 lines).
Hunk #5 succeeded at 2930 (offset 455 lines).
Hunk #6 succeeded at 3407 (offset 29 lines).
"patch -p1 < ../../../patches/perftools-gc.patch"
patching file `src/profiledata.cc'
patching file `src/profiledata.h'
patching file `src/profiler.cc'
Hunk #1 succeeded at 92 (offset 5 lines).
Hunk #3 succeeded at 319 (offset 5 lines).
"patch -p1 < ../../../patches/perftools-debug.patch"
patching file `Makefile.in'
Hunk #1 succeeded at 1720 (offset 353 lines).
"patch -p1 < ../../../patches/perftools-objects.patch"
patching file `src/profile-handler.cc'
patching file `src/profiler.cc'
"patch -p1 < ../../../patches/perftools-frames.patch"
patching file `src/profiledata.h'
"patch -p1 < ../../../patches/perftools-realtime.patch"
patching file `src/profile-handler.cc'
"sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h"
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
sed: preserving permissions for `src/base/sed004612': Permission denied
"./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared"

Ruby 2 support

Do perftools.rb support Ruby 2? I get compile errors like:

perftools.c: In function ‘rb_stack_trace’:
perftools.c:159:9: error: ‘ID_ALLOCATOR’ undeclared (first use in this function)

If Ruby 2 is not supported yet, perhaps required_ruby_version could be set in the Gemspec and mentioned in the README.

Profiling object allocations hangs if app traps interrupt

For the following code

trap("INT") do                                                                                                                                                                  
  puts "interrupted"                                                                                                                                                            
end
550_000.times { {} }

The following command will work:

CPUPROFILE=/tmp/my_app_profile RUBYOPT="-r`gem which perftools | tail -1`" ruby test.rb

However, the following command will hang:

CPUPROFILE_OBJECTS=1 CPUPROFILE=/tmp/my_app_profile RUBYOPT="-r`gem which perftools | tail -1`" ruby test.rb

Profiling object allocations works again if you comment out the code that traps interrupt.

CPUPROFILE_REALTIME=1 causes no problems.

Segfault during profile dump exit handler phase

Program terminated with signal 6, Aborted.
#0 0x0000003e38230155 in raise () from /lib64/libc.so.6

(gdb) bt
#0 0x0000003e38230155 in raise () from /lib64/libc.so.6
#1 0x0000003e38231bf0 in abort () from /lib64/libc.so.6
#2 0x000000000049b3a8 in rb_bug (fmt=0x4b830d "Segmentation fault") at error.c:213
#3 0x0000000000472385 in sigsegv (sig=) at signal.c:633
#4
#5 0x0000003e382422e9 in vfprintf () from /lib64/libc.so.6
#6 0x0000003e3824cf18 in fprintf () from /lib64/libc.so.6
#7 0x00002b0171eff325 in ProfileData::Stop (this=0x2b0172106b28) at src/profiledata.cc:232
#8 0x00002b0171efc818 in CpuProfiler::Stop (this=0x2b0172106b20) at src/profiler.cc:207
#9 0x00002b0171efc870 in ~CpuProfiler (this=0x2b0172106b20) at src/profiler.cc:190
#10 0x00002b0171efc8d0 in __tcf_0 () at src/profiler.cc:137
#11 0x0000003e38232fa5 in exit () from /lib64/libc.so.6
#12 0x000000000041fd60 in ruby_stop (ex=) at eval.c:1694
#13 0x0000000000427dce in ruby_run () at eval.c:1715
#14 0x000000000040e343 in main (argc=3, argv=0x7fff38e115e8, envp=) at main.c:48

I can send you a corefile privately.

reproducible segfault with rchardet gem

From the latest in jmhodges/rchardet, running

CPUPROFILE=complete_test_all_unpack_profile RUBYOPT="-r`gem which perftools | tail -1`"  ruby test/complete_test.rb -n big5:0804.blogspot.com.xml

on OS X 10.7.5 with ruby 1.8.7-370 and ree-1.8.7-2012.02 will segfault in ProfileData::GcMark.

It does not occur when using the start API inside the test files.

I'm able to capture the backtrace and it's pasted at the bottom of this ticket. There have been multiple segfaults in this same function but that is the quickest running version of it.

When investigating the Entry that was being marked, it becomes clear it had been corrupted.

(gdb) p e
$8 = {
  count = 4331379760, 
  depth = 5401, 
  stack = {0, 4331683480, 4001, 0, 4331379760, 5401, 0, 4323148280, 16625, 0 <repeats 291 times>}
}

Note that the depth is significantly larger than the stack array. The n at the time of crash was 303.

If I run the entire test suite with rake test, I'm able to get a EXEC_BAD_ACCESS on if (bucket->entry[a].count > 0) {. On investigation, it becomes clear that the b in &hash_[b] is too large for the size of hash_.

Started
/Users/jhodges/projects/rchardet/lib/rchardet/sbcharsetprober.rb:76: [BUG] rb_gc_mark(): unknown data type 0x0(0x7fff5f50f1e0) non object
ruby 1.8.7 (2012-02-08 MBARI 8/0x6770 on patchlevel 358) [i686-darwin11.3.0], MBARI 0x6770, Ruby Enterprise Edition 2012.02

Program received signal SIGABRT, Aborted.
0x00007fff8b22682a in __kill ()
(gdb) bt
#0 0x00007fff8b22682a in __kill ()
#1 0x00007fff8f24ca9c in abort ()
#2 0x0000000100016ff9 in rb_bug ()
#3 0x000000010003b795 in gc_mark_children ()
#4 0x000000010003be58 in rb_gc_mark ()
#5 0x00000001001b94b8 in ProfileData::GcMark (this=0x1001c2968, mark=0x10003bdc0 <rb_gc_mark>) at src/profiledata.cc:216
#6 0x00000001001b7099 in CpuProfiler::GcMark (this=0x1001c2960, cb=0x10003bdc0 <rb_gc_mark>) at src/profiler.cc:239
#7 0x00000001001b70b7 in ProfilerGcMark (cb=0) at src/profiler.cc:324

Rubygems version out of date

I noticed you've added pause, resume, and paused? to this gem here on github, but RubyGems hasn't been updated yet. It'd be nice to have an updated version pushed there so we can use the updated features without having to reference a github repo.

Use of uninitialized value in exists at perftools.rb-0.5.6/bin/pprof line 2342

After running the simple example:

require 'perftools'
PerfTools::CpuProfiler.start("/tmp/add_numbers_profile") do
  5_000_000.times{ 1+2+3+4+5 }
end

and trying to process the output:

pprof.rb --text /tmp/add_numbers_profile
Using local file /usr/local/ruby-enterprise-1.8.7-2010.01/bin/ruby.
Using local file /tmp/add_numbers_profile.
Use of uninitialized value in exists at /usr/local/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/perftools.rb-0.5.6/bin/pprof line 2342.
Total: 176 samples
     164  93.2%  93.2%      164  93.2% Integer#times

If it matters, I'm using google-perftools 1.7 not 1.6 as is linked to in the perftools.rb README.

segfault with ruby 1.8.7-330

Hi,
I have two problems:

The first is when the application is running I get many
*** Caught a segfault during stack trace sampling!
I caught them in gdb (there are two different errors): https://gist.github.com/874420

The second problem is when I stop the sampling (by code or by exiting, same result):
https://gist.github.com/874430

Here is my exact ruby version (compiled from sources with rvm):
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-linux]

These crash only happen when I try to profile a complex ruby server for some time (using eventmachine as the traces show), if I just start the server and exit it perftools.rb works (but I only have a useless graph showing not much :p)

CPUPROFILE_REALTIME=1 disables profiling

#33 (comment)

As asked in #33 when when I don't have CPUPROFILE_REALTIME set current master (1742f97) works fine but when I set it then profiling gets disabled:

$ CPUPROFILE_REALTIME=1 PERFTOOLS=true bin/cucumber
Using the default profile...
Disabling profiler because SIGALRM handler is already in use.

Here's how perftools.rb is integrated to cucumber

features/support/perftools.rb

if ENV['PERFTOOLS']
  require 'perftools'

  PerfTools::CpuProfiler.start('tmp/cucumber.perf')
  at_exit do
    PerfTools::CpuProfiler.stop
  end
end

Can't install Perftools.rb using Ruby 1.9.3

Hi,

I'm using ruby 1.9.3 and when I tried to install the perftools.rb gem I got the following error:

ERROR:  Error installing perftools.rb:
    ERROR: Failed to build gem native extension.

        /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zpxvf gperftools-2.0.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- patch -p1 < ../../../patches/perftools-realtime.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
  -- make
checking for method.h... no
checking for vm_core.h... no
/Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:39: Use RbConfig instead of obsolete and deprecated Config.
checking for method.h... no
checking for vm_core.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/bin/ruby
/Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:268:in `block (2 levels) in read': Looking for http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p374.tar.gz and all I got was a 404! (URI::NotFoundError)
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:1322:in `block (2 levels) in transport_request'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:2671:in `reading_body'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:1321:in `block in transport_request'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:1293:in `request'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:1286:in `block in request'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:745:in `start'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/net/http.rb:1284:in `request'
    from /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:239:in `block in read'
    from /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:286:in `connect'
    from /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:234:in `read'
    from /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/contrib/uri_ext.rb:128:in `download'
    from /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:55:in `block in create_makefile_with_core'
    from /Users/ricardohsd/.rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/tempfile.rb:320:in `open'
    from /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/ruby_core_source-0.1.5/lib/ruby_core_source.rb:51:in `create_makefile_with_core'
    from extconf.rb:104:in `<main>'
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p374.tar.gz


Gem files will remain installed in /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/perftools.rb-2.0.0 for inspection.
Results logged to /Users/ricardohsd/.rvm/gems/ruby-1.9.3-head/gems/perftools.rb-2.0.0/ext/gem_make.out

Can anyone help?

Segfault when profiling objects

I get a segfault when profiling objects on Ubuntu 12.04 (Precise Pangolin) when using Ruby 1.9.3 patchlevel 0.

If there's any additional information you'd like, please let me know. I don't know how to debug segfaults.

$ uname -a
Linux [redacted] 3.2.0-24-generic #39-Ubuntu SMP Mon May 21 16:52:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
$ ruby1.9.1 --version
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

$ CPUPROFILE_OBJECTS=1 CPUPROFILE=/tmp/my_app_profile_objects RUBYOPT="-r`gem1.9.1 which perftools | tail -1`" ruby1.9.1 -e '[].map'
-e:1: [BUG] Segmentation fault
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0004 p:---- s:0009 b:0009 l:000008 d:000008 CFUNC  :map
c:0003 p:0010 s:0006 b:0006 l:0011f8 d:0002f8 EVAL   -e:1
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0011f8 d:0011f8 TOP   

-- Ruby level backtrace information ----------------------------------------
-e:1:in `<main>'
-e:1:in `map'

-- C level backtrace information -------------------------------------------
/usr/lib/libruby-1.9.1.so.1.9(+0x155b29) [0x7fd39f1dab29] ../sysdeps/x86_64/multiarch/strcpy-ssse3.S:1638
/usr/lib/libruby-1.9.1.so.1.9(+0x57709) [0x7fd39f0dc709] vfscanf.c:1777
/usr/lib/libruby-1.9.1.so.1.9(rb_bug+0xb7) [0x7fd39f0dd137] vfscanf.c:1796
/usr/lib/libruby-1.9.1.so.1.9(+0xf604f) [0x7fd39f17b04f] wcfuncs.c:49
/lib/x86_64-linux-gnu/libc.so.6(+0x364c0) [0x7fd39ecfe4c0] ../sysdeps/posix/killpg.c:38
/usr/lib/libruby-1.9.1.so.1.9(rb_check_type+0xd8) [0x7fd39f0de7e8] vfscanf.c:1963
/usr/lib/libruby-1.9.1.so.1.9(rb_data_typed_object_alloc+0xad) [0x7fd39f0f340d] iofdopen.c:51
/usr/lib/libruby-1.9.1.so.1.9(+0x54f9f) [0x7fd39f0d9f9f] vfscanf.c:2014
/usr/lib/libruby-1.9.1.so.1.9(rb_enumeratorize+0x33) [0x7fd39f0dae33] vfscanf.c:2373
/usr/lib/libruby-1.9.1.so.1.9(+0x14e9a1) [0x7fd39f1d39a1] ../sysdeps/x86_64/multiarch/../strcmp.S:293
/usr/lib/libruby-1.9.1.so.1.9(+0x145912) [0x7fd39f1ca912] ../sysdeps/x86_64/multiarch/memcpy-ssse3.S:2001
/usr/lib/libruby-1.9.1.so.1.9(+0x14b31d) [0x7fd39f1d031d] ../sysdeps/x86_64/multiarch/memcpy-ssse3-back.S:2032
/usr/lib/libruby-1.9.1.so.1.9(rb_iseq_eval_main+0xaf) [0x7fd39f1d769f] ../sysdeps/x86_64/multiarch/../strcmp.S:1811
/usr/lib/libruby-1.9.1.so.1.9(+0x5b172) [0x7fd39f0e0172] vfscanf.c:1471
/usr/lib/libruby-1.9.1.so.1.9(ruby_exec_node+0x1d) [0x7fd39f0e0c5d] vfscanf.c:2288
/usr/lib/libruby-1.9.1.so.1.9(ruby_run_node+0x1e) [0x7fd39f0e280e] psiginfo.c:209
ruby1.9.1() [0x4007db]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7fd39ece976d] libc-start.c:226
ruby1.9.1() [0x400809]

-- Other runtime information -----------------------------------------------

* Loaded script: -e

* Loaded features:

    0 enumerator.so
    1 /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
    2 /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
    3 /usr/lib/ruby/1.9.1/rubygems/defaults.rb
    4 /usr/lib/ruby/1.9.1/x86_64-linux/rbconfig.rb
    5 /usr/lib/ruby/1.9.1/rubygems/deprecate.rb
    6 /usr/lib/ruby/1.9.1/rubygems/exceptions.rb
    7 /usr/lib/ruby/1.9.1/rubygems/custom_require.rb
    8 /usr/lib/ruby/1.9.1/rubygems.rb
    9 /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so

* Process memory map:

00400000-00401000 r-xp 00000000 08:07 704429                             /usr/bin/ruby1.9.1
00600000-00601000 r--p 00000000 08:07 704429                             /usr/bin/ruby1.9.1
00601000-00602000 rw-p 00001000 08:07 704429                             /usr/bin/ruby1.9.1
01464000-016e4000 rw-p 00000000 00:00 0                                  [heap]
7fd39c3e1000-7fd39cf53000 rw-p 00000000 00:00 0 
7fd39cf53000-7fd39cf68000 r-xp 00000000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39cf68000-7fd39d167000 ---p 00015000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39d167000-7fd39d168000 r--p 00014000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39d168000-7fd39d169000 rw-p 00015000 08:06 5443                       /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd39d169000-7fd39d24b000 r-xp 00000000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d24b000-7fd39d44a000 ---p 000e2000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d44a000-7fd39d452000 r--p 000e1000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d452000-7fd39d454000 rw-p 000e9000 08:07 137087                     /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7fd39d454000-7fd39d469000 rw-p 00000000 00:00 0 
7fd39d469000-7fd39d47d000 r-xp 00000000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d47d000-7fd39d67c000 ---p 00014000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d67c000-7fd39d67d000 r--p 00013000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d67d000-7fd39d67e000 rw-p 00014000 08:06 144897                     /var/lib/gems/1.9.1/gems/perftools.rb-2.0.0/lib/perftools.so
7fd39d67e000-7fd39d682000 rw-p 00000000 00:00 0 
7fd39d682000-7fd39d684000 r-xp 00000000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d684000-7fd39d884000 ---p 00002000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d884000-7fd39d885000 r--p 00002000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d885000-7fd39d886000 rw-p 00003000 08:07 157727                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/trans/transdb.so
7fd39d886000-7fd39d888000 r-xp 00000000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39d888000-7fd39da87000 ---p 00002000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39da87000-7fd39da88000 r--p 00001000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39da88000-7fd39da89000 rw-p 00002000 08:07 157743                     /usr/lib/ruby/1.9.1/x86_64-linux/enc/encdb.so
7fd39da89000-7fd39e16c000 r--p 00000000 08:07 134744                     /usr/lib/locale/locale-archive
7fd39e16c000-7fd39e265000 r-xp 00000000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e265000-7fd39e464000 ---p 000f9000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e464000-7fd39e465000 r--p 000f8000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e465000-7fd39e466000 rw-p 000f9000 08:06 5454                       /lib/x86_64-linux-gnu/libm-2.15.so
7fd39e466000-7fd39e46f000 r-xp 00000000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e46f000-7fd39e66f000 ---p 00009000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e66f000-7fd39e670000 r--p 00009000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e670000-7fd39e671000 rw-p 0000a000 08:06 5430                       /lib/x86_64-linux-gnu/libcrypt-2.15.so
7fd39e671000-7fd39e69f000 rw-p 00000000 00:00 0 
7fd39e69f000-7fd39e6a1000 r-xp 00000000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e6a1000-7fd39e8a1000 ---p 00002000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e8a1000-7fd39e8a2000 r--p 00002000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e8a2000-7fd39e8a3000 rw-p 00003000 08:06 5435                       /lib/x86_64-linux-gnu/libdl-2.15.so
7fd39e8a3000-7fd39e8aa000 r-xp 00000000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39e8aa000-7fd39eaa9000 ---p 00007000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39eaa9000-7fd39eaaa000 r--p 00006000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39eaaa000-7fd39eaab000 rw-p 00007000 08:06 5508                       /lib/x86_64-linux-gnu/librt-2.15.so
7fd39eaab000-7fd39eac3000 r-xp 00000000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39eac3000-7fd39ecc2000 ---p 00018000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39ecc2000-7fd39ecc3000 r--p 00017000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39ecc3000-7fd39ecc4000 rw-p 00018000 08:06 5502                       /lib/x86_64-linux-gnu/libpthread-2.15.so
7fd39ecc4000-7fd39ecc8000 rw-p 00000000 00:00 0 
7fd39ecc8000-7fd39ee7b000 r-xp 00000000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39ee7b000-7fd39f07a000 ---p 001b3000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39f07a000-7fd39f07e000 r--p 001b2000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39f07e000-7fd39f080000 rw-p 001b6000 08:06 5422                       /lib/x86_64-linux-gnu/libc-2.15.so
7fd39f080000-7fd39f085000 rw-p 00000000 00:00 0 
7fd39f085000-7fd39f0f0000 r-xp 00000000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f0f0000-7fd39f0f3000 rwxp 0006b000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f0f3000-7fd39f275000 r-xp 0006e000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f275000-7fd39f474000 ---p 001f0000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f474000-7fd39f479000 r--p 001ef000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f479000-7fd39f47d000 rw-p 001f4000 08:07 158047                     /usr/lib/libruby-1.9.1.so.1.9.1
7fd39f47d000-7fd39f499000 rw-p 00000000 00:00 0 
7fd39f499000-7fd39f4bb000 r-xp 00000000 08:06 5402                       /lib/x86_64-linux-gnu/ld-2.15.so
7fd39f59b000-7fd39f6a1000 rw-p 00000000 00:00 0 
7fd39f6b4000-7fd39f6b5000 rw-p 00000000 00:00 0 
7fd39f6b5000-7fd39f6b6000 ---p 00000000 00:00 0 
7fd39f6b6000-7fd39f6bb000 rw-p 00000000 00:00 0 
7fd39f6bb000-7fd39f6bc000 r--p 00022000 08:06 5402                       /lib/x86_64-linux-gnu/ld-2.15.so
7fd39f6bc000-7fd39f6be000 rw-p 00023000 08:06 5402                       /lib/x86_64-linux-gnu/ld-2.15.so
7fff507f8000-7fff50819000 rw-p 00000000 00:00 0                          [stack]
7fff50941000-7fff50942000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]


[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)

make it work with google-perftools-1.8.3

I forked your repository and make it work with newer google-perftools-1.8.3.
It may solve some compile error on new linux version(for example >= 3.0.0) or gcc version.
On my Ubuntu desktop 11.10, it now works.

My repository is here https://github.com/asinbow/perftools.rb
I suggest you merge it back, and later one day I will discard my repository.

Again, thanks for your great work.

Not collecting object information?

Using perftools.rb 2.0.0 and REE 2011.03:

require 'rubygems'
require 'perftools'

PerfTools::CpuProfiler.start("/tmp/objects_profile") do
  1_000_000.times{ Array.new(10) }
end

Results:

$ CPUPROFILE_OBJECTS=1 ruby objects.rb
PROFILE: interrupts/evictions/bytes = 0/0/32
$ pprof.rb --pdf /tmp/objects_profile > /tmp/objects_profile.pdf && open /tmp/objects_profile.pdf
Using local file /home/micah/.rvm/rubies/ree-1.8.7-2011.03/bin/ruby.
Using local file /tmp/objects_profile.
No nodes to print

Block forms for pause/resume

It'd be nifty if the #pause and #resume methods could take blocks of code and restore the original state afterward.

Perftools doesn't build against Ruby 1.9.3

Hi, it seems method.h and vm_core.h are not available on 1.9.3. As such, I can't build perftools.rb on 1.9.3. Here is the output when I do gem install perftoos.rb:


[aaron@mobile000 ~]$ gem install perftools.rb
Fetching: perftools.rb-0.5.6.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing perftools.rb:
    ERROR: Failed to build gem native extension.

        /Users/aaron/.local/bin/ruby extconf.rb
NOTE: Gem.activate is deprecated, use Specification#activate. It will be removed on or after 2011-10-01.
Gem.activate called from extconf.rb:24.
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zxvf google-perftools-1.6.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-osx.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
  -- make
checking for method.h... no
checking for vm_core.h... no


***************************************************************************************
********************** Ruby_core_source::create_makefile FAILED ***********************
***************************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/aaron/.local/bin/ruby
Requesting http://cloud.github.com/downloads/mark-moseley/ruby_core_source/preview_revision.yml
Downloading http://cloud.github.com/downloads/mark-moseley/ruby_core_source/preview_revision.yml


Gem files will remain installed in /Users/aaron/.local/lib/ruby/gems/1.9.1/gems/perftools.rb-0.5.6 for inspection.
Results logged to /Users/aaron/.local/lib/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/gem_make.out

"[BUG] Bus Error" on OS X

Running OS X 10.5.6, ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0], I keep getting bus errors when I try to profile my Rails app. Whenever the PerfTools::CpuProfiler.stop call runs, either by executing script/server with "CPUPROFILE=my_app_profile RUBYOPT="-rgem which perftools | tail -1" script/server" or using some custom hooks to start/stop profiling from a controller, I get a short and cryptic error message from mongrel as it crashes:

[BUG] Bus Error
ruby 1.8.6 (2008-03-03) [universal-darwin9.0]

<18 connection closed.
Abort trap

I'm a little stumped as to what else to look for - didn't see anything else in the README or Ilya's blog post, and while the GoRuCo talk mentions patching the Ruby interpreter I didn't see any instructions for that in the README. Any ideas as to what could be going on?

Could not require "perftools"

Hey,

I cannot require "perftools", I added perftools.rb to my Gemfile, bundle install ran without errors, but now I am getting following errors:

irb(main):002:0> require 'perftools'LoadError: cannot load such file -- perftools        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
        from (irb):2        from /usr/bin/irb:12:in `<main>'

I also does not load with Bundler.setup. My code using PerfTools is raising: uninitialized constant PerfTools.

Ruby 2.0.0-p0, Ubuntu 13.04. I tried master branch and packaged gem in newest version as of this writing.

I inspected the place, where gem is installed and instead of lib directory I have an executable binary file with 473 kilobytes in size. Executing this file causes segmentation fault.

files are world writable

During a security scan, I found that the following files are world writable:

/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/doc
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/m4
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/packed-cache_test
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/nm-pdb
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/malloc_extension_test
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/sampler_test
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/page_heap_test
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/tcmalloc_minimal_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/tcmalloc_minimal_large
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/frag_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/markidle_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/addr2line-pdb
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/thread_dealloc_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/libtcmalloc_minimal
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/addressmap_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/pagemap_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/tmu-static
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/stack_trace_table_test
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/low_level_alloc_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/vsprojects/realloc_unittest
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src/base
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src/google
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src/third_party
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src/windows
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src/windows/google
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src/tests
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/src/solaris
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/packages
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/packages/rpm
/usr/lib64/ruby/gems/1.9.1/gems/perftools.rb-0.5.6/ext/src/google-perftools-1.6/packages/deb

While they are not libraries or executables, please ensure that they are a sane permission.

Take care,
vb

Ruby 1.9.1 support

Hello

While trying to replicate some of your delightful performance graphs on my own hand, I've encountered the following compilation error

make
gcc -I. -I/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/i386-darwin10.0.0 -I/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/backward -I/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1 -I. -DRUBY19 -DHAVE_VM_CORE_H -DHAVE_ISEQ_H -DHAVE_INSNS_INC -DHAVE_INSNS_INFO_INC -I/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby-1.9.1-p243 -fno-common -O2 -g -Wall -Wno-parentheses -pipe -fno-common -o perftools.o -c perftools.c
In file included from perftools.c:111:
/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby-1.9.1-p243/iseq.h:16: error: expected declaration specifiers or ‘...’ before ‘NODE’
/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby-1.9.1-p243/iseq.h:17: error: expected ‘)’ before ‘’ token
/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby-1.9.1-p243/iseq.h:18: error: expected ‘)’ before ‘
’ token
/Users/anders/.rvm/ruby-1.9.1-p243/include/ruby-1.9.1/ruby-1.9.1-p243/iseq.h:88: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘attribute’ before ‘’ token
make: *
* [perftools.o] Error 1

Everything is running smoothly if I switch to Ruby 1.8.7. The application I'm trying to benchmark is, however, not. What are your plans for supporting Ruby 1.9.1 -- if any?

Anders

Failed to build gem native extension under linux

when installing from git source, it gets the following error:

gcc -I. -I. -I/usr/lib/ruby/1.8/i486-linux -I. -DRUBY18 -DHAVE_RB_DURING_GC -D_FILE_OFFSET_BITS=64 -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -c perftools.c
perftools.c: In function ‘uc_get_ip’:
perftools.c:314: error: ‘REG_RIP’ undeclared (first use in this function)
perftools.c:314: error: (Each undeclared identifier is reported only once
perftools.c:314: error: for each function it appears in.)

To fix this error, I changed the perftools.c as following:

+#define __USE_GNU

-return (void**)&uc->uc_mcontext.gregs[REG_RIP];

+return (void**)&uc->uc_mcontext.gregs[REG_EIP];

Then, the tool can be installed and run successfully under ubuntu linux 10.04.

perftool ignores CPUPROFILE_FREQUENCY values over 100

The website claims that the maximum frequency is 4000, but that is not the case:

$ cat _pertool_test
require 'perftools'

PerfTools::CpuProfiler.start("my_profile") do
  50.times{ x= 1; 100000.times { x = x - 2*x }}
end
$ CPUPROFILE_FREQUENCY=25 ruby _pertool_test
PROFILE: interrupts/evictions/bytes = 11/0/104
$ CPUPROFILE_FREQUENCY=50 ruby _pertool_test
PROFILE: interrupts/evictions/bytes = 23/0/104
$ CPUPROFILE_FREQUENCY=100 ruby _pertool_test
PROFILE: interrupts/evictions/bytes = 45/0/104
$ CPUPROFILE_FREQUENCY=200 ruby _pertool_test
PROFILE: interrupts/evictions/bytes = 44/0/104
$ CPUPROFILE_FREQUENCY=400 ruby _pertool_test
PROFILE: interrupts/evictions/bytes = 45/0/104

Cannot build perftools.rb

Perhaps this is Snow Leopard related, but when I try to build I get the following error:

$ sudo gem install perftools.rb
Password:
Building native extensions.  This could take a while...
ERROR:  Error installing perftools.rb:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1200:in `stat': No such file or directory - .libs/libprofiler.a (Errno::ENOENT)
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1200:in `lstat'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1178:in `stat'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1260:in `copy_file'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:463:in `copy_file'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:383:in `cp'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1411:in `fu_each_src_dest0'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:382:in `cp'
    from extconf.rb:55
    from extconf.rb:52:in `chdir'
    from extconf.rb:52
    from extconf.rb:24:in `chdir'
    from extconf.rb:24


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/perftools.rb-0.2.5 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/perftools.rb-0.2.5/ext/gem_make.out

Failed to build native extension (perftools.rb 0.5.3) with ruby 1.9.2-p0

OS: osx 10.6.4
Ruby: 1.9.2-p0 installed with rvm

Steps:

gem install ruby_core_source
gem install perftools.rb

Output:

Building native extensions.  This could take a while...
ERROR:  Error installing perftools.rb:
    ERROR: Failed to build gem native extension.

/Users/aaron/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zxvf google-perftools-1.6.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-osx.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
  -- make
checking for method.h... no
checking for vm_core.h... no
checking for method.h... yes
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
creating Makefile

make
gcc -I. -I/Users/aaron/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/x86_64-darwin10.4.0 -I/Users/aaron/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/Users/aaron/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I. -DRUBY19 -DHAVE_METHOD_H -DHAVE_VM_CORE_H -DHAVE_ISEQ_H -DHAVE_INSNS_INC -DHAVE_INSNS_INFO_INC -I/Users/aaron/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby-1.9.2-p0 -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe  -o perftools.o -c perftools.c
In file included from /Users/aaron/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:25,
                 from /Users/aaron/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby.h:32,
                 from perftools.c:5:
/Users/aaron/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/x86_64-darwin10.4.0/ruby/config.h:15:1: warning: "_GNU_SOURCE" redefined
perftools.c:2:1: warning: this is the location of the previous definition
perftools.c:343: error: expected ‘)’ before ‘event’
perftools.c: In function ‘methprofiler_setup’:
perftools.c:353: error: ‘event_handler’ undeclared (first use in this function)
perftools.c:353: error: (Each undeclared identifier is reported only once
perftools.c:353: error: for each function it appears in.)
perftools.c:353: error: too few arguments to function ‘rb_add_event_hook’
perftools.c: In function ‘methprofiler_teardown’:
perftools.c:365: error: ‘event_handler’ undeclared (first use in this function)
make: *** [perftools.o] Error 1

SIGTRAP leaks when using backquotes and object allocation profiler

The whole interpreter aborts with SIGTRAP when using the object allocation profiler. Simply creating the following bla.rb file

`ls`

and running

CPUPROFILE_OBJECTS=1 CPUPROFILE=acd-profile-allocs ruby -rperftools -S bla.rb

triggers it on my machine (Debian unstable, ruby version)

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Errno::EADDRINUSE: Address already in use - connect(2) when using perftools in rspec with aws-sdk

I'm trying to do some profiling through rspec and I'm seeing these error below come out of the aws-sdk. This error only occurs when running perftools. I'm using the latest perftools and aws-sdk with ruby 2.0.0-p195. The tests are using Goliath's test_helper to start up and serve requests to a goliath server.

    Errno::EADDRINUSE:
       Address already in use - connect(2)
     Shared Example Group: "hello" called from ./github.rb:120
     # /Users/kbishop/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `initialize'
     # /Users/kbishop/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `open'
     # /Users/kbishop/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:878:in `block in connect'
     # /Users/kbishop/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/timeout.rb:66:in `timeout'
     # /Users/kbishop/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:877:in `connect'
     # /Users/kbishop/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:862:in `do_start'
     # /Users/kbishop/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/net/http.rb:857:in `start'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/http/connection_pool.rb:301:in `start_session'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/http/connection_pool.rb:125:in `session_for'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/http/net_http_handler.rb:52:in `handle'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:238:in `block in make_sync_request'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:274:in `retry_server_errors'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:234:in `make_sync_request'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:496:in `block (2 levels) in client_request'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:376:in `log_client_request'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:462:in `block in client_request'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:358:in `return_or_raise'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/core/client.rb:461:in `client_request'
     # (eval):3:in `head_object'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/s3/s3_object.rb:294:in `head'
     # /Users/kbishop/.rvm/gems/ruby-2.0.0-p195@n/gems/aws-sdk-1.11.2/lib/aws/s3/s3_object.rb:271:in `exists?'

Rspec setup in spec_helper:

  config.before(:suite) do
    PerfTools::CpuProfiler.start('/redacted')
  end

  config.after(:suite) do
    PerfTools::CpuProfiler.stop
  end

Gem depends on ruby_core_source gem but does not declare the dependency

Issue

The perftools.rb gem requires that the gem "ruby_coure_source" be installed before it will install when using Ruby 1.9.2 but does not declare the dependency in the gem specification file.

Expected behavior

evans-macbook-pro:~ evan$ gem install perftools.rb
Building native extensions.  This could take a while...
Successfully installed perftools.rb-0.5.4
1 gem installed
Installing ri documentation for perftools.rb-0.5.4...
Installing RDoc documentation for perftools.rb-0.5.4...
evans-macbook-pro:~ evan$ 

Actual behavior

evans-macbook-pro:~ evan$ gem install perftools.rb
Building native extensions.  This could take a while...
ERROR:  Error installing perftools.rb:
    ERROR: Failed to build gem native extension.

/Users/evan/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb


***************************************************************************************
******************** PLEASE RUN gem install ruby_core_source FIRST ********************
***************************************************************************************
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/evan/.rvm/rubies/ruby-1.9.2-p0/bin/ruby


Gem files will remain installed in /Users/evan/.rvm/gems/ruby-1.9.2-p0@expendable-2/gems/perftools.rb-0.5.4 for inspection.
Results logged to /Users/evan/.rvm/gems/ruby-1.9.2-p0@expendable-2/gems/perftools.rb-0.5.4/ext/gem_make.out
evans-macbook-pro:~ evan$ 

Impact

Destroys ability to specify perftools.rb in a Bundler gemfile when using Ruby 1.9.2 and Rails 3.0.3. Adding "ruby_core_source" to the gemfile prior to the declaration of perftools.rb unfortunately does not guarantee it will be installed before perftools.rb.

System configuration

  • Ruby 1.9.2p0
  • perftools.rb 0.5.4
  • rvm 1.0.14
  • Mac OS X 10.6.6

latest perftools (0.4.7) crashed ruby when running "complex" scripts (Snow Leopard x86_64)

Running simple ruby scripts with perftools works fine! but i'd like to find the hotspots in my more complex apps but running them with perftools crashes ruby. to reproduce simply try to run rake with perftools:

CPUPROFILE=/tmp/my_app_profile RUBYOPT="-rgem which perftools | tail -1" ruby -S rake

> CPUPROFILE=/tmp/my_app_profile RUBYOPT="-rgem which perftools | tail -1" ruby -S rake

/Users/thieso/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rubygems.rb:10: [BUG] Segmentation fault
ruby 1.9.2dev (2010-07-11 revision 28618) [x86_64-darwin10.4.0]

-- control frame ----------
c:0010 p:---- s:0032 b:0032 l:000031 d:000031 CFUNC :require
c:0009 p:0025 s:0028 b:0028 l:000027 d:000027 TOP /Users/thieso/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rubygems.rb:10
c:0008 p:---- s:0025 b:0025 l:000024 d:000024 FINISH
c:0007 p:---- s:0023 b:0023 l:000022 d:000022 CFUNC :require
c:0006 p:0123 s:0019 b:0019 l:000018 d:000018 METHOD internal:gem_prelude:158
c:0005 p:0017 s:0016 b:0016 l:000015 d:000015 METHOD internal:gem_prelude:280
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 FINISH
c:0003 p:0121 s:0008 b:0007 l:001588 d:001f90 EVAL /Users/thieso/.rvm/gems/ruby-1.9.2-rc2/bin/rake:19
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH

c:0001 p:0000 s:0002 b:0002 l:001588 d:001588 TOP

-- Ruby level backtrace information ----------------------------------------
/Users/thieso/.rvm/gems/ruby-1.9.2-rc2/bin/rake:19:in <main>' <internal:gem_prelude>:280:inmethod_missing'
internal:gem_prelude:158:in load_full_rubygems_library' <internal:gem_prelude>:158:inrequire'
/Users/thieso/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rubygems.rb:10:in <top (required)>' /Users/thieso/.rvm/rubies/ruby-1.9.2-rc2/lib/ruby/1.9.1/rubygems.rb:10:inrequire'

-- C level backtrace information -------------------------------------------

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

[1] 656 abort CPUPROFILE=/tmp/my_app_profile RUBYOPT="-rgem which perftools | tail -1" -

Oddly named method names, such as 0000000200639fef

Hi there.

I'm sure there's a simple explanation: The CPU time graph I generate has useful information, but I see some method with odd hex names, such as 0000000200639fef. Unfortunately, some of these look to be slow, but I'm not sure where to look. Are these Proc identifiers?

Thanks.

Link to perftools 1.7 in VM / C section?

In the section "Profiling the Ruby VM and C extensions", does it merely tell you to download 1.6 because that was the version when the docs was written, or does 1.7 not work?

profiled process can get stuck in a loop calling clone()

20:35:22.718345 --- SIGPROF (Profiling timer expired) @ 0 (0) ---
20:35:22.718515 rt_sigaction(SIGSEGV, {0x7ffe94cf1150, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, {0x477e80, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, 8) = 0 <0.000022>
20:35:22.718672 rt_sigaction(SIGSEGV, {0x477e80, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, {0x7ffe94cf1150, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, 8) = 0 <0.000021>
20:35:22.718817 rt_sigreturn(0x34d4f7c) = 56 <0.000023>
20:35:22.718897 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7ffe9877f9f0) = ? ERESTARTNOINTR (To be restarted) <0.050648>
20:35:22.769627 --- SIGPROF (Profiling timer expired) @ 0 (0) ---
20:35:22.769797 rt_sigaction(SIGSEGV, {0x7ffe94cf1150, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, {0x477e80, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, 8) = 0 <0.000021>
20:35:22.769952 rt_sigaction(SIGSEGV, {0x477e80, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, {0x7ffe94cf1150, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, 8) = 0 <0.000021>
20:35:22.770097 rt_sigreturn(0x34d4f7c) = 56 <0.000022>
20:35:22.770176 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7ffe9877f9f0) = ? ERESTARTNOINTR (To be restarted) <0.054384>
20:35:22.824653 --- SIGPROF (Profiling timer expired) @ 0 (0) ---
20:35:22.824841 rt_sigaction(SIGSEGV, {0x7ffe94cf1150, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, {0x477e80, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, 8) = 0 <0.000021>
20:35:22.824998 rt_sigaction(SIGSEGV, {0x477e80, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, {0x7ffe94cf1150, [SEGV], SA_RESTORER|SA_RESTART, 0x7ffe9770daf0}, 8) = 0 <0.000021>
20:35:22.825143 rt_sigreturn(0x34d4f7c) = 56 <0.000023>
20:35:22.825224 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7ffe9877f9f0) = ? ERESTARTNOINTR (To be restarted) <0.052579>

See also http://code.google.com/p/google-perftools/issues/detail?id=279

REE compatibility

Seems to be broken with REE. I get:

src/tcmalloc.cc:353] Attempt to free invalid pointer: 0x209a90
Abort trap

I can send reproduction code privately.

perftools.rb is a hack

The SEGV handler has to go. Ignoring the top frame makes profiles kind of useless too.

The solution is to use the signal handler to register a one-time ruby event hook. This hook will fire the next time a method is called, providing a consistent VM state in which to take a profiling sample. No risk of segfaults and no hacks required.

perftool.rb gem fails on Darwin ruby 1.9.3-p0

Specifically it fails with:
Symbol not found: _ruby_current_thread (LoadError)

This appears similar to:
#26
...and a pull request at:
https://github.com/vjt/perftools.rb ... which unfortately gives me a segfault

bash-3.2$ gem which perftools
/Users/justin/.rvm/gems/ruby-1.9.3-p0@app/gems/perftools.rb-0.5.6/lib/perftools.bundle
bash-3.2$ CPUPROFILE=/tmp/my_app_profile \
>   RUBYOPT="-r`gem which perftools | tail -1`" \
>   rspec spec/models/test_spec.rb -l 313
/Users/justin/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': dlopen(/Users/justin/.rvm/gems/ruby-1.9.3-p0@app/gems/perftools.rb-0.5.6/lib/perftools.bundle, 9): Symbol not found: _ruby_current_thread (LoadError)
  Referenced from: /Users/justin/.rvm/gems/ruby-1.9.3-p0@app/gems/perftools.rb-0.5.6/lib/perftools.bundle
  Expected in: flat namespace
 in /Users/justin/.rvm/gems/ruby-1.9.3-p0@app/gems/perftools.rb-0.5.6/lib/perftools.bundle - /Users/justin/.rvm/gems/ruby-1.9.3-p0@app/gems/perftools.rb-0.5.6/lib/perftools.bundle
    from /Users/justin/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

GC not appearing in the profile report when profiling with Ruby Enterprise Edition

I've been trying to profile a Rails app with perftools, and after several runs with MRI 1.8.7-p352, I got reports similar to this one:

 13  61.9%  61.9%       13  61.9% garbage_collector
   3  14.3%  76.2%        4  19.0% ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#execute
   3  14.3%  90.5%        3  14.3% ActiveSupport::BufferedLogger#flush

It looked like the main bottleneck was the GC in this case. I then ran the same test with REE 1.8.7-2012.02 and got this:

   5  83.3%  83.3%        5  83.3% ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#execute
   1  16.7% 100.0%        1  16.7% ActiveSupport::BufferedLogger#flush
   0   0.0% 100.0%        6 100.0% ActionController::Base#perform_action_without_filters

Now, the main problem seems to slow SQL queries. At first sight, this looks good, meaning that at least the GC is faster, or it seems to be so.

However, I would think the GC would have to show up in the report, but it does not. Does that mean that REE's GC is so much better and faster than MRI's that perftools doesn't capture it?

Symbol not found error when requiring perftools

I'm not able to require perftools after installing. Here's what I get:

[10:35:54 bhelmkamp@fozzie] ~ ☠
$ sudo gem install -s http://gems.github.com tmm1-perftools.rb
Building native extensions. This could take a while...
Successfully installed tmm1-perftools.rb-0.1.3
1 gem installed
Installing ri documentation for tmm1-perftools.rb-0.1.3...
Installing RDoc documentation for tmm1-perftools.rb-0.1.3...

[10:37:02 bhelmkamp@fozzie] ~ ☠
$ irb
re>> require "perftools"
LoadError: dlopen(/Library/Ruby/Gems/1.8/gems/tmm1-perftools.rb-0.1.3/lib/perftools.bundle, 9): Symbol not found: ___gxx_personality_v0
Referenced from: /Library/Ruby/Gems/1.8/gems/tmm1-perftools.rb-0.1.3/lib/perftools.bundle
Expected in: dynamic lookup

  • /Library/Ruby/Gems/1.8/gems/tmm1-perftools.rb-0.1.3/lib/perftools.bundle
    from /Library/Ruby/Gems/1.8/gems/tmm1-perftools.rb-0.1.3/lib/perftools.bundle
    from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
    from (irb):1

Install stuck running extconf.rb

$ ruby -v
ruby 1.9.3p286 (2012-10-12 revision 37165) [i686-linux]

Trying to install perftools.rb 2.0.0 the install gets stuck running extconf.rb

$ gem install perftools.rb -v '2.0.0'
Building native extensions.  This could take a while...

$ pstree -a | grep ruby
  |   |       `-ruby /home/betelgeuse/.rvm/rubies/ruby-1.9.3-p286/bin/gem install perftools.rb -v 2.0.0
  |   |           |-sh -c /home/betelgeuse/.rvm/rubies/ruby-1.9.3-p286/bin/ruby extconf.rb 2>&1
  |   |           |   `-ruby extconf.rb
  |   |           |       `-{ruby}
  |   |           `-{ruby}
  |   |   |-grep --color=auto ruby


Perftools isn't building (again?)

This seems to be similar to issue 15, but for 0.5.5:

/usr/bin/ruby1.9.1 extconf.rb
(I'm about to compile google-perftools.. this will definitely take a while)
  -- tar zxvf google-perftools-1.6.tar.gz
  -- patch -p1 < ../../../patches/perftools.patch
  -- patch -p1 < ../../../patches/perftools-notests.patch
  -- patch -p1 < ../../../patches/perftools-pprof.patch
  -- patch -p1 < ../../../patches/perftools-gc.patch
  -- patch -p1 < ../../../patches/perftools-debug.patch
  -- patch -p1 < ../../../patches/perftools-objects.patch
  -- patch -p1 < ../../../patches/perftools-frames.patch
  -- sed -i -e 's,SpinLock,ISpinLock,g' src/*.cc src/*.h src/base/*.cc src/base/*.h
  -- ./configure --disable-heap-profiler --disable-heap-checker --disable-debugalloc --disable-shared
  -- make
checking for method.h... no
checking for vm_core.h... no
checking for method.h... no
checking for vm_core.h... no
Requesting http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz
Downloading http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p243.tar.gz
checking for method.h... no
checking for vm_core.h... yes
checking for iseq.h... yes
checking for insns.inc... yes
checking for insns_info.inc... yes
creating Makefile

make
cc -I. -I/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DRUBY19 -DHAVE_VM_CORE_H -DHAVE_ISEQ_H -DHAVE_INSNS_INC -DHAVE_INSNS_INFO_INC -I/usr/include/ruby-1.9.1/ruby-1.9.1-p243 -fPIC -fno-strict-aliasing -g -g -O2 -O2 -g -Wall -Wno-parentheses  -fPIC  -o perftools.o -c perftools.c
In file included from /usr/include/ruby-1.9.1/ruby/ruby.h:25,
                 from /usr/include/ruby-1.9.1/ruby.h:32,
                 from perftools.c:5:
/usr/include/ruby-1.9.1/x86_64-linux/ruby/config.h:21:1: warning: "_GNU_SOURCE" redefined
perftools.c:2:1: warning: this is the location of the previous definition
perftools.c:96:5: warning: "/*" within comment
perftools.c:349: error: expected ‘)’ before ‘event’
perftools.c: In function ‘methprofiler_setup’:
perftools.c:363: error: ‘event_handler’ undeclared (first use in this function)
perftools.c:363: error: (Each undeclared identifier is reported only once
perftools.c:363: error: for each function it appears in.)
perftools.c:363: error: too few arguments to function ‘rb_add_event_hook’
perftools.c: In function ‘methprofiler_teardown’:
perftools.c:376: error: ‘event_handler’ undeclared (first use in this function)
make: *** [perftools.o] Error 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.