Skip to content

Commit

Permalink
Use new counters for gc counter.
Browse files Browse the repository at this point in the history
  • Loading branch information
kumpera committed Mar 18, 2014
1 parent 4003c6b commit 2f00691
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions mono/metadata/gc.c
Expand Up @@ -1135,8 +1135,8 @@ mono_gc_init (void)
MONO_GC_REGISTER_ROOT_FIXED (gc_handles [HANDLE_PINNED].entries);

mono_counters_register ("Created object count", MONO_COUNTER_GC | MONO_COUNTER_ULONG, &mono_stats.new_object_count);
mono_counters_register ("Minor GC collections", MONO_COUNTER_GC | MONO_COUNTER_INT, &gc_stats.minor_gc_count);
mono_counters_register ("Major GC collections", MONO_COUNTER_GC | MONO_COUNTER_INT, &gc_stats.major_gc_count);
// mono_counters_register ("Minor GC collections", MONO_COUNTER_GC | MONO_COUNTER_INT, &gc_stats.minor_gc_count);
// mono_counters_register ("Major GC collections", MONO_COUNTER_GC | MONO_COUNTER_INT, &gc_stats.major_gc_count);
mono_counters_register ("Minor GC time", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &gc_stats.minor_gc_time_usecs);

This comment has been minimized.

Copy link
@vargaz

vargaz Mar 19, 2014

Contributor

These could be removed.

mono_counters_register ("Major GC time", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &gc_stats.major_gc_time_usecs);

Expand Down
12 changes: 11 additions & 1 deletion mono/metadata/sgen-gc.c
Expand Up @@ -218,7 +218,7 @@
#include "utils/mono-mmap.h"
#include "utils/mono-time.h"
#include "utils/mono-semaphore.h"
#include "utils/mono-counters.h"
#include "utils/mono-counters-internals.h"
#include "utils/mono-proclib.h"
#include "utils/mono-memory-model.h"
#include "utils/mono-logger-internal.h"
Expand Down Expand Up @@ -354,6 +354,10 @@ static long long time_major_fragment_creation = 0;
int gc_debug_level = 0;
FILE* gc_debug_file;

/* New style counters */
static int *major_gc_count;
static int *minor_gc_count;

/*
void
mono_gc_flush_info (void)
Expand Down Expand Up @@ -2212,6 +2216,9 @@ init_stats (void)
if (inited)
return;

minor_gc_count = mono_counters_new_int (MONO_COUNTER_CAT_GC, "Minor GC collections", MONO_COUNTER_UNIT_EVENTS, MONO_COUNTER_UNIT_MONOTONIC);
major_gc_count = mono_counters_new_int (MONO_COUNTER_CAT_GC, "Major GC collections", MONO_COUNTER_UNIT_EVENTS, MONO_COUNTER_UNIT_MONOTONIC);

mono_counters_register ("Minor fragment clear", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_pre_collection_fragment_clear);
mono_counters_register ("Minor pinning", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_pinning);
mono_counters_register ("Minor scan remembered set", MONO_COUNTER_GC | MONO_COUNTER_TIME_INTERVAL, &time_minor_scan_remsets);
Expand Down Expand Up @@ -2579,6 +2586,7 @@ collect_nursery (SgenGrayQueue *unpin_queue, gboolean finish_up_concurrent_mark)

stat_minor_gcs++;
gc_stats.minor_gc_count ++;
mono_counters_inc (minor_gc_count);

MONO_GC_CHECKPOINT_1 (GENERATION_NURSERY);

Expand Down Expand Up @@ -3074,6 +3082,7 @@ major_start_collection (gboolean concurrent, int *old_next_pin_slot)
binary_protocol_collection_begin (stat_major_gcs, GENERATION_OLD);

current_collection_generation = GENERATION_OLD;

#ifndef DISABLE_PERFCOUNTERS
mono_perfcounters->gc_collections1++;
#endif
Expand Down Expand Up @@ -3104,6 +3113,7 @@ major_start_collection (gboolean concurrent, int *old_next_pin_slot)
SGEN_LOG (1, "Start major collection %d", stat_major_gcs);
stat_major_gcs++;
gc_stats.major_gc_count ++;
mono_counters_inc (major_gc_count);

if (major_collector.start_major_collection)
major_collector.start_major_collection ();
Expand Down
11 changes: 6 additions & 5 deletions mono/utils/mono-counters-internals.h
Expand Up @@ -11,11 +11,9 @@ typedef enum {
MONO_COUNTER_CAT_GENERICS,
MONO_COUNTER_CAT_SECURITY,

MONO_COUNTER_CAT_REMOTING,
MONO_COUNTER_CAT_EXC,
MONO_COUNTER_CAT_THREAD,
MONO_COUNTER_CAT_THREADPOOL,
MONO_COUNTER_CAT_IO,
MONO_COUNTER_CAT_SYS,
} MonoCounterCategory;

typedef enum {
Expand All @@ -29,10 +27,11 @@ typedef enum {

typedef enum {
MONO_COUNTER_UNIT_NONE, /* It's a raw value that needs special handling from the consumer */
MONO_COUNTER_UNIT_QUANTITY, /* Quantity of the given counter */
MONO_COUNTER_UNIT_BYTES, /* Quantity of bytes the counter represent */
MONO_COUNTER_UNIT_TIME, /* This is a timestap in 100n units */
MONO_COUNTER_UNIT_EVENT, /* Number of times the given event happens */
MONO_COUNTER_UNIT_EVENTS, /* Number of times the given event happens */
MONO_COUNTER_UNIT_CONFIG, /* Configuration knob of the runtime */
MONO_COUNTER_UNIT_PERCENTAGE, /* Percentage of something */
} MonoCounterUnit;

typedef enum {
Expand Down Expand Up @@ -68,5 +67,7 @@ mono_counters_register_full (MonoCounterCategory category, const char *name, Mon
#define mono_counters_new_long_const(cat,name,unit,value) do { gint64 *__ptr = mono_counters_new(cat,name,MONO_COUNTER_TYPE_INT,unit,variance); *__ptr = value; } while (0)
#define mono_counters_new_double_const(cat,name,unit,value) do { double *__ptr = mono_counters_new(cat,name,MONO_COUNTER_TYPE_INT,unit,variance); *__ptr = value; } while (0)

#define mono_counters_inc(counter_ptr) do { *(counter_ptr) += 1; } while(0)
#define mono_counters_add(counter_ptr, val) do { *(counter_ptr) += val; } while(0)

#endif

0 comments on commit 2f00691

Please sign in to comment.