Changeset: 2ac7a4b71b31 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2ac7a4b71b31
Modified Files:
MonetDB5/mal/mal_resource.c
MonetDB5/modules/mal/tracer.c
MonetDB5/modules/mal/tracer.h
MonetDB5/modules/mal/tracer.mal
gdk/gdk_tracer.c
gdk/gdk_tracer.h
gdk/gdk_utils.c
gdk/gdk_utils.h
sql/scripts/81_tracer.sql
tools/mserver/mserver5.c
Branch: gdk-tracer
Log Message:
Added log level per layer + SQL API - Renamed some functions
diffs (truncated from 730 to 300 lines):
diff --git a/MonetDB5/mal/mal_resource.c b/MonetDB5/mal/mal_resource.c
--- a/MonetDB5/mal/mal_resource.c
+++ b/MonetDB5/mal/mal_resource.c
@@ -129,15 +129,15 @@ MALadmission_claim(Client cntxt, MalBlkP
if ( memorypool > argclaim || stk->workers == 0 ) {
/* If we are low on memory resources, limit the user if he
exceeds his memory budget
* but make sure there is at least one worker thread active */
- if ( 0 && cntxt->memorylimit) {
- if (argclaim + stk->memory > (lng) cntxt->memorylimit *
LL_CONSTANT(1048576)){
- MT_lock_unset(&admissionLock);
- DEBUG(PAR, "Delayed due to lack of session
memory " LLFMT " requested "LLFMT"\n",
- stk->memory, argclaim);
- return -1;
- }
- stk->memory += argclaim;
- }
+ // if ( 0 && cntxt->memorylimit) {
+ // if (argclaim + stk->memory > (lng) cntxt->memorylimit *
LL_CONSTANT(1048576)){
+ // MT_lock_unset(&admissionLock);
+ // DEBUG(PAR, "Delayed due to lack of session
memory " LLFMT " requested "LLFMT"\n",
+ // stk->memory, argclaim);
+ // return -1;
+ // }
+ // stk->memory += argclaim;
+ // }
memorypool -= argclaim;
DEBUG(PAR, "Thread %d pool " LLFMT "claims " LLFMT "\n",
THRgettid(), memorypool, argclaim);
@@ -161,10 +161,11 @@ MALadmission_release(Client cntxt, MalBl
return;
MT_lock_set(&admissionLock);
- if ( 0 && cntxt->memorylimit) {
- DEBUG(PAR, "Return memory to session budget " LLFMT "\n",
stk->memory);
- stk->memory -= argclaim;
- }
+ (void) cntxt;
+ // if ( 0 && cntxt->memorylimit) {
+ // DEBUG(PAR, "Return memory to session budget " LLFMT "\n",
stk->memory);
+ // stk->memory -= argclaim;
+ // }
memorypool += argclaim;
if ( memorypool > (lng) MEMORY_THRESHOLD ){
DEBUG(PAR, "Memorypool reset\n");
diff --git a/MonetDB5/modules/mal/tracer.c b/MonetDB5/modules/mal/tracer.c
--- a/MonetDB5/modules/mal/tracer.c
+++ b/MonetDB5/modules/mal/tracer.c
@@ -25,10 +25,10 @@ TRACERflush_buffer(void)
str
-TRACERset_component_log_level(void *ret, int *comp, int *lvl)
+TRACERset_component_level(void *ret, int *comp, int *lvl)
{
(void) ret;
- GDK_result = GDKtracer_set_component_log_level(comp, lvl);
+ GDK_result = GDKtracer_set_component_level(comp, lvl);
// if(GDK_result == GDK_FAIL)
// throw(TRACER, __FILE__, "%s:%s", __func__, OPERATION_FAILED);
@@ -37,9 +37,32 @@ TRACERset_component_log_level(void *ret,
str
-TRACERreset_component_log_level(int *comp)
+TRACERreset_component_level(int *comp)
+{
+ GDK_result = GDKtracer_reset_component_level(comp);
+ // if(GDK_result == GDK_FAIL)
+ // throw(TRACER, __FILE__, "%s:%s", __func__, OPERATION_FAILED);
+
+ return MAL_SUCCEED;
+}
+
+
+str
+TRACERset_layer_level(void *ret, int *layer, int *lvl)
{
- GDK_result = GDKtracer_reset_component_log_level(comp);
+ (void) ret;
+ GDK_result = GDKtracer_set_layer_level(layer, lvl);
+ // if(GDK_result == GDK_FAIL)
+ // throw(TRACER, __FILE__, "%s:%s", __func__, OPERATION_FAILED);
+
+ return MAL_SUCCEED;
+}
+
+
+str
+TRACERreset_layer_level(int *layer)
+{
+ GDK_result = GDKtracer_reset_layer_level(layer);
// if(GDK_result == GDK_FAIL)
// throw(TRACER, __FILE__, "%s:%s", __func__, OPERATION_FAILED);
diff --git a/MonetDB5/modules/mal/tracer.h b/MonetDB5/modules/mal/tracer.h
--- a/MonetDB5/modules/mal/tracer.h
+++ b/MonetDB5/modules/mal/tracer.h
@@ -13,8 +13,10 @@
#include "mal_interpreter.h"
mal_export str TRACERflush_buffer(void);
-mal_export str TRACERset_component_log_level(void *ret, int *comp, int *lvl);
-mal_export str TRACERreset_component_log_level(int *comp);
+mal_export str TRACERset_component_level(void *ret, int *comp, int *lvl);
+mal_export str TRACERreset_component_level(int *comp);
+mal_export str TRACERset_layer_level(void *ret, int *layer, int *lvl);
+mal_export str TRACERreset_layer_level(int *layer);
mal_export str TRACERset_flush_level(void *ret, int *lvl);
mal_export str TRACERreset_flush_level(void);
mal_export str TRACERset_adapter(void *ret, int *adapter);
diff --git a/MonetDB5/modules/mal/tracer.mal b/MonetDB5/modules/mal/tracer.mal
--- a/MonetDB5/modules/mal/tracer.mal
+++ b/MonetDB5/modules/mal/tracer.mal
@@ -10,13 +10,21 @@ command flush()
address TRACERflush_buffer
comment "Flush GDKtracer buffer";
-command setcomploglevel(comp:int, lvl:int)
-address TRACERset_component_log_level
+command setcomplevel(comp:int, lvl:int)
+address TRACERset_component_level
comment "Set GDKtracer log level for a specific component";
-command resetcomploglevel(comp:int)
-address TRACERreset_component_log_level
-comment "Reset the log level for specific component of GDKtracer";
+command resetcomplevel(comp:int)
+address TRACERreset_component_level
+comment "Reset the log level for specific component";
+
+command setlayerlevel(layer:int, lvl:int)
+address TRACERset_layer_level
+comment "Set GDKtracer log level for a specific layer";
+
+command resetlayerlevel(layer:int)
+address TRACERreset_layer_level
+comment "Reset the log level for specific layer";
command setflushlevel(lvl:int)
address TRACERset_flush_level
diff --git a/gdk/gdk_tracer.c b/gdk/gdk_tracer.c
--- a/gdk/gdk_tracer.c
+++ b/gdk/gdk_tracer.c
@@ -29,21 +29,18 @@
#include "gdk.h"
#include "gdk_tracer.h"
-/* CHECK */
-// Make CUR_FLUSH_LEVEL => ATOMIC_TYPE?
-// 0 -> tracer
-// 1 -> secondary_tracer
static gdk_tracer tracer = { .allocated_size = 0, .id = 0, .lock =
MT_LOCK_INITIALIZER("GDKtracerL") };
static gdk_tracer secondary_tracer = { .allocated_size = 0, .id = 1, .lock =
MT_LOCK_INITIALIZER("GDKtracerL2") };
static ATOMIC_TYPE SELECTED_tracer_ID = 0;
-static bool GDK_TRACER_STOP = false;
-
static FILE *output_file;
static ATOMIC_TYPE CUR_ADAPTER = DEFAULT_ADAPTER;
+
static LOG_LEVEL CUR_FLUSH_LEVEL = DEFAULT_FLUSH_LEVEL;
-LOG_LEVEL LOG_LVL_PER_COMPONENT[COMPONENTS_COUNT];
+LOG_LEVEL LVL_PER_COMPONENT[COMPONENTS_COUNT];
+
+static bool GDK_TRACER_STOP = false;
// Output error from snprintf of vsnprintf
@@ -61,6 +58,32 @@ static void
}
+// Prepares a file in order to write the contents of the buffer when necessary
+static void
+_GDKtracer_create_file(void)
+{
+ char id[INT_MAX_LEN];
+ snprintf(id, INT_MAX_LEN, "%d", 1);
+
+ char file_name[FILENAME_MAX];
+ sprintf(file_name, "%s%c%s%c%s%c%s%s", GDKgetenv("gdk_dbpath"), DIR_SEP,
FILE_NAME, NAME_SEP, GDKtracer_get_timestamp("%Y-%m-%dT%H:%M:%S"), NAME_SEP,
id, ".log");
+
+ output_file = fopen(file_name, "w");
+
+ _GDKtracer_file_is_open(output_file);
+}
+
+
+static void
+_GDKtracer_init_components(void)
+{
+ for(int i = 0; i < COMPONENTS_COUNT; i++)
+ {
+ LVL_PER_COMPONENT[i] = DEFAULT_LOG_LEVEL;
+ }
+}
+
+
static bool
_GDKtracer_adapter_exists(int *adapter)
{
@@ -70,7 +93,7 @@ static bool
if(*adapter >= 0 && *adapter < ADAPTERS_COUNT)
return true;
- return true;
+ return false;
}
@@ -88,42 +111,28 @@ static bool
static bool
+_GDKtracer_layer_exists(int *layer)
+{
+ if(*layer == LAYERS_COUNT)
+ return false;
+
+ if(*layer >= 0 && *layer < LAYERS_COUNT)
+ return true;
+
+ return false;
+}
+
+
+static bool
_GDKtracer_component_exists(int *comp)
{
if(*comp == COMPONENTS_COUNT)
return false;
- if(*comp >= 0 && *comp <= COMPONENTS_COUNT)
+ if(*comp >= 0 && *comp < COMPONENTS_COUNT)
return true;
- return true;
-}
-
-
-static void
-_GDKtracer_init_log_level_per_component(void)
-{
- for(int i = 0; i < COMPONENTS_COUNT; i++)
- {
- LOG_LVL_PER_COMPONENT[i] = DEFAULT_LOG_LEVEL;
- }
-}
-
-
-// Prepares a file in order to write the contents of the buffer
-// when necessary. The file name each time is merovingian_{int}.log
-static void
-_GDKtracer_create_file(void)
-{
- char id[INT_MAX_LEN];
- snprintf(id, INT_MAX_LEN, "%d", 1);
-
- char file_name[FILENAME_MAX];
- sprintf(file_name, "%s%c%s%c%s%c%s%s", GDKgetenv("gdk_dbpath"), DIR_SEP,
FILE_NAME, NAME_SEP, GDKtracer_get_timestamp("%Y-%m-%dT%H:%M:%S"), NAME_SEP,
id, ".log");
-
- output_file = fopen(file_name, "w");
-
- _GDKtracer_file_is_open(output_file);
+ return false;
}
@@ -139,12 +148,13 @@ static int
size_t fmt_len = strlen(fmt);
int bytes_written = 0;
+ // Add \n if it doesn't exist
if(fmt[fmt_len - 1] != NEW_LINE)
{
tmp = GDKmalloc(sizeof(char) * (fmt_len + 2));
strcpy(tmp, fmt);
tmp[fmt_len] = NEW_LINE;
- tmp[fmt_len + 1] = '\0';
+ tmp[fmt_len + 1] = NULL_CHAR;
msg = tmp;
}
else
@@ -168,6 +178,55 @@ static int
}
+static gdk_return
+_GDKtracer_layer_level_helper(int *layer, int *level)
+{
+ char *tmp = NULL;
+ char *tok = NULL;
+ for(int i = 0; i < LAYERS_COUNT; i++)
+ {
+ if(*layer == MDB_ALL)
+ {
+ if(LVL_PER_COMPONENT[i] != *level)
+ LVL_PER_COMPONENT[i] = *level;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list