Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add collection logging to sgen.
  • Loading branch information
kumpera committed Sep 6, 2011
1 parent 9934944 commit 05550e7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
37 changes: 35 additions & 2 deletions mono/metadata/sgen-gc.c
Expand Up @@ -216,6 +216,7 @@
#include "utils/mono-semaphore.h"
#include "utils/mono-counters.h"
#include "utils/mono-proclib.h"
#include "utils/mono-logger-internal.h"

#include <mono/utils/memcheck.h>

Expand Down Expand Up @@ -521,6 +522,12 @@ static mword memory_pressure = 0;
static mword minor_collection_allowance;
static int minor_collection_sections_alloced = 0;


/* GC Logging stats */
static int last_major_num_sections = 0;
static int last_los_memory_usage = 0;
static gboolean major_collection_hapenned = FALSE;

static GCMemSection *nursery_section = NULL;
static mword lowest_heap_address = ~(mword)0;
static mword highest_heap_address = 0;
Expand Down Expand Up @@ -3434,6 +3441,7 @@ major_collection (const char *reason)
return;
}

major_collection_hapenned = TRUE;
current_collection_generation = GENERATION_OLD;
major_do_collection (reason);
current_collection_generation = -1;
Expand Down Expand Up @@ -5330,17 +5338,22 @@ stop_world (int generation)
g_assert (count >= 0);
DEBUG (3, fprintf (gc_debug_file, "world stopped %d thread(s)\n", count));
mono_profiler_gc_event (MONO_GC_EVENT_POST_STOP_WORLD, generation);

last_major_num_sections = major_collector.get_num_major_sections ();
last_los_memory_usage = los_memory_usage;
major_collection_hapenned = FALSE;
return count;
}

/* LOCKING: assumes the GC lock is held */
static int
restart_world (int generation)
{
int count, i;
int count, i, num_major_sections;
SgenThreadInfo *info;
TV_DECLARE (end_sw);
unsigned long usec;
TV_DECLARE (end_bridge);
unsigned long usec, bridge_usec;

/* notify the profiler of the leftovers */
if (G_UNLIKELY (mono_profiler_events & MONO_PROFILE_GC_MOVES)) {
Expand All @@ -5365,6 +5378,26 @@ restart_world (int generation)
max_pause_usec = MAX (usec, max_pause_usec);
DEBUG (2, fprintf (gc_debug_file, "restarted %d thread(s) (pause time: %d usec, max: %d)\n", count, (int)usec, (int)max_pause_usec));
mono_profiler_gc_event (MONO_GC_EVENT_POST_START_WORLD, generation);

TV_GETTIME (end_bridge);
bridge_usec = TV_ELAPSED (end_sw, end_bridge);

num_major_sections = major_collector.get_num_major_sections ();
if (major_collection_hapenned)
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MAJOR: %s pause %.2fms, bridge %.2fms major %dK/%dK los %dK/%dK",
generation ? "" : "(minor overflow)",
(int)usec / 1000.0f, (int)bridge_usec / 1000.0f,
major_collector.section_size * num_major_sections / 1024,
major_collector.section_size * last_major_num_sections / 1024,
los_memory_usage / 1024,
last_los_memory_usage / 1024);
else
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "GC_MINOR: pause %.2fms, bridge %.2fms promoted %dK major %dK los %dK",
(int)usec / 1000.0f, (int)bridge_usec / 1000.0f,
(num_major_sections - last_major_num_sections) * major_collector.section_size / 1024,
major_collector.section_size * num_major_sections / 1024,
los_memory_usage / 1024);

return count;
}

Expand Down
1 change: 0 additions & 1 deletion mono/metadata/sgen-gc.h
Expand Up @@ -832,7 +832,6 @@ struct _LOSObject {

extern LOSObject *los_object_list;
extern mword los_memory_usage;
extern mword last_los_memory_usage;

void mono_sgen_los_free_object (LOSObject *obj) MONO_INTERNAL;
void* mono_sgen_los_alloc_large_inner (MonoVTable *vtable, size_t size) MONO_INTERNAL;
Expand Down

0 comments on commit 05550e7

Please sign in to comment.