[前][次][番号順一覧][スレッド一覧]

ruby-changes:31426

From: tarui <ko1@a...>
Date: Fri, 1 Nov 2013 21:49:56 +0900 (JST)
Subject: [ruby-changes:31426] tarui:r43505 (trunk): * gc.c (typedef struct rb_objspace): Refactoring. Move some members

tarui	2013-11-01 21:49:49 +0900 (Fri, 01 Nov 2013)

  New Revision: 43505

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43505

  Log:
    * gc.c (typedef struct rb_objspace): Refactoring. Move some members
      into profile member.
    
    * gc.c (newobj_of): Correspond to the above.
    
    * gc.c (finalize_list): Ditto.
    
    * gc.c (objspace_live_num): Ditto.
    
    * gc.c (gc_page_sweep): Ditto.
    
    * gc.c (rb_gc_force_recycle): Ditto.
    
    * gc.c (garbage_collect_body): Ditto.
    
    * gc.c (rb_gc_count): Ditto.
    
    * gc.c (gc_stat): Ditto.
    
    * gc.c (gc_prof_set_heap_info): Ditto.
    
    * gc.c (gc_profile_dump_on): Ditto.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43504)
+++ ChangeLog	(revision 43505)
@@ -1,3 +1,28 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov  1 21:40:35 2013  Masaya Tarui  <tarui@r...>
+
+	* gc.c (typedef struct rb_objspace): Refactoring. Move some members
+	  into profile member.
+
+	* gc.c (newobj_of): Correspond to the above.
+
+	* gc.c (finalize_list): Ditto.
+
+	* gc.c (objspace_live_num): Ditto.
+
+	* gc.c (gc_page_sweep): Ditto.
+
+	* gc.c (rb_gc_force_recycle): Ditto.
+
+	* gc.c (garbage_collect_body): Ditto.
+
+	* gc.c (rb_gc_count): Ditto.
+
+	* gc.c (gc_stat): Ditto.
+
+	* gc.c (gc_prof_set_heap_info): Ditto.
+
+	* gc.c (gc_profile_dump_on): Ditto.
+
 Fri Nov  1 20:53:56 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* string.c (rb_str_scrub): fix typo, should yield invalid byte
Index: gc.c
===================================================================
--- gc.c	(revision 43504)
+++ gc.c	(revision 43505)
@@ -410,11 +410,13 @@ typedef struct rb_objspace { https://github.com/ruby/ruby/blob/trunk/gc.c#L410
 	double gc_sweep_start_time;
 	size_t total_allocated_object_num_at_gc_start;
 	size_t heap_used_at_gc_start;
+
+	/* basic statistics */
+	size_t count;
+	size_t total_allocated_object_num;
+	size_t total_freed_object_num;
     } profile;
     struct gc_list *global_list;
-    size_t count;
-    size_t total_allocated_object_num;
-    size_t total_freed_object_num;
     rb_event_flag_t hook_events; /* this place may be affinity with memory cache */
     VALUE gc_stress;
 
@@ -1159,7 +1161,7 @@ newobj_of(VALUE klass, VALUE flags, VALU https://github.com/ruby/ruby/blob/trunk/gc.c#L1161
     if (rgengc_remembered(objspace, (VALUE)obj)) rb_bug("newobj: %p (%s) is remembered.\n", (void *)obj, obj_type_name(obj));
 #endif
 
-    objspace->total_allocated_object_num++;
+    objspace->profile.total_allocated_object_num++;
     gc_event_hook(objspace, RUBY_INTERNAL_EVENT_NEWOBJ, obj);
 
     return obj;
@@ -1866,7 +1868,7 @@ finalize_list(rb_objspace_t *objspace, R https://github.com/ruby/ruby/blob/trunk/gc.c#L1868
 	struct heap_page *page = GET_HEAP_PAGE(p);
 
 	run_final(objspace, (VALUE)p);
-	objspace->total_freed_object_num++;
+	objspace->profile.total_freed_object_num++;
 
 	page->final_num--;
 	heap_page_add_freeobj(objspace, GET_HEAP_PAGE(p), (VALUE)p);
@@ -2346,7 +2348,7 @@ lazy_sweep_enable(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L2348
 static size_t
 objspace_live_num(rb_objspace_t *objspace)
 {
-    return objspace->total_allocated_object_num - objspace->total_freed_object_num;
+    return objspace->profile.total_allocated_object_num - objspace->profile.total_freed_object_num;
 }
 
 static size_t
@@ -2455,7 +2457,7 @@ gc_page_sweep(rb_objspace_t *objspace, r https://github.com/ruby/ruby/blob/trunk/gc.c#L2457
 	}
     }
     heap_pages_swept_num += freed_num + empty_num;
-    objspace->total_freed_object_num += freed_num;
+    objspace->profile.total_freed_object_num += freed_num;
     heap_pages_final_num += final_num;
     sweep_page->final_num = final_num;
 
@@ -4303,7 +4305,7 @@ rb_gc_force_recycle(VALUE p) https://github.com/ruby/ruby/blob/trunk/gc.c#L4305
     }
 #endif
 
-    objspace->total_freed_object_num++;
+    objspace->profile.total_freed_object_num++;
     heap_page_add_freeobj(objspace, GET_HEAP_PAGE(p), p);
 
     /* Disable counting swept_num because there are no meaning.
@@ -4403,10 +4405,10 @@ garbage_collect_body(rb_objspace_t *objs https://github.com/ruby/ruby/blob/trunk/gc.c#L4405
 
     if (GC_NOTIFY) fprintf(stderr, "start garbage_collect(%d, %d, %d)\n", full_mark, immediate_sweep, reason);
 
-    objspace->count++;
+    objspace->profile.count++;
     gc_event_hook(objspace, RUBY_INTERNAL_EVENT_GC_START, 0 /* TODO: pass minor/immediate flag? */);
 
