tmm1 / perftools.rb

gperftools for ruby code
http://gperftools.googlecode.com/svn/trunk/doc/cpuprofile.html#pprof
1.02k stars 61 forks source link

Fix the object allocation profile mode on Ruby 2.x #66

Closed benweint closed 11 years ago

benweint commented 11 years ago

The object allocation profiler currently works by patching the rb_newobj function in Ruby. This function is no longer directly used in Ruby 2.x - rb_newobj_of is used instead.

This change patches either rb_newobj or rb_newobj_of, depending on whether the targeted Ruby version has rb_newobj_of available.

tmm1 commented 11 years ago

Unfortunately rb_newobj_of is not widely used, so this technique will not catch the majority of allocations.

benweint commented 11 years ago

@tmm1 hmm, my experimentation suggested the opposite - I got no results at all from the object allocation profiler on 2.0.0-p247 until I switched over to patching rb_newobj_of. From my brief read, it looked like internal usage within MRI had switched over to rb_newobj_of - are you referring to usage by 3rd-party C extensions?

tmm1 commented 11 years ago

Ah, you're right. Glad this is working.