Skip to content

Commit

Permalink
[sgen] More information in sweep and world restart DTrace probes.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
schani committed Dec 9, 2012
1 parent 3f011fd commit 48f06fb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 deletions.
8 changes: 4 additions & 4 deletions data/mono.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 12 additions & 5 deletions mono/metadata/sgen-gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion mono/metadata/sgen-gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion mono/metadata/sgen-marksweep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -1841,6 +1843,8 @@ major_start_major_collection (void)

iter = &block->next;
}

MONO_GC_SWEEP_END (GENERATION_OLD, TRUE);
}
}

Expand Down Expand Up @@ -2290,14 +2294,16 @@ 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)) {
fprintf (stderr, "Error: Could not create sweep thread.\n");
exit (1);
}
}

collector->sweeps_lazily = lazy_sweep;
}

void
Expand Down
4 changes: 2 additions & 2 deletions mono/metadata/sgen-stw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down

0 comments on commit 48f06fb

Please sign in to comment.