Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
dedicated file to trace categorized resource utilization
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 23 Sep 2010 09:06:46 +0000 (09:06 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 23 Sep 2010 09:06:46 +0000 (09:06 +0000)
details:
- src/instr/resource_utilization.c
- three methods implemented:
   - A (dumb tracing, all update_actions_state are transformed in two events)
   - B (try to resume the tracing if the utilization value did not change)
         => it produces the same trace as A, resumed if update_actions_state
            do not change the values on all updates
   - C (categorized resource utilization integrated within the scope of a smx_action)

- method A generates a gigantic trace file, B is the solution for MSG, but not for SMPI
- method C is the solution for SMPI, but we lost details on each update
- now, method B is active

todo:
- create an option to select which method to use

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8202 48e7efb5-ca39-0410-a469-dd3cf9ba447f

buildtools/Cmake/DefinePackages.cmake
src/instr/private.h
src/instr/resource_utilization.c [new file with mode: 0644]
src/instr/smx_instr.c
src/instr/surf_instr.c

index 2b5b50b..2c03455 100755 (executable)
@@ -337,6 +337,7 @@ set(TRACING_SRC
        src/instr/surf_instr.c
        src/instr/smpi_instr.c
        src/instr/variables_instr.c
+       src/instr/resource_utilization.c
        src/instr/private.h
 )
 
index e44ed32..1cfdfe4 100644 (file)
@@ -112,17 +112,14 @@ void TRACE_smx_action_destroy (smx_action_t act);
 void __TRACE_surf_init (void);
 void __TRACE_surf_finalize (void);
 void __TRACE_surf_check_variable_set_to_zero (double now, const char *variable, const char *resource);
-void __TRACE_surf_update_action_state_resource (double now, double delta, const char *type, const char *name, double value);
 void __TRACE_surf_set_resource_variable (double date, const char *variable, const char *resource, double value);
 void TRACE_surf_host_declaration (char *name, double power);
 void TRACE_surf_host_set_power (double date, char *resource, double power);
-void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta);
 void TRACE_surf_host_define_id (const char *name, int host_id);
 void TRACE_surf_host_vivaldi_parse (char *host, double x, double y, double h);
 void TRACE_surf_link_declaration (char *name, double bw, double lat);
 void TRACE_surf_link_set_bandwidth (double date, char *resource, double bandwidth);
 void TRACE_surf_link_set_latency (double date, char *resource, double latency);
-void TRACE_surf_link_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta);
 void TRACE_surf_link_save_endpoints (char *link_name, int src, int dst);
 void TRACE_surf_link_missing (void);
 void TRACE_msg_clean (void);
@@ -156,6 +153,14 @@ int _TRACE_msg_volume_enabled (void);
 char *_TRACE_filename (void);
 void TRACE_global_init(int *argc, char **argv);
 
+/* from resource_utilization.c */
+void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta);
+void TRACE_surf_link_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta);
+void __TRACE_surf_resource_utilization_start (smx_action_t action);
+void __TRACE_surf_resource_utilization_event (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value);
+void __TRACE_surf_resource_utilization_end (smx_action_t action);
+void __TRACE_surf_resource_utilization_initialize (void);
+void __TRACE_surf_resource_utilization_finalize (void);
 
 #endif
 
