# Ruby-prof on Ruby 1.9 woes

**URL:** <https://www.ruby-forum.com/t/ruby-prof-on-ruby-1-9-woes/174195>\
**Category:** Ruby\
**Created:** [August 22, 2009, 4:58am UTC](https://www.ruby-forum.com/t/ruby-prof-on-ruby-1-9-woes/174195 "2009-08-22T04:58:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shot\_SPiotr\_S.S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@Shot\_SPiotr\_S.S](https://www.ruby-forum.com/u/Shot_SPiotr_S.S)\
**Post date:** [August 22, 2009, 4:58am UTC](https://www.ruby-forum.com/t/ruby-prof-on-ruby-1-9-woes/174195/1 "2009-08-22T04:58:45Z")

</div>

Iâ€™m trying to use ruby-prof with Ruby 1.9.1p243 on 64-bit Ubuntu.

The current released version doesnâ€™t work, but a gem built from the  
ruby-profâ€™s svn repoâ€™s trunk at least installs properly. Unfortunately,  
when trying to profile a Ruby 1.9 it breaks as described at  
[http://redmine.ruby-lang.org/issues/show/1227](http://redmine.ruby-lang.org/issues/show/1227)

I tried to clone [http://github.com/trafficbroker/ruby-prof](http://github.com/trafficbroker/ruby-prof) and  
â€˜rake gemâ€™, but a subsequent â€˜gem installâ€™ attempt results in

Building native extensions. This could take a while…  
ERROR: Error installing ruby-prof-0.7.3.2.gem:  
ERROR: Failed to build gem native extension.

/home/shot/opt/ruby-1.9.1-p243/bin/ruby extconf.rb install  
ruby-prof-0.7.3.2.gem  
checking for sys/times.h… yes  
checking for rb\_os\_allocated\_objects()… no  
checking for rb\_gc\_allocated\_size()… no  
checking for rb\_gc\_collections()… no  
checking for rb\_gc\_time()… no  
checking for rb\_heap\_total\_mem()… no  
checking for rb\_gc\_heap\_info()… no  
checking for rb\_gc\_malloc\_allocations()… no  
checking for rb\_gc\_malloc\_allocated\_size()… no  
creating Makefile

make  
gcc -I. -I/home/shot/opt/ruby-1.9.1-p243/include/ruby-1.9.1/x86\_64-linux  
-I/home/shot/opt/ruby-1.9.1-p243/include/ruby-1.9.1/ruby/backward  
-I/home/shot/opt/ruby-1.9.1-p243/include/ruby-1.9.1 -I.  
-DHAVE\_SYS\_TIMES\_H -fPIC -O2 -g -Wall -Wno-parentheses -o  
ruby\_prof.o -c ruby\_prof.c  
ruby\_prof.c:890: error: expected declaration specifiers or â€˜…â€™ before  
â€˜NODEâ€™  
ruby\_prof.c: In function â€˜prof\_event\_hookâ€™:  
ruby\_prof.c:1137: error: â€˜nodeâ€™ undeclared (first use in this function)  
ruby\_prof.c:1137: error: (Each undeclared identifier is reported only  
once  
ruby\_prof.c:1137: error: for each function it appears in.)  
ruby\_prof.c:1137: error: too many arguments to function â€˜get\_methodâ€™  
ruby\_prof.c:1143: warning: passing argument 5 of â€˜get\_methodâ€™ makes  
pointer from integer without a cast  
ruby\_prof.c:1143: error: too many arguments to function â€˜get\_methodâ€™  
make: \*\*\* [ruby\_prof.o] Error 1

I finally tried to use upstream ruby-prof 0.7.3 patched just with the  
patch from [http://redmine.ruby-lang.org/issues/show/1227#note-6](http://redmine.ruby-lang.org/issues/show/1227#note-6) but this  
makes the profiling run for ages in most of my cases. I even tested this  
in a freshly-setup 32-bit Ubuntu, but with the same results. 😑

Does anyone know of a way to make ruby-prof  
work in sensible time in my case?

Steps to reproduce:

1. Install any ruby-prof version thatâ€™s supposed to work with Ruby 1.9
2. git clone git://github.com/Chastell/art-decomp.git
3. cd art-decomp
4. export RUBYOPT="$RUBYOPT -Ku’ # -Ku doesnâ€™t work in shebang on Linux

$ time bin/inputs kiss/s510  
â€¦  
real 0m0.571s  
user 0m0.468s  
sys 0m0.008s

$ time bin/inputs kiss/s420  
â€¦  
real 0m1.183s  
user 0m1.040s  
sys 0m0.012s

$ time ruby-prof bin/inputs kiss/s510  
â€¦  
real 0m2.862s  
user 0m2.100s  
sys 0m0.556s

$ time ruby-prof bin/inputs kiss/s420  
â€¦  
[take ages, but does finish eventually]

â€” Shot

---

<div class="post-metadata">

**Author:** ![Shot\_SPiotr\_S.S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@Shot\_SPiotr\_S.S](https://www.ruby-forum.com/u/Shot_SPiotr_S.S)\
**Post date:** [August 22, 2009, 7:09pm UTC](https://www.ruby-forum.com/t/ruby-prof-on-ruby-1-9-woes/174195/2 "2009-08-22T19:09:49Z")

</div>

> The current released version doesn’t work, but a gem built from the  
> ruby-prof’s svn repo’s trunk at least installs properly. Unfortunately,  
> when trying to profile a Ruby 1.9 it breaks as described at  
> [http://redmine.ruby-lang.org/issues/show/1227](http://redmine.ruby-lang.org/issues/show/1227)

The patches there don’t fix it?  
-r

---

<div class="post-metadata">

**Author:** ![Shot\_SPiotr\_S.S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@Shot\_SPiotr\_S.S](https://www.ruby-forum.com/u/Shot_SPiotr_S.S)\
**Post date:** [August 23, 2009, 12:45am UTC](https://www.ruby-forum.com/t/ruby-prof-on-ruby-1-9-woes/174195/3 "2009-08-23T00:45:49Z")

</div>

Roger P.:

> > The current released version doesnâ€™t work, but a gem built from the  
> > ruby-profâ€™s svn repoâ€™s trunk at least installs properly. Unfortunately,  
> > when trying to profile a Ruby 1.9 it breaks as described at  
> > [http://redmine.ruby-lang.org/issues/show/1227](http://redmine.ruby-lang.org/issues/show/1227)

> The patches there don’t fix it?

The patch there fixes the trunk version of ruby-prof in that it does  
work under Ruby 1.9, but ruby-prof runs for ages in most cases (cases  
which seem quite similar to ones where it behaves â€“ and I never had this  
kind of problems with ruby-prof under Ruby 1.8). Basically, while it  
makes the whole program run a bit slower (which is understandable), the  
compilation of the final report takes ridiculously long.

Iâ€™ll see whether backporting my code to Ruby 1.8 is a viable option and  
if so whether profiling it then makes a difference with regards to run  
times.

â€” Shot

---

<div class="post-metadata">

**Author:** ![Shot\_SPiotr\_S.S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@Shot\_SPiotr\_S.S](https://www.ruby-forum.com/u/Shot_SPiotr_S.S)\
**Post date:** [August 24, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/ruby-prof-on-ruby-1-9-woes/174195/4 "2009-08-24T16:27:01Z")

</div>

Thanks, Roger, for all your prompt and to-the-point help! 🙂

Roger P.:

> > Basically, while it makes the whole program run a bit slower (which  
> > is understandable), the compilation of the final report takes  
> > ridiculously long.

> gem install jeremy-ruby-prof  
> might help?

Perfect, thank you!

(I do like the ease-of-forking granted by Git/GitHub, but  
choosing _which_ ruby-prof fork there has the right combination  
of working-under-Ruby-1.9 and performance was too much for me,  
apparently.)

Now off to figure why does this version produces a 48 MiB HTML  
profile (with tons of distinct references like Set#&-2388) while the  
slow-as-melasses one produces a 1.4 MiB HTML profile (with all the Set#&  
calls combined into Set#& and Set#&-1)â€¦

â€” Shot

---

<div class="post-metadata">

**Author:** ![Shot\_SPiotr\_S.S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/e79b87/32.png) [@Shot\_SPiotr\_S.S](https://www.ruby-forum.com/u/Shot_SPiotr_S.S)\
**Post date:** [August 23, 2009, 7:39pm UTC](https://www.ruby-forum.com/t/ruby-prof-on-ruby-1-9-woes/174195/5 "2009-08-23T19:39:46Z")

</div>

> Basically, while it  
> makes the whole program run a bit slower (which is understandable), the  
> compilation of the final report takes ridiculously long.

gem install jeremy-ruby-prof

might help?  
-r
