[sgen] Move SGen statistics out of gc-internal.h.
authorMark Probst <mark.probst@gmail.com>
Sun, 7 Sep 2014 12:16:40 +0000 (14:16 +0200)
committerMark Probst <mark.probst@gmail.com>
Mon, 29 Sep 2014 18:04:02 +0000 (11:04 -0700)
This introduced a dependency from sgen-conf.h to a lot of compilation units
in metadata, leading to long build times when experimenting with SGen.

mono/metadata/gc-internal.h
mono/metadata/gc.c
mono/metadata/sgen-gc.c
mono/metadata/sgen-gray.c
mono/metadata/sgen-gray.h

index f5e9ba95dc0ceab38d0b4de1cbc5330f19cff28b..8e8c35f836065991b4a5266b39a45da65f223441 100644 (file)
@@ -13,7 +13,6 @@
 #include <glib.h>
 #include <mono/metadata/object-internals.h>
 #include <mono/metadata/threads-types.h>
-#include <mono/metadata/sgen-conf.h>
 #include <mono/utils/gc_wrapper.h>
 
 typedef struct {
@@ -22,14 +21,6 @@ typedef struct {
        long long minor_gc_time;
        long long major_gc_time;
        long long major_gc_time_concurrent;
-#ifdef HEAVY_STATISTICS
-       unsigned long long gray_queue_section_alloc;
-       unsigned long long gray_queue_section_free;
-       unsigned long long gray_queue_enqueue_fast_path;
-       unsigned long long gray_queue_dequeue_fast_path;
-       unsigned long long gray_queue_enqueue_slow_path;
-       unsigned long long gray_queue_dequeue_slow_path;
-#endif
 } GCStats;
 
 #define mono_domain_finalizers_lock(domain) mono_mutex_lock (&(domain)->finalizable_objects_hash_lock);
index 95073555641a16f501b2787119532c95dc3e6c9a..a0472955071df183adf0d6457be366fe0c78cb3a 100644 (file)
@@ -1155,14 +1155,6 @@ mono_gc_init (void)
        mono_counters_register ("Minor GC time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.minor_gc_time);
        mono_counters_register ("Major GC time", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.major_gc_time);
        mono_counters_register ("Major GC time concurrent", MONO_COUNTER_GC | MONO_COUNTER_LONG | MONO_COUNTER_TIME, &gc_stats.major_gc_time_concurrent);
-#ifdef HEAVY_STATISTICS
-       mono_counters_register ("Gray Queue alloc section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_section_alloc);
-       mono_counters_register ("Gray Queue free section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_section_free);
-       mono_counters_register ("Gray Queue enqueue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_enqueue_fast_path);
-       mono_counters_register ("Gray Queue dequeue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_dequeue_fast_path);
-       mono_counters_register ("Gray Queue enqueue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_enqueue_slow_path);
-       mono_counters_register ("Gray Queue dequeue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &gc_stats.gray_queue_dequeue_slow_path);
-#endif
 
        mono_gc_base_init ();
 
index 29eaa6d6ab35a4a433a3d713dfaf80fabe27a2d7..01d92284afed80fc35a75701a4c49abe712b8fa3 100644 (file)
@@ -4606,6 +4606,7 @@ mono_gc_base_init (void)
        sgen_init_stw ();
        sgen_init_hash_table ();
        sgen_init_descriptors ();
+       sgen_init_gray_queues ();
 
        sgen_register_fixed_internal_mem_type (INTERNAL_MEM_SECTION, SGEN_SIZEOF_GC_MEM_SECTION);
        sgen_register_fixed_internal_mem_type (INTERNAL_MEM_FINALIZE_READY_ENTRY, sizeof (FinalizeReadyEntry));
index 9201f98cd860d4e681c7fb3a9c90231f099a6dee..247608751fe5fe850fdf6feed51797cf503b2715 100644 (file)
 #include "utils/mono-counters.h"
 #include "sgen-protocol.h"
 
+#ifdef HEAVY_STATISTICS
+unsigned long long stat_gray_queue_section_alloc;
+unsigned long long stat_gray_queue_section_free;
+unsigned long long stat_gray_queue_enqueue_fast_path;
+unsigned long long stat_gray_queue_dequeue_fast_path;
+unsigned long long stat_gray_queue_enqueue_slow_path;
+unsigned long long stat_gray_queue_dequeue_slow_path;
+#endif
+
 #define GRAY_QUEUE_LENGTH_LIMIT        64
 
 #ifdef SGEN_CHECK_GRAY_OBJECT_SECTIONS
@@ -46,7 +55,7 @@ sgen_gray_object_alloc_queue_section (SgenGrayQueue *queue)
 {
        GrayQueueSection *section;
 
-       HEAVY_STAT (gc_stats.gray_queue_section_alloc ++);
+       HEAVY_STAT (stat_gray_queue_section_alloc ++);
 
        if (queue->alloc_prepare_func)
                queue->alloc_prepare_func (queue);
@@ -75,7 +84,7 @@ sgen_gray_object_alloc_queue_section (SgenGrayQueue *queue)
 void
 sgen_gray_object_free_queue_section (GrayQueueSection *section)
 {
-       HEAVY_STAT (gc_stats.gray_queue_section_free ++);
+       HEAVY_STAT (stat_gray_queue_section_free ++);
 
        STATE_TRANSITION (section, GRAY_QUEUE_SECTION_STATE_FLOATING, GRAY_QUEUE_SECTION_STATE_FREED);
        sgen_free_internal (section, INTERNAL_MEM_GRAY_QUEUE);
@@ -92,7 +101,7 @@ sgen_gray_object_enqueue (SgenGrayQueue *queue, char *obj, mword desc)
 {
        GrayQueueEntry entry = { obj, desc };
 
-       HEAVY_STAT (gc_stats.gray_queue_enqueue_slow_path ++);
+       HEAVY_STAT (stat_gray_queue_enqueue_slow_path ++);
 
        SGEN_ASSERT (9, obj, "enqueueing a null object");
        //sgen_check_objref (obj);
@@ -124,7 +133,7 @@ sgen_gray_object_dequeue (SgenGrayQueue *queue)
 {
        GrayQueueEntry entry;
 
-       HEAVY_STAT (gc_stats.gray_queue_dequeue_slow_path ++);
+       HEAVY_STAT (stat_gray_queue_dequeue_slow_path ++);
 
        if (sgen_gray_object_queue_is_empty (queue)) {
                entry.obj = NULL;
@@ -353,4 +362,16 @@ sgen_section_gray_queue_enqueue (SgenSectionGrayQueue *queue, GrayQueueSection *
        unlock_section_queue (queue);
 }
 
+void
+sgen_init_gray_queues (void)
+{
+#ifdef HEAVY_STATISTICS
+       mono_counters_register ("Gray Queue alloc section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_section_alloc);
+       mono_counters_register ("Gray Queue free section", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_section_free);
+       mono_counters_register ("Gray Queue enqueue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_enqueue_fast_path);
+       mono_counters_register ("Gray Queue dequeue fast path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_dequeue_fast_path);
+       mono_counters_register ("Gray Queue enqueue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_enqueue_slow_path);
+       mono_counters_register ("Gray Queue dequeue slow path", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &stat_gray_queue_dequeue_slow_path);
+#endif
+}
 #endif
index b277765d374955c9c0323d85755c9396b3876665..c0ccd616bd7cebb1090739d92cf61a1f4688d73a 100644 (file)
@@ -121,6 +121,17 @@ struct _SgenSectionGrayQueue {
 #define GRAY_LAST_CURSOR_POSITION(s) ((s)->entries + SGEN_GRAY_QUEUE_SECTION_SIZE - 1)
 #define GRAY_FIRST_CURSOR_POSITION(s) ((s)->entries)
 
+#ifdef HEAVY_STATISTICS
+extern unsigned long long stat_gray_queue_section_alloc;
+extern unsigned long long stat_gray_queue_section_free;
+extern unsigned long long stat_gray_queue_enqueue_fast_path;
+extern unsigned long long stat_gray_queue_dequeue_fast_path;
+extern unsigned long long stat_gray_queue_enqueue_slow_path;
+extern unsigned long long stat_gray_queue_dequeue_slow_path;
+#endif
+
+void sgen_init_gray_queues (void) MONO_INTERNAL;
+
 void sgen_gray_object_enqueue (SgenGrayQueue *queue, char *obj, mword desc) MONO_INTERNAL;
 GrayQueueEntry sgen_gray_object_dequeue (SgenGrayQueue *queue) MONO_INTERNAL;
 GrayQueueSection* sgen_gray_object_dequeue_section (SgenGrayQueue *queue) MONO_INTERNAL;
@@ -158,7 +169,7 @@ GRAY_OBJECT_ENQUEUE (SgenGrayQueue *queue, char* obj, mword desc)
        } else {
                GrayQueueEntry entry = { obj, desc };
 
-               HEAVY_STAT (gc_stats.gray_queue_enqueue_fast_path ++);
+               HEAVY_STAT (stat_gray_queue_enqueue_fast_path ++);
 
                *++queue->cursor = entry;
 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
@@ -178,7 +189,7 @@ GRAY_OBJECT_DEQUEUE (SgenGrayQueue *queue, char** obj, mword *desc)
        *desc = entry.desc;
 #else
        if (!queue->first) {
-               HEAVY_STAT (gc_stats.gray_queue_dequeue_fast_path ++);
+               HEAVY_STAT (stat_gray_queue_dequeue_fast_path ++);
 
                *obj = NULL;
 #ifdef SGEN_HEAVY_BINARY_PROTOCOL
@@ -189,7 +200,7 @@ GRAY_OBJECT_DEQUEUE (SgenGrayQueue *queue, char** obj, mword *desc)
                *obj = entry.obj;
                *desc = entry.desc;
        } else {
-               HEAVY_STAT (gc_stats.gray_queue_dequeue_fast_path ++);
+               HEAVY_STAT (stat_gray_queue_dequeue_fast_path ++);
 
                entry = *queue->cursor--;
                *obj = entry.obj;