From 44b1144ed17857619cb75a13030d9c8619e84408 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Fri, 18 Apr 2014 18:12:03 -0400 Subject: [PATCH] [counters] Introduce variance and units. --- mono/utils/mono-counters.c | 14 +++++++++++++- mono/utils/mono-counters.h | 22 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/mono/utils/mono-counters.c b/mono/utils/mono-counters.c index bdd64db58c7..b1258b24d63 100644 --- a/mono/utils/mono-counters.c +++ b/mono/utils/mono-counters.c @@ -20,6 +20,18 @@ static MonoCounter *counters = NULL; static int valid_mask = 0; static int set_mask = 0; +static int +mono_counter_get_variance (MonoCounter *counter) +{ + return counter->type & MONO_COUNTER_VARIANCE_MASK; +} + +static int +mono_counter_get_unit (MonoCounter *counter) +{ + return counter->type & MONO_COUNTER_UNIT_MASK; +} + /** * mono_counters_enable: * @section_mask: a mask listing the sections that will be displayed @@ -170,7 +182,7 @@ mono_counters_dump_section (int section, FILE *outfile) { MonoCounter *counter = counters; while (counter) { - if (counter->type & section) + if (counter->type & section && mono_counter_get_variance (counter) == MONO_COUNTER_MONOTONIC) dump_counter (counter, outfile); counter = counter->next; } diff --git a/mono/utils/mono-counters.h b/mono/utils/mono-counters.h index 3c02893e282..36420a18a6a 100644 --- a/mono/utils/mono-counters.h +++ b/mono/utils/mono-counters.h @@ -5,6 +5,7 @@ #include enum { + /* Counter type, bits 0-7. */ MONO_COUNTER_INT, /* 32 bit int */ MONO_COUNTER_UINT, /* 32 bit uint */ MONO_COUNTER_WORD, /* pointer-sized int */ @@ -16,7 +17,7 @@ enum { MONO_COUNTER_TYPE_MASK = 0xf, MONO_COUNTER_CALLBACK = 128, /* ORed with the other values */ MONO_COUNTER_SECTION_MASK = 0xffffff00, - /* sections */ + /* Sections, bits 8-15 */ MONO_COUNTER_JIT = 1 << 8, MONO_COUNTER_GC = 1 << 9, MONO_COUNTER_METADATA = 1 << 10, @@ -24,7 +25,24 @@ enum { MONO_COUNTER_SECURITY = 1 << 12, MONO_COUNTER_RUNTIME = 1 << 13, MONO_COUNTER_SYSTEM = 1 << 14, - MONO_COUNTER_LAST_SECTION + MONO_COUNTER_LAST_SECTION, + + /* Unit, bits 16-23 */ + MONO_COUNTER_UNIT_SHIFT = 16, + MONO_COUNTER_UNIT_MASK = 0xFFu << MONO_COUNTER_UNIT_SHIFT, + MONO_COUNTER_RAW = 0 << 16, /* Raw value */ + MONO_COUNTER_BYTES = 1 << 16, /* Quantity of bytes. RSS, active heap, etc */ + MONO_COUNTER_TIME = 2 << 16, /* Time interval in 100ns units. Minor pause, JIT compilation*/ + MONO_COUNTER_EVENTS = 3 << 16, /* Number of times the given event happens. Major collections, Compiled methods. */ + MONO_COUNTER_ITEMS = 4 << 16, /* Current number of things. Threads, queued jobs.*/ + MONO_COUNTER_PERCENTAGE = 5 << 16, /* [0-1] Fraction Percentage of something. Load average. */ + + /* Monotonicity, bits 24-31 */ + MONO_COUNTER_VARIANCE_SHIFT = 24, + MONO_COUNTER_VARIANCE_MASK = 0xFFu << MONO_COUNTER_VARIANCE_SHIFT, + MONO_COUNTER_MONOTONIC = 0 << 24, /* This counter value always increase/decreases over time. Reported by --stat. */ + MONO_COUNTER_CONSTANT = 1 << 24, /* Fixed value. Used by configuration data. */ + MONO_COUNTER_VARIABLE = 2 << 24, /* This counter value can be anything on each sampling. Only interesting when sampling. */ }; MONO_API void mono_counters_enable (int section_mask); -- GitLab