(2011/09/06 22:05), Charlie Savage wrote:
> 
> Issue #5291 has been reported by Charlie Savage.
> 
> ----------------------------------------
> Feature #5291: Enabling GC Profiler GC_PROFILE_MORE_DETAIL and CALC_EXACT_MALLOC_SIZE
> http://redmine.ruby-lang.org/issues/5291
> 
> Author: Charlie Savage
> Status: Open
> Priority: Normal
> Assignee: 
> Category: core
> Target version: 1.9.3
> 
> 
> I would like to hook ruby-prof into the new GC profiler. However, by default a lot of the profile stats are disabled by these two defines in gcc.c.
> 
> #define GC_PROFILE_MORE_DETAIL 0
> #define CALC_EXACT_MALLOC_SIZE 0
> 
> To turn on these stats, you have to modify the ruby source code!  That is a high barrier for most people.
> 
> So would it be possible to:
> 
> * Set them to 1 by default.  Or would this be too much of a performance hit?
> 
> - or - 
> 
> * Remove the lines entirely and then change the logic in the file from this:
> 
> #if GC_PROFILE_MORE_DETAIL
> 
> To this:
> 
> #if defined?(GC_PROFILE_MORE_DETAIL)
> 
> Then when buildig Ruby you could tell the compiler to define the symbols  (-DGC_PROFILE_MORE_DETAIL).
> 
> - or -
> 
> * Add these two defines to the ./configure script so they end up in config.h.  That would make it easy for users to enable them if they wish, and would be also allow ruby-prof to use them too.
> 
> Would a patch be accepted to do this?
> 
> 

How about it?

Index: gc.c
===================================================================
--- gc.c	(revision 33165)
+++ gc.c	(working copy)
@@ -93,7 +93,10 @@
 int ruby_gc_debug_indent = 0;

 /* for GC profile */
+#ifndef GC_PROFILE_MORE_DETAIL
 #define GC_PROFILE_MORE_DETAIL 0
+#endif
+
 typedef struct gc_profile_record {
     double gc_time;
     double gc_mark_time;
@@ -309,7 +312,9 @@
     struct gc_list *next;
 };

+#ifndef CALC_EXACT_MALLOC_SIZE
 #define CALC_EXACT_MALLOC_SIZE 0
+#endif

 typedef struct rb_objspace {
     struct {


-- 
// SASADA Koichi at atdot dot net