[Darshan-commits] [Git][darshan/darshan][master] 5 commits: make dxt mem usage runtime configurable
Shane Snyder
xgitlab at cels.anl.gov
Mon Jan 30 20:44:23 CST 2017
Shane Snyder pushed to branch master at darshan / darshan
Commits:
7bebe64f by Shane Snyder at 2017-01-30T15:16:21-06:00
make dxt mem usage runtime configurable
- - - - -
79ec6b82 by Shane Snyder at 2017-01-30T16:39:14-06:00
allow mem env variables to be floats
this allows us to request memory allocations at smaller granularity
than MiB
- - - - -
410c684a by Shane Snyder at 2017-01-30T17:00:07-06:00
bug fix in dxt serialiation routines
- - - - -
915885cf by Shane Snyder at 2017-01-30T20:37:43-06:00
make sure compression buffers are big enough
- - - - -
03053837 by Shane Snyder at 2017-01-30T20:44:17-06:00
Merge branch 'issue-219-dxt-mem-config' into 'master'
Issue 219 dxt mem config
See merge request !9
- - - - -
5 changed files:
- darshan-runtime/darshan-core.h
- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-dxt.c
- darshan-runtime/lib/darshan-mpiio.c
- darshan-runtime/lib/darshan-posix.c
Changes:
=====================================
darshan-runtime/darshan-core.h
=====================================
--- a/darshan-runtime/darshan-core.h
+++ b/darshan-runtime/darshan-core.h
@@ -48,9 +48,6 @@
/* default name record buf can store 2048 records of size 100 bytes */
#define DARSHAN_NAME_RECORD_BUF_SIZE (2048 * 100)
-/* Default runtime compression buffer size */
-#define DARSHAN_COMP_BUF_SIZE DARSHAN_MOD_MEM_MAX
-
/* structure to track registered modules */
struct darshan_core_module
{
=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -156,8 +156,9 @@ void darshan_core_initialize(int argc, char **argv)
char *jobid_str;
int jobid;
int ret;
- int tmpval;
int i;
+ int tmpval;
+ double tmpfloat;
DARSHAN_MPI_CALL(PMPI_Comm_size)(MPI_COMM_WORLD, &nprocs);
DARSHAN_MPI_CALL(PMPI_Comm_rank)(MPI_COMM_WORLD, &my_rank);
@@ -219,11 +220,11 @@ void darshan_core_initialize(int argc, char **argv)
envstr = getenv(DARSHAN_MOD_MEM_OVERRIDE);
if(envstr)
{
- ret = sscanf(envstr, "%d", &tmpval);
+ ret = sscanf(envstr, "%lf", &tmpfloat);
/* silently ignore if the env variable is set poorly */
- if(ret == 1 && tmpval > 0)
+ if(ret == 1 && tmpfloat > 0)
{
- darshan_mod_mem_quota = tmpval * 1024 * 1024; /* convert from MiB */
+ darshan_mod_mem_quota = tmpfloat * 1024 * 1024; /* convert from MiB */
}
}
@@ -404,7 +405,7 @@ void darshan_core_shutdown()
final_core->log_job_p->end_time = last_end_time;
}
- final_core->comp_buf = malloc(DARSHAN_COMP_BUF_SIZE);
+ final_core->comp_buf = malloc(darshan_mod_mem_quota);
if(!(final_core->comp_buf))
{
darshan_core_cleanup(final_core);
@@ -1557,7 +1558,7 @@ static int darshan_deflate_buffer(void **pointers, int *lengths, int count,
}
tmp_stream.next_out = (unsigned char *)comp_buf;
- tmp_stream.avail_out = DARSHAN_COMP_BUF_SIZE;
+ tmp_stream.avail_out = darshan_mod_mem_quota;
/* loop over the input pointers */
for(i = 0; i < count; i++)
=====================================
darshan-runtime/lib/darshan-dxt.c
=====================================
--- a/darshan-runtime/lib/darshan-dxt.c
+++ b/darshan-runtime/lib/darshan-dxt.c
@@ -35,7 +35,11 @@ typedef int64_t off64_t;
#endif
/* maximum amount of memory to use for storing DXT records */
-#define DXT_IO_TRACE_MEM_MAX (4 * 1024 * 1024) /* 4 MiB */
+#ifdef __DARSHAN_MOD_MEM_MAX
+#define DXT_IO_TRACE_MEM_MAX (__DARSHAN_MOD_MEM_MAX * 1024 * 1024)
+#else
+#define DXT_IO_TRACE_MEM_MAX (4 * 1024 * 1024) /* 4 MiB default */
+#endif
/* initial size of read/write trace buffer (in number of segments) */
/* NOTE: when this size is exceeded, the buffer size is doubled */
@@ -137,7 +141,8 @@ static pthread_mutex_t dxt_runtime_mutex =
PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int dxt_my_rank = -1;
-static int dxt_mem_remaining = DXT_IO_TRACE_MEM_MAX;
+static int dxt_total_mem = DXT_IO_TRACE_MEM_MAX;
+static int dxt_mem_remaining = 0;
#define DXT_LOCK() pthread_mutex_lock(&dxt_runtime_mutex)
#define DXT_UNLOCK() pthread_mutex_unlock(&dxt_runtime_mutex)
@@ -375,6 +380,9 @@ static void dxt_posix_runtime_initialize()
* over realloc'ing module memory as needed.
*/
int dxt_psx_buf_size = 0;
+ int ret;
+ double tmpfloat;
+ char *envstr;
/* register the DXT module with darshan core */
darshan_core_register_module(
@@ -391,14 +399,30 @@ static void dxt_posix_runtime_initialize()
return;
}
+ DXT_LOCK();
dxt_posix_runtime = malloc(sizeof(*dxt_posix_runtime));
if(!dxt_posix_runtime)
{
darshan_core_unregister_module(DXT_POSIX_MOD);
+ DXT_UNLOCK();
return;
}
memset(dxt_posix_runtime, 0, sizeof(*dxt_posix_runtime));
+ /* set the memory quota for DXT, if it has not been initialized */
+ envstr = getenv("ENABLE_DXT_IO_TRACE_MEM");
+ if(envstr && dxt_mpiio_runtime == NULL)
+ {
+ ret = sscanf(envstr, "%lf", &tmpfloat);
+ /* silently ignore if the env variable is set poorly */
+ if(ret == 1 && tmpfloat > 0)
+ {
+ dxt_total_mem = tmpfloat * 1024 * 1024; /* convert from MiB */
+ }
+ }
+ dxt_mem_remaining = dxt_total_mem;
+ DXT_UNLOCK();
+
return;
}
@@ -409,6 +433,9 @@ void dxt_mpiio_runtime_initialize()
* over realloc'ing module memory as needed.
*/
int dxt_mpiio_buf_size = 0;
+ int ret;
+ double tmpfloat;
+ char *envstr;
/* register the DXT module with darshan core */
darshan_core_register_module(
@@ -425,14 +452,30 @@ void dxt_mpiio_runtime_initialize()
return;
}
+ DXT_LOCK();
dxt_mpiio_runtime = malloc(sizeof(*dxt_mpiio_runtime));
if(!dxt_mpiio_runtime)
{
darshan_core_unregister_module(DXT_MPIIO_MOD);
+ DXT_UNLOCK();
return;
}
memset(dxt_mpiio_runtime, 0, sizeof(*dxt_mpiio_runtime));
+ /* set the memory quota for DXT, if it has not been initialized */
+ envstr = getenv("ENABLE_DXT_IO_TRACE_MEM");
+ if(envstr && dxt_posix_runtime == NULL)
+ {
+ ret = sscanf(envstr, "%lf", &tmpfloat);
+ /* silently ignore if the env variable is set poorly */
+ if(ret == 1 && tmpfloat > 0)
+ {
+ dxt_total_mem = tmpfloat * 1024 * 1024; /* convert from MiB */
+ }
+ }
+ dxt_mem_remaining = dxt_total_mem;
+ DXT_UNLOCK();
+
return;
}
@@ -682,10 +725,10 @@ static void dxt_posix_shutdown(
*dxt_posix_buf_sz = 0;
- dxt_posix_runtime->record_buf = malloc(DXT_IO_TRACE_MEM_MAX);
+ dxt_posix_runtime->record_buf = malloc(dxt_total_mem);
if(!(dxt_posix_runtime->record_buf))
return;
- memset(dxt_posix_runtime->record_buf, 0, DXT_IO_TRACE_MEM_MAX);
+ memset(dxt_posix_runtime->record_buf, 0, dxt_total_mem);
dxt_posix_runtime->record_buf_size = 0;
/* iterate all dxt posix records and serialize them to the output buffer */
@@ -792,10 +835,10 @@ static void dxt_mpiio_shutdown(
*dxt_mpiio_buf_sz = 0;
- dxt_mpiio_runtime->record_buf = malloc(DXT_IO_TRACE_MEM_MAX);
+ dxt_mpiio_runtime->record_buf = malloc(dxt_total_mem);
if(!(dxt_mpiio_runtime->record_buf))
return;
- memset(dxt_mpiio_runtime->record_buf, 0, DXT_IO_TRACE_MEM_MAX);
+ memset(dxt_mpiio_runtime->record_buf, 0, dxt_total_mem);
dxt_mpiio_runtime->record_buf_size = 0;
/* iterate all dxt posix records and serialize them to the output buffer */
=====================================
darshan-runtime/lib/darshan-mpiio.c
=====================================
--- a/darshan-runtime/lib/darshan-mpiio.c
+++ b/darshan-runtime/lib/darshan-mpiio.c
@@ -862,7 +862,7 @@ static void mpiio_runtime_initialize()
memset(mpiio_runtime, 0, sizeof(*mpiio_runtime));
/* check if DXT (Darshan extended tracing) should be enabled */
- if (getenv("ENABLE_DXT_IO_TRACE")) {
+ if (getenv("ENABLE_DXT_IO_TRACE_MEM")) {
enable_dxt_io_trace = 1;
}
=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -1291,7 +1291,7 @@ static void posix_runtime_initialize()
memset(posix_runtime, 0, sizeof(*posix_runtime));
/* check if DXT (Darshan extended tracing) should be enabled */
- if (getenv("ENABLE_DXT_IO_TRACE")) {
+ if (getenv("ENABLE_DXT_IO_TRACE_MEM")) {
enable_dxt_io_trace = 1;
}
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/a4a77adadb6d17924962c260576791d759261175...03053837489f018ca58b231f9099f82a12bd5b79
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20170130/dd73c2ef/attachment-0001.html>
More information about the Darshan-commits
mailing list