This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, trac-323-sos has been updated
via cd4381f5133ad315e792fcc5b861759a0208215c (commit)
via 4f17474afb2d705953a1bdee68ff044a0eadbf5a (commit)
from 5efedd840fc08bd6af03ac070e83f0e1170b7d69 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit cd4381f5133ad315e792fcc5b861759a0208215c
Author: John Jenkins <jenkins(a)mcs.anl.gov>
Date: Tue Mar 10 11:11:05 2015 -0500
add simple profiling layer to asg
commit 4f17474afb2d705953a1bdee68ff044a0eadbf5a
Author: John Jenkins <jenkins(a)mcs.anl.gov>
Date: Tue Mar 10 11:08:18 2015 -0500
error check for partial allocation failure
-----------------------------------------------------------------------
Summary of changes:
code/src/asg/Makefile.subdir | 4 +-
code/src/asg/README | 4 ++
code/src/asg/asg-internal-util.c | 71 ++++++++++++++++++++++++++++++++++
code/src/asg/asg-internal-util.h | 79 ++++++++++++++++++++++++++++++++++++++
code/src/asg/asg-internal.ae | 10 ++++-
code/src/asg/asg.c | 68 +++++++++++++++++++++++----------
6 files changed, 213 insertions(+), 23 deletions(-)
create mode 100644 code/src/asg/asg-internal-util.c
create mode 100644 code/src/asg/asg-internal-util.h
Diff of changes:
diff --git a/code/src/asg/Makefile.subdir b/code/src/asg/Makefile.subdir
index b119d3f..175b348 100644
--- a/code/src/asg/Makefile.subdir
+++ b/code/src/asg/Makefile.subdir
@@ -3,7 +3,9 @@ src_libtriton_la_SOURCES += \
src/asg/asg-triton-ext.c \
src/asg/asg-internal.ae \
src/asg/asg-internal.h \
- src/asg/asg-internal.hae
+ src/asg/asg-internal.hae \
+ src/asg/asg-internal-util.h \
+ src/asg/asg-internal-util.c
BUILT_SOURCES += \
src/asg/asg-internal.h
diff --git a/code/src/asg/README b/code/src/asg/README
index a646060..2584669 100644
--- a/code/src/asg/README
+++ b/code/src/asg/README
@@ -4,3 +4,7 @@ NOTE: to control the replication factor, the application can define the
environment variable TRITON_ASG_RF to a positive integer. If the variable
doesn't exist or is non-integral, then it is ignored and the system default
replication factor is used.
+
+NOTE: per-function profiling can be enabled by specifying the TRITON_ASG_PROF
+environment variable. If it is defined to a string, the value will be used as
+the output file. Otherwise, stderr is used.
diff --git a/code/src/asg/asg-internal-util.c b/code/src/asg/asg-internal-util.c
new file mode 100644
index 0000000..9fbc0e3
--- /dev/null
+++ b/code/src/asg/asg-internal-util.c
@@ -0,0 +1,71 @@
+/*
+ * (C) 2015 The University of Chicago
+ *
+ * See COPYRIGHT notice in top-level source directory
+ */
+
+#include <stdlib.h>
+
+#include "asg-internal-util.h"
+
+#define CONV 1000000000
+
+int asg_do_profile = 0;
+FILE * asg_prof_output = NULL;
+
+#if ENABLE_PROFILING
+#define MAX_TIMESTR_LEN 128
+void asg_init_profile(void) {
+ const char * prof_env_var;
+ time_t curr_time;
+ struct tm * curr_tm;
+ char timestr[MAX_TIMESTR_LEN];
+
+ /* initialize profiling based on environment variables */
+ prof_env_var = getenv("TRITON_ASG_PROF");
+ /* if nonempty, open the file there */
+ if (prof_env_var == NULL)
+ asg_do_profile = 0;
+ else {
+ asg_do_profile = 1;
+ if (prof_env_var[0] != '\0') {
+ asg_prof_output = fopen(prof_env_var, "a");
+ if (asg_prof_output == NULL) {
+ fprintf(stderr, "ERROR: asg profile unable to open %s\n", prof_env_var);
+ asg_do_profile = 0;
+ }
+ }
+ else
+ asg_prof_output = stderr;
+ curr_time = time(NULL);
+ curr_tm = localtime(&curr_time);
+ strftime(timestr, MAX_TIMESTR_LEN, "%F %T", curr_tm);
+ fprintf(asg_prof_output, "=== ASG Profile %s ===\n", timestr);
+ }
+}
+#endif
+
+double timespec_subtract(
+ struct timespec *x,
+ struct timespec *y)
+{
+ struct timespec result;
+ /* Perform the carry for the later subtraction by updating y. */
+ if (x->tv_nsec < y->tv_nsec) {
+ int nsec = (y->tv_nsec - x->tv_nsec) / CONV + 1;
+ y->tv_nsec -= CONV * nsec;
+ y->tv_sec += nsec;
+ }
+ if (x->tv_nsec - y->tv_nsec > CONV) {
+ int nsec = (x->tv_nsec - y->tv_nsec) / CONV;
+ y->tv_nsec += CONV * nsec;
+ y->tv_sec -= nsec;
+ }
+
+ /* Compute the time remaining to wait.
+ tv_usec is certainly positive. */
+ result.tv_sec = x->tv_sec - y->tv_sec;
+ result.tv_nsec = x->tv_nsec - y->tv_nsec;
+
+ return (double) result.tv_sec * 1e9 + (double) result.tv_nsec;
+}
diff --git a/code/src/asg/asg-internal-util.h b/code/src/asg/asg-internal-util.h
new file mode 100644
index 0000000..44bf170
--- /dev/null
+++ b/code/src/asg/asg-internal-util.h
@@ -0,0 +1,79 @@
+/*
+ * (C) 2015 The University of Chicago
+ *
+ * See COPYRIGHT notice in top-level source directory
+ */
+
+#ifndef ASG_INTERNAL_UTIL
+#define ASG_INTERNAL_UTIL
+
+#include <time.h>
+#include <stdio.h>
+
+double timespec_subtract(
+ struct timespec *x,
+ struct timespec *y);
+
+extern int asg_do_profile;
+extern FILE * asg_prof_output;
+
+#define ENABLE_PROFILING 1
+
+/* TODO: make this a configure-time option */
+
+#if ENABLE_PROFILING
+
+void asg_init_profile(void);
+
+#define DECL_PROF \
+ struct timespec _ts_start, _ts_end; \
+ int _clock_rc;
+
+#define GETTIME(t) \
+ _clock_rc = clock_gettime(CLOCK_MONOTONIC, &t); \
+ if (_clock_rc != 0) { \
+ fprintf(stderr, "ERROR: failure while profiling asg, turning off\n"); \
+ asg_do_profile = 0; \
+ }
+
+#define START_PROF \
+if (asg_do_profile) { \
+ GETTIME(_ts_start) \
+}
+
+#define _NOARG_PRINT(rtn) \
+ fprintf(asg_prof_output, "%s:%d: %0.2lf\n", __func__, rtn, \
+ timespec_subtract(&_ts_end, &_ts_start) / 1e3);
+#define _ARG_PRINT(rtn, fmt, ...) \
+ fprintf(asg_prof_output, "%s:%d: %0.2lf " fmt "\n", __func__, rtn, \
+ timespec_subtract(&_ts_end, &_ts_start) / 1e3, ## __VA_ARGS__);
+
+
+#define END_PROF_NOARGS(rtn) \
+if (asg_do_profile) { \
+ GETTIME(_ts_end) \
+ if (asg_do_profile) \
+ _NOARG_PRINT(rtn) \
+}
+
+/* fmt must be a string literal */
+#define END_PROF(rtn, fmt, ...) \
+if (asg_do_profile) { \
+ GETTIME(_ts_end) \
+ if (asg_do_profile) { \
+ if (rtn == ASG_SUCCESS) \
+ _ARG_PRINT(rtn, fmt, __VA_ARGS__) \
+ else \
+ _NOARG_PRINT(rtn) \
+ } \
+}
+
+#else
+#define asg_init_profile() do { } while(0)
+#define DECL_PROF
+#define START_PROF
+#define END_PROF_NOARGS()
+#define END_PROF(...)
+#endif
+
+#endif
diff --git a/code/src/asg/asg-internal.ae b/code/src/asg/asg-internal.ae
index 415cddf..7ca772e 100644
--- a/code/src/asg/asg-internal.ae
+++ b/code/src/asg/asg-internal.ae
@@ -680,6 +680,8 @@ __blocking int asg_i_alloc_object_set(
int num_obj_per_serv;
asg_size_t i;
triton_place_ctx ctx = NULL;
+ triton_ret_t tret;
+ int aret;
#define NOT_SUPPORTED(etype) \
fprintf(stderr, "Error: " #etype " currently not supported for alloc\n");\
@@ -715,9 +717,13 @@ __blocking int asg_i_alloc_object_set(
for (i = 0; i < num_objects; i++) {
if (i == num_objects-1 ||
!triton_node_equal(nodelist[i], nodelist[i+1])) {
- remote_triton_rpc_rosd_alloc(&nodelist[i], container,
+ tret = remote_triton_rpc_rosd_alloc(&nodelist[i], container,
num_obj_per_serv, (int) replication_factor,
0, ctx, objects);
+ if (triton_is_error(tret)) {
+ aret = ASG_ERR_OTHER;
+ break;
+ }
num_obj_per_serv = 1;
}
else /* not last server && nodes are equal */
@@ -725,7 +731,7 @@ __blocking int asg_i_alloc_object_set(
}
free(nodelist);
- return ASG_ERR_OTHER;
+ return aret;
}
/*
diff --git a/code/src/asg/asg.c b/code/src/asg/asg.c
index 5cdccd1..b389828 100644
--- a/code/src/asg/asg.c
+++ b/code/src/asg/asg.c
@@ -3,15 +3,19 @@
#include <src/common/triton-debug.h>
#include <include/asg.h>
#include <src/asg/asg-internal.h>
+#include "asg-internal-util.h"
-#define ASG_HANDLE_AE_DEFAULT(_fnname, ...) \
+#define ASG_HANDLE_AE_DEFAULT(_fnname, _out_ret, ...) \
asg_completion_t c; \
ae_hints_t hints; \
ae_op_id_t op_id; \
int r; \
+ int _out_ret; \
+ DECL_PROF \
\
c.done = 0; \
ae_hints_init(&hints); \
+ START_PROF \
r = ext_post_blocking(_fnname, asg_callback, &c, &hints, &op_id, &c.ret, \
__VA_ARGS__); \
if (r == AE_SUCCESS) \
@@ -21,17 +25,22 @@
c.ret = ASG_ERR_OTHER; \
/* else nothing to do if immediately completed */ \
ae_hints_destroy(&hints); \
- return c.ret;
+ _out_ret = c.ret;
int asg_initialize (asg_instance_t * instance, const char * options)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_initialize, instance, options)
+ asg_init_profile();
+ ASG_HANDLE_AE_DEFAULT(asg_i_initialize, aret, instance, options)
+ END_PROF_NOARGS(aret)
+ return aret;
}
int asg_finalize (asg_instance_t instance)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_finalize, instance)
+ ASG_HANDLE_AE_DEFAULT(asg_i_finalize, aret, instance)
+ END_PROF_NOARGS(aret)
+ return aret;
}
int asg_read_one (
@@ -47,9 +56,11 @@ int asg_read_one (
size_t buf_size,
asg_record_info_t * record_info)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_read_one, instance, location, container,
+ ASG_HANDLE_AE_DEFAULT(asg_i_read_one, aret, instance, location, container,
object, fork, record, flags, update_id_condition, buf, buf_size,
record_info);
+ END_PROF(aret, "xfer:%lu", record_info->record_len)
+ return aret;
}
int asg_read_sequence (
@@ -66,10 +77,13 @@ int asg_read_sequence (
void * buf,
asg_record_info_t * record_info)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_read_sequence, instance, location,
- container, object,
- fork, record_start, record_count, record_expected_length, flags,
- update_id_condition, buf, record_info)
+ ASG_HANDLE_AE_DEFAULT(asg_i_read_sequence, aret, instance, location,
+ container, object, fork, record_start, record_count,
+ record_expected_length, flags, update_id_condition, buf,
+ record_info)
+ END_PROF(aret, "xfer:%lu",
+ record_info->seq_len * record_info->record_len);
+ return aret;
}
@@ -113,9 +127,11 @@ int asg_write (
const void * data,
asg_size_t * transferred)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_write, instance, location, container, object,
- fork, start_record, recordcount, recordlen, flags,
+ ASG_HANDLE_AE_DEFAULT(asg_i_write, aret, instance, location, container,
+ object, fork, start_record, recordcount, recordlen, flags,
version_condition, new_version, data, transferred)
+ END_PROF(aret, "xfer:%lu", *transferred)
+ return aret;
}
int asg_punch (
@@ -131,9 +147,11 @@ int asg_punch (
asg_update_id_t * new_version,
asg_size_t * transferred)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_punch, instance, location, container, object,
- fork, start_record, recordcount, flags, version_condition,
+ ASG_HANDLE_AE_DEFAULT(asg_i_punch, aret, instance, location, container,
+ object, fork, start_record, recordcount, flags, version_condition,
new_version, transferred)
+ END_PROF(aret, "xfer:%lu", *transferred)
+ return aret;
}
int asg_reset (
@@ -148,9 +166,11 @@ int asg_reset (
asg_update_id_t update_id_condition,
asg_size_t * records_reset)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_reset, instance, location, container, object,
- fork, record_start, record_count, flags,
+ ASG_HANDLE_AE_DEFAULT(asg_i_reset, aret, instance, location, container,
+ object, fork, record_start, record_count, flags,
update_id_condition, records_reset)
+ END_PROF(aret, "records:%lu", record_count)
+ return aret;
}
int asg_probe_system (
@@ -162,8 +182,10 @@ int asg_probe_system (
asg_size_t * transferred, /* number of container structures returned */
asg_container_id_t * next)
{
- ASG_HANDLE_AE_DEFAULT( asg_i_probe_system, instance, location, start,
+ ASG_HANDLE_AE_DEFAULT(asg_i_probe_system, aret, instance, location, start,
buf, maxitems, transferred, next)
+ END_PROF(aret, "xfer:%lu", *transferred)
+ return aret;
}
int asg_probe_container (
@@ -176,8 +198,10 @@ int asg_probe_container (
asg_size_t * transferred,
asg_object_id_t * next)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_probe_container, instance, location,
+ ASG_HANDLE_AE_DEFAULT(asg_i_probe_container, aret, instance, location,
container, start, buf, maxitems, transferred, next)
+ END_PROF(aret, "xfer:%lu", *transferred)
+ return aret;
}
int asg_probe_object (
@@ -191,8 +215,10 @@ int asg_probe_object (
asg_size_t * transferred,
asg_fork_id_t * next)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_probe_object, instance, location, container,
- object, start, buf, maxitems, transferred, next)
+ ASG_HANDLE_AE_DEFAULT(asg_i_probe_object, aret, instance, location,
+ container, object, start, buf, maxitems, transferred, next)
+ END_PROF(aret, "xfer:%lu", *transferred)
+ return aret;
}
int asg_probe_fork (
@@ -207,6 +233,8 @@ int asg_probe_fork (
asg_size_t * transferred,
asg_record_id_t * next)
{
- ASG_HANDLE_AE_DEFAULT(asg_i_probe_fork, instance, location, container,
+ ASG_HANDLE_AE_DEFAULT(asg_i_probe_fork, aret, instance, location, container,
object, fork, start, buf, maxitems, transferred, next)
+ END_PROF(aret, "xfer:%lu", *transferred)
+ return aret;
}
hooks/post-receive
--