-    objspace->profile.total_allocated_object_num_at_gc_start = objspace->total_allocated_object_num;
+    objspace->profile.total_allocated_object_num_at_gc_start = objspace->profile.total_allocated_object_num;
     objspace->profile.heap_used_at_gc_start = heap_pages_used;
 
     gc_prof_setup_new_record(objspace, reason);
@@ -4571,7 +4573,7 @@ gc_count_add_each_types(VALUE hash, cons https://github.com/ruby/ruby/blob/trunk/gc.c#L4573
 size_t
 rb_gc_count(void)
 {
-    return rb_objspace.count;
+    return rb_objspace.profile.count;
 }
 
 /*
@@ -4671,7 +4673,7 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L4673
         hash = rb_hash_new();
     }
 
-    rb_hash_aset(hash, sym_count, SIZET2NUM(objspace->count));
+    rb_hash_aset(hash, sym_count, SIZET2NUM(objspace->profile.count));
     /* implementation dependent counters */
     rb_hash_aset(hash, sym_heap_used, SIZET2NUM(heap_pages_used));
     rb_hash_aset(hash, sym_heap_final_num, SIZET2NUM(heap_pages_final_num));
@@ -4682,8 +4684,8 @@ gc_stat(int argc, VALUE *argv, VALUE sel https://github.com/ruby/ruby/blob/trunk/gc.c#L4684
     rb_hash_aset(hash, sym_heap_live_num, SIZET2NUM(objspace_live_num(objspace)));
     rb_hash_aset(hash, sym_heap_free_num, SIZET2NUM(objspace_free_num(objspace)));
 
-    rb_hash_aset(hash, sym_total_allocated_object, SIZET2NUM(objspace->total_allocated_object_num));
-    rb_hash_aset(hash, sym_total_freed_object, SIZET2NUM(objspace->total_freed_object_num));
+    rb_hash_aset(hash, sym_total_allocated_object, SIZET2NUM(objspace->profile.total_allocated_object_num));
+    rb_hash_aset(hash, sym_total_freed_object, SIZET2NUM(objspace->profile.total_freed_object_num));
 #if USE_RGENGC
     rb_hash_aset(hash, sym_minor_gc_count, SIZET2NUM(objspace->profile.minor_gc_count));
     rb_hash_aset(hash, sym_major_gc_count, SIZET2NUM(objspace->profile.major_gc_count));
@@ -5853,7 +5855,7 @@ gc_prof_set_heap_info(rb_objspace_t *obj https://github.com/ruby/ruby/blob/trunk/gc.c#L5855
 {
     if (objspace->profile.run) {
 	gc_profile_record *record = gc_prof_record(objspace);
-	size_t live = objspace->profile.total_allocated_object_num_at_gc_start - objspace->total_freed_object_num;
+	size_t live = objspace->profile.total_allocated_object_num_at_gc_start - objspace->profile.total_freed_object_num;
 	size_t total = objspace->profile.heap_used_at_gc_start * HEAP_OBJ_LIMIT;
 
 #if GC_PROFILE_MORE_DETAIL
@@ -6021,7 +6023,7 @@ gc_profile_dump_on(VALUE out, VALUE (*ap https://github.com/ruby/ruby/blob/trunk/gc.c#L6023
 	size_t i;
 	const gc_profile_record *record;
 
-	append(out, rb_sprintf("GC %"PRIuSIZE" invokes.\n", objspace->count));
+	append(out, rb_sprintf("GC %"PRIuSIZE" invokes.\n", objspace->profile.count));
 	append(out, rb_str_new_cstr("Index    Invoke Time(sec)       Use Size(byte)     Total Size(byte)         Total Object                    GC Time(ms)\n"));
 
 	for (i = 0; i < count; i++) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]