ruby-changes:31512
From: tarui <ko1@a...>
Date: Sat, 9 Nov 2013 08:59:27 +0900 (JST)
Subject: [ruby-changes:31512] tarui:r43591 (trunk): * gc.c : Add GC_PROFILE_DETAIL_MEMORY option.
tarui 2013-11-09 08:59:20 +0900 (Sat, 09 Nov 2013) New Revision: 43591 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43591 Log: * gc.c : Add GC_PROFILE_DETAIL_MEMORY option. If GC_PROFILE_MORE_DETAIL && GC_PROFILE_DETAIL_MEMORY, maxrss, minflt and majflt are added to each profile record. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43590) +++ ChangeLog (revision 43591) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 9 08:58:23 2013 Masaya Tarui <tarui@r...> + + * gc.c : Add GC_PROFILE_DETAIL_MEMORY option. + If GC_PROFILE_MORE_DETAIL && GC_PROFILE_DETAIL_MEMORY, + maxrss, minflt and majflt are added to each profile record. + Sat Nov 9 07:41:41 2013 Nobuyoshi Nakada <nobu@r...> * internal.h (rb_vm_backtrace_object, rb_gc_count): make prototype Index: gc.c =================================================================== --- gc.c (revision 43590) +++ gc.c (revision 43591) @@ -206,6 +206,9 @@ static ruby_gc_params_t initial_params = https://github.com/ruby/ruby/blob/trunk/gc.c#L206 #ifndef GC_PROFILE_MORE_DETAIL #define GC_PROFILE_MORE_DETAIL 0 #endif +#ifndef GC_PROFILE_DETAIL_MEMORY +#define GC_PROFILE_DETAIL_MEMORY 0 +#endif #ifndef GC_ENABLE_LAZY_SWEEP #define GC_ENABLE_LAZY_SWEEP 1 #endif @@ -263,8 +266,12 @@ typedef struct gc_profile_record { https://github.com/ruby/ruby/blob/trunk/gc.c#L266 double prepare_time; size_t removing_objects; size_t empty_objects; +#if GC_PROFILE_DETAIL_MEMORY + long maxrss; + long minflt; + long majflt; +#endif #endif - #if CALC_EXACT_MALLOC_SIZE size_t allocated_size; #endif @@ -6128,6 +6135,18 @@ gc_prof_setup_new_record(rb_objspace_t * https://github.com/ruby/ruby/blob/trunk/gc.c#L6135 #if CALC_EXACT_MALLOC_SIZE record->allocated_size = malloc_allocated_size; #endif +#if GC_PROFILE_DETAIL_MEMORY +#ifdef RUSAGE_SELF + { + struct rusage usage; + if (getrusage(RUSAGE_SELF, &usage) == 0) { + record->maxrss = usage.ru_maxrss; + record->minflt = usage.ru_minflt; + record->majflt = usage.ru_majflt; + } + } +#endif +#endif } } @@ -6442,6 +6461,9 @@ gc_profile_dump_on(VALUE out, VALUE (*ap https://github.com/ruby/ruby/blob/trunk/gc.c#L6461 #if RGENGC_PROFILE " OldgenObj RemNormObj RemShadObj" #endif +#if GC_PROFILE_DETAIL_MEMORY + " MaxRSS(KB) MinorFLT MajorFLT" +#endif "\n")); for (i = 0; i < count; i++) { @@ -6454,6 +6476,10 @@ gc_profile_dump_on(VALUE out, VALUE (*ap https://github.com/ruby/ruby/blob/trunk/gc.c#L6476 #if RGENGC_PROFILE "%10"PRIuSIZE" %10"PRIuSIZE" %10"PRIuSIZE #endif +#if GC_PROFILE_DETAIL_MEMORY + "%11ld %8ld %8ld" +#endif + "\n", i+1, "-+O3S567R9abcdef!"[record->flags & GPR_FLAG_MAJOR_MASK], /* Stress,Rescan,Shady,Oldgen,NoFree */ @@ -6482,6 +6508,13 @@ gc_profile_dump_on(VALUE out, VALUE (*ap https://github.com/ruby/ruby/blob/trunk/gc.c#L6508 record->remembered_normal_objects, record->remembered_shady_objects #endif +#if GC_PROFILE_DETAIL_MEMORY + , + record->maxrss / 1024, + record->minflt, + record->majflt +#endif + )); } #endif @@ -6851,6 +6884,7 @@ Init_GC(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L6884 OPT(GC_ENABLE_LAZY_SWEEP); OPT(CALC_EXACT_MALLOC_SIZE); OPT(CALC_EXACT_MALLOC_SIZE_CHECK_OLD_SIZE); + OPT(GC_PROFILE_DETAIL_MEMORY); #undef OPT } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/