From d09a40ca0b4f1965d0753b19abb253b6907692c7 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Wed, 28 Apr 2010 00:11:28 +0000 Subject: [PATCH] 2010-04-28 Mark Probst * sgen-gc.c, sgen-marksweep.c, sgen-major-copying.c: Bring heavy statistics up-to-date. svn path=/trunk/mono/; revision=156274 --- mono/metadata/ChangeLog | 5 +++ mono/metadata/sgen-gc.c | 65 ++++++++++++++------------------------ mono/metadata/sgen-major-copying.c | 28 ++++++++++++---- mono/metadata/sgen-marksweep.c | 8 +++-- 4 files changed, 56 insertions(+), 50 deletions(-) diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog index e1f734fa522..1dd3e7bf6a6 100644 --- a/mono/metadata/ChangeLog +++ b/mono/metadata/ChangeLog @@ -1,3 +1,8 @@ +2010-04-28 Mark Probst + + * sgen-gc.c, sgen-marksweep.c, sgen-major-copying.c: Bring heavy + statistics up-to-date. + 2010-04-27 Mark Probst * sgen-gc.c, sgen-marksweep.c, sgen-major-copying.c: Support diff --git a/mono/metadata/sgen-gc.c b/mono/metadata/sgen-gc.c index 71b1fc9a85c..708abb57aaa 100644 --- a/mono/metadata/sgen-gc.c +++ b/mono/metadata/sgen-gc.c @@ -258,16 +258,18 @@ static long stat_bytes_alloced = 0; static long stat_objects_alloced_degraded = 0; static long stat_bytes_alloced_degraded = 0; static long stat_bytes_alloced_los = 0; + static long stat_copy_object_called_nursery = 0; static long stat_objects_copied_nursery = 0; static long stat_copy_object_called_major = 0; static long stat_objects_copied_major = 0; -static long stat_copy_object_failed_from_space = 0; -static long stat_copy_object_failed_forwarded = 0; -static long stat_copy_object_failed_pinned = 0; -static long stat_copy_object_failed_large_pinned = 0; -static long stat_copy_object_failed_to_space = 0; +static long stat_scan_object_called_nursery = 0; +static long stat_scan_object_called_major = 0; + +static long stat_nursery_copy_object_failed_from_space = 0; +static long stat_nursery_copy_object_failed_forwarded = 0; +static long stat_nursery_copy_object_failed_pinned = 0; static long stat_store_remsets = 0; static long stat_store_remsets_unique = 0; @@ -276,9 +278,6 @@ static long stat_saved_remsets_2 = 0; static long stat_global_remsets_added = 0; static long stat_global_remsets_processed = 0; -static long num_copy_object_called = 0; -static long num_objects_copied = 0; - static int stat_wbarrier_set_field = 0; static int stat_wbarrier_set_arrayref = 0; static int stat_wbarrier_arrayref_copy = 0; @@ -2033,8 +2032,6 @@ copy_object_no_checks (void *obj) DEBUG (9, fprintf (gc_debug_file, " (to %p, %s size: %zd)\n", destination, ((MonoObject*)obj)->vtable->klass->name, objsize)); binary_protocol_copy (obj, destination, ((MonoObject*)obj)->vtable, objsize); - HEAVY_STAT (++num_objects_copied); - if (objsize <= sizeof (gpointer) * 8) { mword *dest = (mword*)destination; goto *copy_labels [objsize / sizeof (gpointer)]; @@ -2125,10 +2122,10 @@ copy_object (void **obj_slot) DEBUG (9, g_assert (current_collection_generation == GENERATION_NURSERY)); - HEAVY_STAT (++num_copy_object_called); + HEAVY_STAT (++stat_copy_object_called_nursery); if (!ptr_in_nursery (obj)) { - HEAVY_STAT (++stat_copy_object_failed_from_space); + HEAVY_STAT (++stat_nursery_copy_object_failed_from_space); return; } @@ -2143,17 +2140,19 @@ copy_object (void **obj_slot) if ((forwarded = object_is_forwarded (obj))) { DEBUG (9, g_assert (((MonoVTable*)LOAD_VTABLE(obj))->gc_descr)); DEBUG (9, fprintf (gc_debug_file, " (already forwarded to %p)\n", forwarded)); - HEAVY_STAT (++stat_copy_object_failed_forwarded); + HEAVY_STAT (++stat_nursery_copy_object_failed_forwarded); *obj_slot = forwarded; return; } if (object_is_pinned (obj)) { DEBUG (9, g_assert (((MonoVTable*)LOAD_VTABLE(obj))->gc_descr)); DEBUG (9, fprintf (gc_debug_file, " (pinned, no change)\n")); - HEAVY_STAT (++stat_copy_object_failed_pinned); + HEAVY_STAT (++stat_nursery_copy_object_failed_pinned); return; } + HEAVY_STAT (++stat_objects_copied_nursery); + *obj_slot = copy_object_no_checks (obj); } @@ -2181,6 +2180,8 @@ scan_object (char *start) { #include "sgen-scan-object.h" + HEAVY_STAT (++stat_scan_object_called_nursery); + return start; } @@ -2240,6 +2241,8 @@ major_scan_object (char *start) { #include "sgen-scan-object.h" + HEAVY_STAT (++stat_scan_object_called_major); + return start; } @@ -3069,11 +3072,6 @@ init_stats (void) { static gboolean inited = FALSE; -#ifdef HEAVY_STATISTICS - num_copy_object_called = 0; - num_objects_copied = 0; -#endif - if (inited) return; @@ -3113,16 +3111,18 @@ init_stats (void) mono_counters_register ("# objects allocated degraded", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_objects_alloced_degraded); mono_counters_register ("bytes allocated degraded", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_bytes_alloced_degraded); mono_counters_register ("bytes allocated in LOS", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_bytes_alloced_los); + mono_counters_register ("# copy_object() called (nursery)", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_copy_object_called_nursery); mono_counters_register ("# objects copied (nursery)", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_objects_copied_nursery); mono_counters_register ("# copy_object() called (major)", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_copy_object_called_major); mono_counters_register ("# objects copied (major)", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_objects_copied_major); - mono_counters_register ("# copy_object() failed from space", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_copy_object_failed_from_space); - mono_counters_register ("# copy_object() failed forwarded", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_copy_object_failed_forwarded); - mono_counters_register ("# copy_object() failed pinned", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_copy_object_failed_pinned); - mono_counters_register ("# copy_object() failed large or pinned chunk", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_copy_object_failed_large_pinned); - mono_counters_register ("# copy_object() failed to space", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_copy_object_failed_to_space); + mono_counters_register ("# scan_object() called (nursery)", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_scan_object_called_nursery); + mono_counters_register ("# scan_object() called (major)", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_scan_object_called_major); + + mono_counters_register ("# nursery copy_object() failed from space", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_nursery_copy_object_failed_from_space); + mono_counters_register ("# nursery copy_object() failed forwarded", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_nursery_copy_object_failed_forwarded); + mono_counters_register ("# nursery copy_object() failed pinned", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_nursery_copy_object_failed_pinned); mono_counters_register ("Store remsets", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_store_remsets); mono_counters_register ("Unique store remsets", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_store_remsets_unique); @@ -3135,21 +3135,6 @@ init_stats (void) inited = TRUE; } -static void -commit_stats (int generation) -{ -#ifdef HEAVY_STATISTICS - if (generation == GENERATION_NURSERY) { - stat_copy_object_called_nursery += num_copy_object_called; - stat_objects_copied_nursery += num_objects_copied; - } else { - g_assert (generation == GENERATION_OLD); - stat_copy_object_called_major += num_copy_object_called; - stat_objects_copied_major += num_objects_copied; - } -#endif -} - /* * Collect objects in the nursery. Returns whether to trigger a major * collection. @@ -3275,8 +3260,6 @@ collect_nursery (size_t requested_size) g_assert (gray_object_queue_is_empty ()); - commit_stats (GENERATION_NURSERY); - check_scan_starts (); current_collection_generation = -1; diff --git a/mono/metadata/sgen-major-copying.c b/mono/metadata/sgen-major-copying.c index e8082fc80ed..830fcb6f810 100644 --- a/mono/metadata/sgen-major-copying.c +++ b/mono/metadata/sgen-major-copying.c @@ -68,6 +68,13 @@ static char *to_space_bumper = NULL; static char *to_space_top = NULL; static GCMemSection *to_space_section = NULL; +#ifdef HEAVY_STATISTICS +static long stat_major_copy_object_failed_forwarded = 0; +static long stat_major_copy_object_failed_pinned = 0; +static long stat_major_copy_object_failed_large_pinned = 0; +static long stat_major_copy_object_failed_to_space = 0; +#endif + static gboolean obj_is_from_pinned_alloc (char *p) { @@ -282,7 +289,7 @@ major_copy_or_mark_object (void **obj_slot) DEBUG (9, g_assert (current_collection_generation == GENERATION_OLD)); - HEAVY_STAT (++num_copy_object_called); + HEAVY_STAT (++stat_copy_object_called_major); DEBUG (9, fprintf (gc_debug_file, "Precise copy of %p from %p", obj, obj_slot)); @@ -314,14 +321,14 @@ major_copy_or_mark_object (void **obj_slot) if ((forwarded = object_is_forwarded (obj))) { DEBUG (9, g_assert (((MonoVTable*)LOAD_VTABLE(obj))->gc_descr)); DEBUG (9, fprintf (gc_debug_file, " (already forwarded to %p)\n", forwarded)); - HEAVY_STAT (++stat_copy_object_failed_forwarded); + HEAVY_STAT (++stat_major_copy_object_failed_forwarded); *obj_slot = forwarded; return; } if (object_is_pinned (obj)) { DEBUG (9, g_assert (((MonoVTable*)LOAD_VTABLE(obj))->gc_descr)); DEBUG (9, fprintf (gc_debug_file, " (pinned, no change)\n")); - HEAVY_STAT (++stat_copy_object_failed_pinned); + HEAVY_STAT (++stat_major_copy_object_failed_pinned); return; } @@ -355,7 +362,7 @@ major_copy_or_mark_object (void **obj_slot) binary_protocol_pin (obj, (gpointer)LOAD_VTABLE (obj), safe_object_get_size ((MonoObject*)obj)); pin_object (obj); GRAY_OBJECT_ENQUEUE (obj); - HEAVY_STAT (++stat_copy_object_failed_large_pinned); + HEAVY_STAT (++stat_major_copy_object_failed_large_pinned); return; } @@ -367,11 +374,13 @@ major_copy_or_mark_object (void **obj_slot) if (MAJOR_OBJ_IS_IN_TO_SPACE (obj)) { DEBUG (9, g_assert (objsize <= MAX_SMALL_OBJ_SIZE)); DEBUG (9, fprintf (gc_debug_file, " (already copied)\n")); - HEAVY_STAT (++stat_copy_object_failed_to_space); + HEAVY_STAT (++stat_major_copy_object_failed_to_space); return; } copy: + HEAVY_STAT (++stat_objects_copied_major); + *obj_slot = copy_object_no_checks (obj); } @@ -754,8 +763,6 @@ major_do_collection (const char *reason) g_assert (gray_object_queue_is_empty ()); - commit_stats (GENERATION_OLD); - num_major_sections_saved = MAX (old_num_major_sections - num_major_sections, 1); save_target = num_major_sections / 2; @@ -816,6 +823,13 @@ static void major_init (void) { minor_collection_section_allowance = MIN_MINOR_COLLECTION_SECTION_ALLOWANCE; + +#ifdef HEAVY_STATISTICS + mono_counters_register ("# major copy_object() failed forwarded", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_major_copy_object_failed_forwarded); + mono_counters_register ("# major copy_object() failed pinned", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_major_copy_object_failed_pinned); + mono_counters_register ("# major copy_object() failed large or pinned chunk", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_major_copy_object_failed_large_pinned); + mono_counters_register ("# major copy_object() failed to space", MONO_COUNTER_GC | MONO_COUNTER_LONG, &stat_major_copy_object_failed_to_space); +#endif } /* only valid during minor collections */ diff --git a/mono/metadata/sgen-marksweep.c b/mono/metadata/sgen-marksweep.c index 77b09f2e033..f609ca6781b 100644 --- a/mono/metadata/sgen-marksweep.c +++ b/mono/metadata/sgen-marksweep.c @@ -365,6 +365,8 @@ alloc_degraded (MonoVTable *vtable, size_t size) { void *obj = alloc_obj (size, FALSE); *(MonoVTable**)obj = vtable; + HEAVY_STAT (++stat_objects_alloced_degraded); + HEAVY_STAT (stat_bytes_alloced_degraded += size); return obj; } @@ -489,6 +491,8 @@ major_copy_or_mark_object (void **ptr) int index; int count; + HEAVY_STAT (++stat_copy_object_called_major); + DEBUG (9, g_assert (obj)); DEBUG (9, g_assert (current_collection_generation == GENERATION_OLD)); @@ -503,6 +507,8 @@ major_copy_or_mark_object (void **ptr) if (object_is_pinned (obj)) return; + HEAVY_STAT (++stat_objects_copied_major); + obj = copy_object_no_checks (obj); *ptr = obj; @@ -850,8 +856,6 @@ major_do_collection (const char *reason) g_assert (gray_object_queue_is_empty ()); - commit_stats (GENERATION_OLD); - num_major_sections_saved = MAX (old_num_major_sections - num_major_sections, 1); save_target = num_major_sections / 2; -- 2.11.4.GIT