diff --git a/src/instr/resource_utilization.c b/src/instr/resource_utilization.c
new file mode 100644 (file)
index 0000000..7898bea
--- /dev/null
@@ -0,0 +1,423 @@
+/* Copyright (c) 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
+
+/* This program is free software; you can redistribute it and/or modify it
+  * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "instr/private.h"
+
+#ifdef HAVE_TRACING
+
+#define VARIABLE_SEPARATOR '#'
+
+#define METHOD_B
+
+#ifdef METHOD_B
+static xbt_dict_t last_platform_variables; /* to control the amount of add/sub variables events:
+   dict with key {RESOURCE_NAME}#Time or {RESOURCE_NAME}#Value of dict with variables types == string */
+#endif //METHOD_B
+
+#ifdef METHOD_C
+static xbt_dict_t method_c_dict;
+#endif // METHOD_C
+
+/* auxiliary function for resource utilization tracing */
+static char *strsplit (char *input, int field, char del) //caller should free the returned string
+{
+  char *ret = NULL;
+  int length = strlen(input), i;
+  int s = 0, e = length+1;
+  int current_field = 0;
+  for (i = 0; i < length; i++){
+     if (input[i] == del){
+       if (current_field == field){
+         e = i-1;
+         break;
+       }else{
+         s = i+1;
+         current_field++;
+       }
+     }
+  }
+  //copy string from s to e (with length equal to e-s) and return
+  ret = malloc ((e-s+2)*sizeof(char));
+  strncpy (ret, input+s, e-s+1);
+  ret[e-s+1] = '\0';
+  return ret;
+}
+
+#ifdef METHOD_A
+static void __TRACE_surf_resource_utilization_A (double now, double delta, const char *variable, const char *resource, double value)
+{
+  if (!IS_TRACING_PLATFORM) return;
+
+  char valuestr[100];
+  snprintf (valuestr, 100, "%f", value);
+
+  __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
+  pajeAddVariable (now, variable, resource, valuestr);
+  pajeSubVariable (now+delta, variable, resource, valuestr);
+  return;
+}
+#endif //METHOD_A
+
+#ifdef METHOD_B
+static void __TRACE_surf_resource_utilization_initialize_B ()
+{
+  last_platform_variables =  xbt_dict_new();
+}
+
+static void __TRACE_surf_resource_utilization_B (double now, double delta, const char *variable, const char *resource, double value)
+{
+  if (!IS_TRACING_PLATFORM) return;
+
+  char valuestr[100];
+  char nowstr[100], nowdeltastr[100];
+  char timekey[100], valuekey[100], variablekey[100];
+  char *lastvariable = NULL;
+  char *lasttime = NULL;
+  char *lastvalue = NULL;
+  char *nowdeltastr_cpy = NULL;
+  char *valuestr_cpy = NULL;
+  char *variable_cpy = NULL;
+
+  /*
+   * The following code replaces the code above with the objective
+   * to decrease the size of file because of unnecessary add/sub on
+   * variables. It should be re-checked before put in production.
+   */
+
+  snprintf (valuestr, 100, "%f", value);
+  snprintf (nowstr, 100, "%f", now);
+  snprintf (nowdeltastr, 100, "%f", now+delta);
+  snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
+  snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
+  snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
+
+  lastvariable = xbt_dict_get_or_null (last_platform_variables, variablekey);
+  if (lastvariable == NULL){
+    __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
+    pajeAddVariable (now, variable, resource, valuestr);
+    nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+    valuestr_cpy = xbt_strdup (valuestr);
+    variable_cpy = xbt_strdup (variable);
+    xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+    xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
+    xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
+  }else{
+    lasttime = xbt_dict_get_or_null (last_platform_variables, timekey);
+    lastvalue = xbt_dict_get_or_null (last_platform_variables, valuekey);
+
+    /* check if it is the same variable */
+    if (strcmp(lastvariable, variable) == 0){ /* same variable */
+      /* check if lasttime equals now */
+      if (atof(lasttime) == now){ /* lastime == now */
+        /* check if lastvalue equals valuestr */
+        if (atof(lastvalue) == value){ /* lastvalue == value (good, just advance time) */
+          char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+          xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+        }else{ /* value has changed */
+          /* value has changed, subtract previous value, add new one */
+          pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
+          pajeAddVariable (atof(nowstr), variable, resource, valuestr);
+          nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+          valuestr_cpy = xbt_strdup (valuestr);
+          xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+          xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
+        }
+      }else{ /* lasttime != now */
+        /* the last time is different from new starting time, subtract to lasttime and add from nowstr */
+        pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
+        pajeAddVariable (atof(nowstr), variable, resource, valuestr);
+        nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+        valuestr_cpy = xbt_strdup (valuestr);
+        xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+        xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
+      }
+    }else{ /* variable has changed */
+      pajeSubVariable (atof(lasttime), lastvariable, resource, lastvalue);
+      __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
+      pajeAddVariable (now, variable, resource, valuestr);
+      nowdeltastr_cpy = xbt_strdup (nowdeltastr);
+      valuestr_cpy = xbt_strdup (valuestr);
+      variable_cpy = xbt_strdup (variable);
+      xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
+      xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
+      xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
+    }
+  }
+  return;
+}
+
+static void __TRACE_surf_resource_utilization_finalize_B ()
+{
+  xbt_dict_cursor_t cursor = NULL;
+  unsigned int cursor_ar = 0;
+    char *key, *value, *res;
+    char *resource;
+    char *aux = NULL;
+    char *var_cpy = NULL;
+    xbt_dynar_t resources = NULL;
+  if (!IS_TRACING_PLATFORM) return;
+  if (!xbt_dict_length(last_platform_variables)){
+    return;
+  }else{
+    /* get all resources from last_platform_variables */
+    resources = xbt_dynar_new(sizeof(char*), xbt_free);
+    xbt_dict_foreach(last_platform_variables, cursor, key, value) {
+      res = strsplit (key, 0, VARIABLE_SEPARATOR);
+      aux = strsplit (key, 1, VARIABLE_SEPARATOR);
+      if (strcmp (aux, "Time") == 0){ //only need to add one of three
+        var_cpy = xbt_strdup (res);
+        xbt_dynar_push (resources, &var_cpy);
+      }
+      free (aux);
+      free (res);
+    }
+
+    /* iterate through resources array */
+    xbt_dynar_foreach (resources, cursor_ar, resource) {
+      char timekey[100], valuekey[100], variablekey[100];
+      char *time = NULL;
+      char *value = NULL;
+      char *variable = NULL;
+      snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
+      snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
+      snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
+
+      time = xbt_dict_get_or_null (last_platform_variables, timekey);
+      if (!time) continue;
+      value = xbt_dict_get (last_platform_variables, valuekey);
+      variable = xbt_dict_get (last_platform_variables, variablekey);
+      pajeSubVariable (atof(time), variable, resource, value);
+
+      xbt_dict_remove (last_platform_variables, timekey);
+      xbt_dict_remove (last_platform_variables, valuekey);
+      xbt_dict_remove (last_platform_variables, variablekey);
+    }
+  }
+}
+#endif //METHOD_B
+
+
+#ifdef METHOD_C
+static void __TRACE_surf_resource_utilization_start_C (smx_action_t action)
+{
+  char key[100];
+  snprintf (key, 100, "%p", action);
+
+  //check if exists
+  if (xbt_dict_get_or_null (method_c_dict, key)){
+    xbt_dict_remove (method_c_dict, key); //should never execute here, but it does
+  }
+  xbt_dict_set (method_c_dict, key, xbt_dict_new(), xbt_free);
+
+  //fprintf (stderr, "start %p\n", action);
+  /*
+
+  if (xbt_dict_get_or_null (start_time, key)){
+    xbt_dict_remove (start_time, key);
+  }
+  */
+}
+
+static void __TRACE_surf_resource_utilization_end_C (smx_action_t action)
+{
+  char key[100];
+  snprintf (key, 100, "%p", action);
+
+  xbt_dict_t action_dict = xbt_dict_get (method_c_dict, key);
+//  fprintf (stderr, "end %p (%f - %f)\n", action, atof(xbt_dict_get_or_null(action_dict, "start")),
+//                                                 atof(xbt_dict_get_or_null(action_dict, "end")));
+
+  double start_time = atof(xbt_dict_get (action_dict, "start"));
+  double end_time = atof(xbt_dict_get (action_dict, "end"));
+
+  xbt_dict_cursor_t cursor=NULL;
+  char *action_dict_key, *action_dict_value;
+  xbt_dict_foreach(action_dict,cursor,action_dict_key,action_dict_value) {
+    char resource[100], variable[100];
+    if (sscanf (action_dict_key, "%s %s", resource, variable) != 2) continue;
+    __TRACE_surf_check_variable_set_to_zero (start_time, variable, resource);
+    char value_str[100];
+    if(end_time-start_time != 0){
+      snprintf (value_str, 100, "%f", atof(action_dict_value)/(end_time-start_time));
+      pajeAddVariable (start_time, variable, resource, value_str);
+      pajeSubVariable (end_time, variable, resource, value_str);
+    }
+
+    //fprintf(stderr, "\t%p (key=%s) %s %s = %s\n",action, action_dict_key, resource, variable, action_dict_value);
+    //fprintf(stderr, "\t%f %f\n", start_time, end_time);
+  }
+  //fprintf (stderr, "\n");
+
+  xbt_dict_remove (method_c_dict, key);
+  /*
+
+  if (xbt_dict_get_or_null (start_time_dict, key)){
+    xbt_dict_remove (start_time_dict, key);
+  }
+  if (xbt_dict_get_or_null (end_time_dict, key)){
+    xbt_dict_remove (end_time_dict, key);
+  }
+  */
+
+}
+
+static void __TRACE_surf_resource_utilization_C (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value)
+{
+  char key[100];
+  snprintf (key, 100, "%p", action);
+
+  xbt_dict_t action_dict = xbt_dict_get (method_c_dict, key);
+  //setting start time
+  if (!xbt_dict_get_or_null (action_dict, "start")){
+    char start_time[100];
+    snprintf (start_time, 100, "%f", now);
+    xbt_dict_set (action_dict, "start", xbt_strdup (start_time), xbt_free);
+  }
+  //updating end time
+  char end_time[100];
+  snprintf (end_time, 100, "%f", now+delta);
+  xbt_dict_set (action_dict, "end", xbt_strdup (end_time), xbt_free);
+
+  //accumulate the value resource-variable
+  char res_var[300];
+  snprintf (res_var, 300, "%s %s", resource, variable);
+  double current_value_f;
+  char *current_value = xbt_dict_get_or_null (action_dict, res_var);
+  if (current_value){
+    current_value_f = atof (current_value);
+    current_value_f += value*delta;
+  }else{
+    current_value_f = value*delta;
+  }
+  char new_current_value[100];
+  snprintf (new_current_value, 100, "%f", current_value_f);
+  xbt_dict_set (action_dict, res_var, xbt_strdup (new_current_value), xbt_free);
+
+  //fprintf (stderr, "event act=%p, now=%f, delta=%f, %s - %s %f\n", action, now, delta, resource, variable, value);
+}
+
+static void __TRACE_surf_resource_utilization_initialize_C ()
+{
+  //start_time_dict = xbt_dict_new();
+  //end_time_dict = xbt_dict_new();
+  method_c_dict = xbt_dict_new();
+}
+
+static void __TRACE_surf_resource_utilization_finalize_C ()
+{
+  xbt_dict_free (&method_c_dict);
+}
+#endif //METHOD_C
+
+
+
+/*
+ * TRACE_surf_link_set_utilization: entry point from SimGrid
+ */
+void TRACE_surf_link_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta)
+{
+  char type[100];
+  if (!IS_TRACING || !IS_TRACED(smx_action)) return;
+
+  if (strcmp (name, "__loopback__")==0 ||
+      strcmp (name, "loopback")==0){ //ignore loopback updates
+    return;
+  }
+
+  if (value == 0) return;
+
+  //if (!xbt_dict_get_or_null (created_links, name)){
+//    TRACE_surf_link_missing ();
+    //return;
+  //}
+
+  snprintf (type, 100, "b%s", smx_action->category);
+  __TRACE_surf_resource_utilization_event (smx_action, now, delta, type, name, value);
+//fprintf (stderr, "%p - (%f - %f = %f) %s %f metric = %f\n", smx_action, now, now+delta, delta, name, value, value*delta);
+//  __TRACE_surf_update_action_state_resource (now, delta, type, name, value);
+  return;
+}
+
+/*
+ * TRACE_surf_host_set_utilization: entry point from SimGrid
+ */
+void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta)
+{
+  char type[100];
+  if (!IS_TRACING || !IS_TRACED(smx_action)) return;
+
+  if (value==0){
+    return;
+  }
+  snprintf (type, 100, "p%s", smx_action->category);
+  __TRACE_surf_resource_utilization_event (smx_action, now, delta, type, name, value);
+//fprintf (stderr, "%p - (%f - %f = %f) %s %f metric = %f\n", smx_action, now, now+delta, delta, name, value, value*delta);
+//  __TRACE_surf_update_action_state_resource (now, delta, type, name, value);
+  return;
+}
+
+/*
+ * __TRACE_surf_resource_utilization_*: entry points from tracing functions
+ */
+void __TRACE_surf_resource_utilization_start (smx_action_t action)
+{
+#ifdef METHOD_C
+  __TRACE_surf_resource_utilization_start_C (action);
+#endif
+}
+
+void __TRACE_surf_resource_utilization_end (smx_action_t action)
+{
+#ifdef METHOD_C
+  __TRACE_surf_resource_utilization_end_C (action);
+#endif
+}
+
+void __TRACE_surf_resource_utilization_event (smx_action_t action, double now, double delta, const char *variable, const char *resource, double value)
+{
+#ifdef METHOD_A
+  __TRACE_surf_resource_utilization_A (now, delta, variable, resource, value);
+#else
+  #ifdef METHOD_B
+  __TRACE_surf_resource_utilization_B (now, delta, variable, resource, value);
+  #else
+    #ifdef METHOD_C
+    __TRACE_surf_resource_utilization_C (action, now, delta, variable, resource, value);
+    #endif
+  #endif
+#endif
+}
+
+void __TRACE_surf_resource_utilization_initialize ()
+{
+#ifdef METHOD_A
+#else
+  #ifdef METHOD_B
+  __TRACE_surf_resource_utilization_initialize_B();
+  #else
+    #ifdef METHOD_C
+    __TRACE_surf_resource_utilization_initialize_C();
+    #endif
+  #endif
+#endif
+}
+
+void __TRACE_surf_resource_utilization_finalize ()
+{
+#ifdef METHOD_A
+#else
+  #ifdef METHOD_B
+  __TRACE_surf_resource_utilization_finalize_B();
+  #else
+    #ifdef METHOD_C
+    __TRACE_surf_resource_utilization_finalize_C();
+    #endif
+  #endif
+#endif
+}
+
+
+#endif
index 3d2870a..229b15b 100644 (file)
@@ -21,6 +21,7 @@ void TRACE_smx_action_execute (smx_action_t act)
     act->category = xbt_new (char, strlen (category)+1);
     strncpy (act->category, category, strlen(category)+1);
   }
