[sgen] More information in sweep and world restart DTrace probes.
authorMark Probst <mark.probst@gmail.com>
Fri, 16 Nov 2012 10:48:05 +0000 (11:48 +0100)
committerMark Probst <mark.probst@gmail.com>
Sun, 9 Dec 2012 14:02:48 +0000 (15:02 +0100)
Pass to the sweep probes whether a full sweep (including memset and resetting
mark bitmaps) was performed.

Pass to the world restart probes the oldest generation collected during
the pause.

data/mono.d
mono/metadata/sgen-gc.c
mono/metadata/sgen-gc.h
mono/metadata/sgen-marksweep.c
mono/metadata/sgen-stw.c

index 76721151289f4f091c13303179e90a6cc71d5a78..c6447a2a0dbf70c0589890838e5339abb8e52075 100644 (file)
@@ -25,13 +25,13 @@ provider mono {
        probe gc__concurrent__update__end (int generation);
        probe gc__concurrent__finish__end (int generation);
 
-       probe gc__sweep__begin (int generation);
-       probe gc__sweep__end (int generation);
+       probe gc__sweep__begin (int generation, int full_sweep);
+       probe gc__sweep__end (int generation, int full_sweep);
 
        probe gc__world__stop__begin ();
        probe gc__world__stop__end ();
-       probe gc__world__restart__begin ();
-       probe gc__world__restart__end ();
+       probe gc__world__restart__begin (int generation);
+       probe gc__world__restart__end (int generation);
 
        probe gc__heap__alloc (uintptr_t addr, uintptr_t len);
        probe gc__heap__free (uintptr_t addr, uintptr_t len);
index 88cd8a7db30e492ef3897abf4aa96ff39a131606..bed7176aade2d4bfb2fb384f22f9987cd73ff7e0 100644 (file)
@@ -2963,7 +2963,7 @@ major_finish_collection (const char *reason, int old_next_pin_slot, gboolean sca
        reset_heap_boundaries ();
        sgen_update_heap_boundaries ((mword)sgen_get_nursery_start (), (mword)sgen_get_nursery_end ());
 
-       MONO_GC_SWEEP_BEGIN (GENERATION_OLD);
+       MONO_GC_SWEEP_BEGIN (GENERATION_OLD, !major_collector.sweeps_lazily);
 
        /* sweep the big objects list */
        prevbo = NULL;
@@ -2998,7 +2998,7 @@ major_finish_collection (const char *reason, int old_next_pin_slot, gboolean sca
 
        major_collector.sweep ();
 
-       MONO_GC_SWEEP_END (GENERATION_OLD);
+       MONO_GC_SWEEP_END (GENERATION_OLD, !major_collector.sweeps_lazily);
 
        TV_GETTIME (btv);
        time_major_sweep += TV_ELAPSED (atv, btv);
@@ -3165,8 +3165,11 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
        TV_DECLARE (gc_end);
        GGTimingInfo infos [2];
        int overflow_generation_to_collect = -1;
+       int oldest_generation_collected = generation_to_collect;
        const char *overflow_reason = NULL;
 
+       g_assert (generation_to_collect == GENERATION_NURSERY || generation_to_collect == GENERATION_OLD);
+
        memset (infos, 0, sizeof (infos));
        mono_profiler_gc_event (MONO_GC_EVENT_START, generation_to_collect);
 
@@ -3180,8 +3183,10 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
 
        if (concurrent_collection_in_progress) {
                g_print ("finishing concurrent collection\n");
-               if (major_update_or_finish_concurrent_collection (generation_to_collect == GENERATION_OLD))
+               if (major_update_or_finish_concurrent_collection (generation_to_collect == GENERATION_OLD)) {
+                       oldest_generation_collected = GENERATION_OLD;
                        goto done;
+               }
        }
 
        //FIXME extract overflow reason
@@ -3233,6 +3238,8 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
 
                /* keep events symmetric */
                mono_profiler_gc_event (MONO_GC_EVENT_END, overflow_generation_to_collect);
+
+               oldest_generation_collected = MAX (oldest_generation_collected, overflow_generation_to_collect);
        }
 
        SGEN_LOG (2, "Heap size: %lu, LOS size: %lu", (unsigned long)mono_gc_get_heap_size (), (unsigned long)los_memory_usage);
@@ -3249,7 +3256,7 @@ sgen_perform_collection (size_t requested_size, int generation_to_collect, const
        g_assert (sgen_gray_object_queue_is_empty (&gray_queue));
        g_assert (sgen_gray_object_queue_is_empty (&remember_major_objects_gray_queue));
 
-       sgen_restart_world (generation_to_collect, infos);
+       sgen_restart_world (oldest_generation_collected, infos);
 
        mono_profiler_gc_event (MONO_GC_EVENT_END, generation_to_collect);
 }
@@ -4956,7 +4963,7 @@ mono_gc_base_init (void)
        }
 
        if (major_collector.post_param_init)
-               major_collector.post_param_init ();
+               major_collector.post_param_init (&major_collector);
 
        sgen_memgov_init (max_heap, soft_limit, debug_print_allowance, allowance_ratio, save_target);
 
index 15d730a0183483f2dff442e363263851d400d2cf..61b1382ef77017e719743acec70237f4d2ae7600 100644 (file)
@@ -671,6 +671,7 @@ struct _SgenMajorCollector {
        gboolean is_parallel;
        gboolean is_concurrent;
        gboolean supports_cardtable;
+       gboolean sweeps_lazily;
 
        /*
         * This is set to TRUE if the sweep for the last major
@@ -713,7 +714,7 @@ struct _SgenMajorCollector {
        gboolean (*handle_gc_param) (const char *opt);
        void (*print_gc_param_usage) (void);
        gboolean (*is_worker_thread) (MonoNativeThreadId thread);
-       void (*post_param_init) (void);
+       void (*post_param_init) (SgenMajorCollector *collector);
        void* (*alloc_worker_data) (void);
        void (*init_worker_thread) (void *data);
        void (*reset_worker_data) (void *data);
index 03fd1020b854720d2fc6221eab2a72ca65d77dfa..db3de651bb377f3cf0d9b15dafc4066ce343c10b 100644 (file)
@@ -1833,6 +1833,8 @@ major_start_major_collection (void)
        if (lazy_sweep) {
                MSBlockInfo **iter;
 
+               MONO_GC_SWEEP_BEGIN (GENERATION_OLD, TRUE);
+
                iter = &all_blocks;
                while (*iter) {
                        MSBlockInfo *block = *iter;
@@ -1841,6 +1843,8 @@ major_start_major_collection (void)
 
                        iter = &block->next;
                }
+
+               MONO_GC_SWEEP_END (GENERATION_OLD, TRUE);
        }
 }
 
@@ -2290,7 +2294,7 @@ major_reset_worker_data (void *data)
 #undef pthread_create
 
 static void
-post_param_init (void)
+post_param_init (SgenMajorCollector *collector)
 {
        if (concurrent_sweep) {
                if (!mono_native_thread_create (&ms_sweep_thread, ms_sweep_thread_func, NULL)) {
@@ -2298,6 +2302,8 @@ post_param_init (void)
                        exit (1);
                }
        }
+
+       collector->sweeps_lazily = lazy_sweep;
 }
 
 void
index 1a845c91e9552b6574726c11e27abdb3875e8102..7543d894d31c1487865304cfbacbbdbf12814cd7 100644 (file)
@@ -251,7 +251,7 @@ sgen_restart_world (int generation, GGTimingInfo *timing)
        if (G_UNLIKELY (mono_profiler_events & MONO_PROFILE_GC_MOVES))
                sgen_gc_event_moves ();
        mono_profiler_gc_event (MONO_GC_EVENT_PRE_START_WORLD, generation);
-       MONO_GC_WORLD_RESTART_BEGIN ();
+       MONO_GC_WORLD_RESTART_BEGIN (generation);
        FOREACH_THREAD (info) {
                info->stack_start = NULL;
 #ifdef USE_MONO_CTX
@@ -270,7 +270,7 @@ sgen_restart_world (int generation, GGTimingInfo *timing)
        max_pause_usec = MAX (usec, max_pause_usec);
        SGEN_LOG (2, "restarted %d thread(s) (pause time: %d usec, max: %d)", count, (int)usec, (int)max_pause_usec);
        mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD, generation);
-       MONO_GC_WORLD_RESTART_END ();
+       MONO_GC_WORLD_RESTART_END (generation);
 
        bridge_process (generation);