Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Perf improvement: reduce the amount of cbps creation/destruction by making it static...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 9 Sep 2005 10:19:46 +0000 (10:19 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 9 Sep 2005 10:19:46 +0000 (10:19 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1715 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/gras/DataDesc/cbps.c
src/gras/DataDesc/datadesc_private.h
src/gras/DataDesc/ddt_exchange.c

index 69b3ed2..df24554 100644 (file)
@@ -60,6 +60,17 @@ void gras_cbps_free(gras_cbps_t *state) {
   *state = NULL;
 }
 
+void gras_cbps_reset(gras_cbps_t state) {
+
+  xbt_dynar_reset(state->lints);
+
+  xbt_dict_free ( &(state->space) );
+  state->space = xbt_dict_new();
+
+  xbt_dynar_reset(state->frames);
+  xbt_dynar_reset(state->globals);
+}
+
 /** \brief Declare a new element in the PS, and give it a value.
  *
  * If an element of that
index f6b43c5..82d77a8 100644 (file)
@@ -248,6 +248,7 @@ gras_datadesc_type_t
  ****************************************************/
 gras_cbps_t gras_cbps_new(void);
 void gras_cbps_free(gras_cbps_t *state);
+void gras_cbps_reset(gras_cbps_t state);
 
 /***************
  * Convertions *
index 6519ec0..36af95d 100644 (file)
@@ -580,19 +580,20 @@ void gras_datadesc_send(gras_socket_t        sock,
                        void *src) {
 
   xbt_ex_t e;
-  gras_cbps_t  state;
+  static gras_cbps_t state=NULL;
   xbt_dict_t  refs; /* all references already sent */
  
   xbt_assert0(type,"called with NULL type descriptor");
 
   refs = xbt_dict_new();
-  state = gras_cbps_new();
+  if (!state)
+    state = gras_cbps_new();
   
   TRY {
     gras_datadesc_send_rec(sock,state,refs,type,(char*)src, type->cycle);
   } CLEANUP {
     xbt_dict_free(&refs);
-    gras_cbps_free(&state);
+    gras_cbps_reset(state);
   } CATCH(e) {
     RETHROW;
   }
@@ -909,11 +910,12 @@ gras_datadesc_recv(gras_socket_t         sock,
                   void                 *dst) {
 
   xbt_ex_t e;
-  gras_cbps_t  state; /* callback persistent state */
+  static gras_cbps_t state=NULL; /* callback persistent state */
   xbt_dict_t  refs;  /* all references already sent */
 
   refs = xbt_dict_new();
-  state = gras_cbps_new();
+  if (!state)
+    state = gras_cbps_new();
 
   xbt_assert0(type,"called with NULL type descriptor");
   TRY {
@@ -923,7 +925,7 @@ gras_datadesc_recv(gras_socket_t         sock,
                           type->cycle);
   } CLEANUP {
     xbt_dict_free(&refs);
-    gras_cbps_free(&state);
+    gras_cbps_reset(state);
   } CATCH(e) {
     RETHROW;
   }