+  __TRACE_surf_resource_utilization_start (act);
 }
 
 void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
@@ -33,6 +34,7 @@ void TRACE_smx_action_communicate (smx_action_t act, smx_process_t proc)
   if (category){
     act->category = xbt_strdup (category);
   }
+  __TRACE_surf_resource_utilization_start (act);
 }
 
 void TRACE_smx_action_destroy (smx_action_t act)
@@ -42,6 +44,7 @@ void TRACE_smx_action_destroy (smx_action_t act)
   if (act->category){
     xbt_free (act->category);
   }
+  __TRACE_surf_resource_utilization_end (act);
 }
 
 #endif
index 61b703d..66ce712 100644 (file)
@@ -20,9 +20,6 @@ static xbt_dict_t link_bandwidth; //name(char*) -> bandwidth(double)
 static xbt_dict_t link_latency;   //name(char*) -> latency(double)
 static xbt_dict_t host_containers;
 
-static xbt_dict_t last_platform_variables; /* to control the amount of add/sub variables events:
-   dict with key {RESOURCE_NAME}#Time or {RESOURCE_NAME}#Value of dict with variables types == string */
-
 static xbt_dict_t platform_variables; /* host or link name -> array of categories */
 
 static xbt_dict_t resource_variables; /* (host|link)#variable -> value */
