From: mquinson Date: Fri, 9 Sep 2005 10:19:46 +0000 (+0000) Subject: Perf improvement: reduce the amount of cbps creation/destruction by making it static... X-Git-Tag: v3.3~3642 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/6e9f0031ab47e172c38c52e2ae81c335a46b1d46 Perf improvement: reduce the amount of cbps creation/destruction by making it static and using a (newly created) cbps_reset (based on dynar_reset) git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1715 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/gras/DataDesc/cbps.c b/src/gras/DataDesc/cbps.c index 69b3ed24c5..df245546c9 100644 --- a/src/gras/DataDesc/cbps.c +++ b/src/gras/DataDesc/cbps.c @@ -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 diff --git a/src/gras/DataDesc/datadesc_private.h b/src/gras/DataDesc/datadesc_private.h index f6b43c5a0c..82d77a826e 100644 --- a/src/gras/DataDesc/datadesc_private.h +++ b/src/gras/DataDesc/datadesc_private.h @@ -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 * diff --git a/src/gras/DataDesc/ddt_exchange.c b/src/gras/DataDesc/ddt_exchange.c index 6519ec0ecc..36af95d0ac 100644 --- a/src/gras/DataDesc/ddt_exchange.c +++ b/src/gras/DataDesc/ddt_exchange.c @@ -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; }