@@ -40,83 +37,15 @@ void __TRACE_surf_init (void)
   link_latency = xbt_dict_new();
   platform_variables = xbt_dict_new();
   host_containers = xbt_dict_new();
-  last_platform_variables =  xbt_dict_new();
   resource_variables = xbt_dict_new ();
   gtnets_src = xbt_dict_new ();
   gtnets_dst = xbt_dict_new ();
-}
-
-static char *strsplit (char *input, int field, char del) //caller should free the returned string
-{
-       char *ret = NULL;
-  int length = strlen(input), i;
-  int s = 0, e = length+1;
-  int current_field = 0;
-  for (i = 0; i < length; i++){
-     if (input[i] == del){
-       if (current_field == field){
-         e = i-1;
-         break;
-       }else{
-         s = i+1;
-         current_field++;
-       }
-     }
-  }
-  //copy string from s to e (with length equal to e-s) and return
-  ret = malloc ((e-s+2)*sizeof(char));
-  strncpy (ret, input+s, e-s+1);
-  ret[e-s+1] = '\0';
-  return ret;
+  __TRACE_surf_resource_utilization_initialize();
 }
 
 void __TRACE_surf_finalize (void)
 {
-       xbt_dict_cursor_t cursor = NULL;
-       unsigned int cursor_ar = 0;
-    char *key, *value, *res;
-    char *resource;
-    char *aux = NULL;
-    char *var_cpy = NULL;
-    xbt_dynar_t resources = NULL;
-  if (!IS_TRACING_PLATFORM) return;
-  if (!xbt_dict_length(last_platform_variables)){
-    return;
-  }else{
-    /* get all resources from last_platform_variables */
-    resources = xbt_dynar_new(sizeof(char*), xbt_free);
-    xbt_dict_foreach(last_platform_variables, cursor, key, value) {
-      res = strsplit (key, 0, VARIABLE_SEPARATOR);
-      aux = strsplit (key, 1, VARIABLE_SEPARATOR);
-      if (strcmp (aux, "Time") == 0){ //only need to add one of three
-        var_cpy = xbt_strdup (res);
-        xbt_dynar_push (resources, &var_cpy);
-      }
-      free (aux);
-      free (res);
-    }
-
-    /* iterate through resources array */
-    xbt_dynar_foreach (resources, cursor_ar, resource) {
-      char timekey[100], valuekey[100], variablekey[100];
-      char *time = NULL;
-      char *value = NULL;
-      char *variable = NULL;
-      snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
-      snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
-      snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
-
-      time = xbt_dict_get_or_null (last_platform_variables, timekey);
-      if (!time) continue;
-      value = xbt_dict_get (last_platform_variables, valuekey);
-      variable = xbt_dict_get (last_platform_variables, variablekey);
-      pajeSubVariable (atof(time), variable, resource, value);
-
-      xbt_dict_remove (last_platform_variables, timekey);
-      xbt_dict_remove (last_platform_variables, valuekey);
-      xbt_dict_remove (last_platform_variables, variablekey);
-    }
-  }
+  __TRACE_surf_resource_utilization_finalize();
 }
 
 void __TRACE_surf_check_variable_set_to_zero (double now, const char *variable, const char *resource)
@@ -147,100 +76,6 @@ void __TRACE_surf_check_variable_set_to_zero (double now, const char *variable,
   /* end of check */
 }
 
-void __TRACE_surf_update_action_state_resource (double now, double delta, const char *variable, const char *resource, double value)
-{
-       char valuestr[100];
-       char nowstr[100], nowdeltastr[100];
-       char timekey[100], valuekey[100], variablekey[100];
-       char *lastvariable = NULL;
-       char *lasttime = NULL;
-    char *lastvalue = NULL;
-    char *nowdeltastr_cpy = NULL;
-    char *valuestr_cpy = NULL;
-    char *variable_cpy = NULL;
-
-  if (!IS_TRACING_PLATFORM) return;
-
-  snprintf (valuestr, 100, "%f", value);
-
-  /*
-  //fprintf (stderr, "resource = %s variable = %s (%f -> %f) value = %s\n", resource, variable, now, now+delta, valuestr);
-  if (1){
-    __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
-    if (IS_TRACING_PLATFORM) pajeAddVariable (now, variable, resource, valuestr);
-    if (IS_TRACING_PLATFORM) pajeSubVariable (now+delta, variable, resource, valuestr);
-    return;
-  }
-  */
-
-  /*
-   * The following code replaces the code above with the objective
-   * to decrease the size of file because of unnecessary add/sub on
-   * variables. It should be re-checked before put in production.
-   */
-
-  snprintf (nowstr, 100, "%.15f", now);
-  snprintf (nowdeltastr, 100, "%.15f", now+delta);
-
-  snprintf (timekey, 100, "%s%cTime", resource, VARIABLE_SEPARATOR);
-  snprintf (valuekey, 100, "%s%cValue", resource, VARIABLE_SEPARATOR);
-  snprintf (variablekey, 100, "%s%cVariable", resource, VARIABLE_SEPARATOR);
-
-  lastvariable = xbt_dict_get_or_null (last_platform_variables, variablekey);
-  if (lastvariable == NULL){
-    __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
-    pajeAddVariable (now, variable, resource, valuestr);
-    nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-    valuestr_cpy = xbt_strdup (valuestr);
-    variable_cpy = xbt_strdup (variable);
-    xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
-    xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
-    xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
-  }else{
-    lasttime = xbt_dict_get_or_null (last_platform_variables, timekey);
-    lastvalue = xbt_dict_get_or_null (last_platform_variables, valuekey);
-
-    /* check if it is the same variable */
-    if (strcmp(lastvariable, variable) == 0){ /* same variable */
-      /* check if lasttime equals now */
-      if (atof(lasttime) == now){ /* lastime == now */
-        /* check if lastvalue equals valuestr */
-        if (atof(lastvalue) == value){ /* lastvalue == value (good, just advance time) */
-          char *nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-          xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
-        }else{ /* value has changed */
-          /* value has changed, subtract previous value, add new one */
-          pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
-          pajeAddVariable (atof(nowstr), variable, resource, valuestr);
-          nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-          valuestr_cpy = xbt_strdup (valuestr);
-          xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
-          xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
-        }
-      }else{ /* lasttime != now */
-        /* the last time is different from new starting time, subtract to lasttime and add from nowstr */
-        pajeSubVariable (atof(lasttime), variable, resource, lastvalue);
-        pajeAddVariable (atof(nowstr), variable, resource, valuestr);
-        nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-        valuestr_cpy = xbt_strdup (valuestr);
-        xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
-        xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
-      }
-    }else{ /* variable has changed */
-      pajeSubVariable (atof(lasttime), lastvariable, resource, lastvalue);
-      __TRACE_surf_check_variable_set_to_zero (now, variable, resource);
-      pajeAddVariable (now, variable, resource, valuestr);
-      nowdeltastr_cpy = xbt_strdup (nowdeltastr);
-      valuestr_cpy = xbt_strdup (valuestr);
-      variable_cpy = xbt_strdup (variable);
-      xbt_dict_set (last_platform_variables, timekey, nowdeltastr_cpy, xbt_free);
-      xbt_dict_set (last_platform_variables, valuekey, valuestr_cpy, xbt_free);
-      xbt_dict_set (last_platform_variables, variablekey, variable_cpy, xbt_free);
-    }
-  }
-  return;
-}
-
 void __TRACE_surf_set_resource_variable (double date, const char *variable, const char *resource, double value)
 {
        char aux[100], key[100];
@@ -259,42 +94,6 @@ void __TRACE_surf_set_resource_variable (double date, const char *variable, cons
   xbt_dict_set (resource_variables, xbt_strdup(key), xbt_strdup(aux), xbt_free);
 }
 
-void TRACE_surf_link_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta)
-{
-       char type[100];
-  if (!IS_TRACING || !IS_TRACED(smx_action)) return;
-
-  if (strcmp (name, "__loopback__")==0 ||
-      strcmp (name, "loopback")==0){ //ignore loopback updates
-    return;
-  }
-
-  if (value == 0) return;
-
-  if (!xbt_dict_get_or_null (created_links, name)){
-    TRACE_surf_link_missing ();
-    return;
-  }
-
-  snprintf (type, 100, "b%s", smx_action->category);
-  __TRACE_surf_update_action_state_resource (now, delta, type, name, value);
-  return;
-}
-
-void TRACE_surf_host_set_utilization (const char *name, smx_action_t smx_action, double value, double now, double delta)
-{
-       char type[100];
-  if (!IS_TRACING || !IS_TRACED(smx_action)) return;
-
-  if (value==0){
-    return;
-  }
-
-  snprintf (type, 100, "p%s", smx_action->category);
-  __TRACE_surf_update_action_state_resource (now, delta, type, name, value);
-  return;
-}
-
 /*
  * TRACE_surf_link_declaration (name, bandwidth, latency): this function
  * saves the bandwidth and latency of a link identified by name. This