summaryrefslogtreecommitdiff
path: root/common/src/tfe_future.cpp
diff options
context:
space:
mode:
authorzhengchao <[email protected]>2018-09-04 18:13:05 +0800
committerzhengchao <[email protected]>2018-09-04 18:13:05 +0800
commitaf6340becf7e9f1a527e861e1f6c7823301f1951 (patch)
tree0e886db3e55cb5f879f66a17572d30e69d48c9c4 /common/src/tfe_future.cpp
parent636e41cfca230e872f94b6be6f8c61ffbaf72845 (diff)
完成和key keeper的联调。
Diffstat (limited to 'common/src/tfe_future.cpp')
-rw-r--r--common/src/tfe_future.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/common/src/tfe_future.cpp b/common/src/tfe_future.cpp
index 9e39a17..c398d0d 100644
--- a/common/src/tfe_future.cpp
+++ b/common/src/tfe_future.cpp
@@ -109,19 +109,20 @@ static long field_get_set_cb(void * data, const uchar * key, uint size, void * u
if(data==NULL)
{
field_id=(int*)malloc(sizeof(int)*2);
- field_id[0]=FS_register(args->fs_handle, FS_STYLE_HISTOGRAM, FS_CALC_SPEED, (const char * )key);
- args->fsid_failed=field_id[0];
+ snprintf(buff,sizeof(buff),"%s(ms)",(char*)key);
+ field_id[0]=FS_register(args->fs_handle, FS_STYLE_HISTOGRAM, FS_CALC_CURRENT, buff);
+ args->fsid_latency=field_id[0];
snprintf(buff,sizeof(buff),"%s%s",(char*)key,fail_str);
field_id[1]=FS_register(args->fs_handle, FS_STYLE_FIELD, FS_CALC_SPEED,buff);
- args->fsid_latency=field_id[1];
+ args->fsid_failed=field_id[1];
ret = MESA_htable_add(args->htable, key, size, (void*)field_id);
- assert(ret==0);
+ assert(ret>=0);
}
else
{
field_id=(int*)data;
- args->fsid_failed=field_id[0];
- args->fsid_latency=field_id[1];
+ args->fsid_latency=field_id[0];
+ args->fsid_failed=field_id[1];
}
return 0;
}
@@ -137,7 +138,7 @@ struct future * future_create(const char* symbol, future_success_cb * cb_success
clock_gettime(CLOCK_MONOTONIC,&p->debug.create_time);
void * no_use = NULL;
long cb_ret=0;
- struct field_get_set_args args{.htable = g_FP_instance.name_table, .fs_handle = g_FP_instance.fs_handle};
+ struct field_get_set_args args={.htable = g_FP_instance.name_table, .fs_handle = g_FP_instance.fs_handle};
no_use=MESA_htable_search_cb(g_FP_instance.name_table, (const unsigned char*)symbol, strlen(symbol), field_get_set_cb, &args, &cb_ret);
p->debug.fsid_latency=args.fsid_latency;
p->debug.fsid_failed=args.fsid_failed;
@@ -165,7 +166,7 @@ void future_destroy(struct future * f)
static void fp_stat_latency(struct _future_promise_debug* debug, int is_success)
{
struct timespec end;
- long long jiffies=0;
+ long long jiffies_ms=0;
clock_gettime(CLOCK_MONOTONIC,&end);
if(is_success==1)
{
@@ -177,19 +178,21 @@ static void fp_stat_latency(struct _future_promise_debug* debug, int is_success)
}
if(debug->succ_times<=1)
{
- jiffies=(end.tv_sec-debug->create_time.tv_sec)*1000000000+end.tv_nsec-debug->create_time.tv_nsec;
- FS_operate(g_FP_instance.fs_handle, debug->fsid_latency, 0, FS_OP_SET, jiffies);
+ jiffies_ms=(end.tv_sec-debug->create_time.tv_sec)*1000+(end.tv_nsec-debug->create_time.tv_nsec)/1000000;
+ FS_operate(g_FP_instance.fs_handle, debug->fsid_latency, 0, FS_OP_SET, jiffies_ms);
}
return;
}
void promise_failed(struct promise * p, enum e_future_error error, const char * what)
{
+ fp_stat_latency(&p->debug, 0);
p->f.cb_failed(error, what, p->f.user);
return;
}
void promise_success(struct promise * p, void * result)
{
+ fp_stat_latency(&p->debug, 1);
p->f.cb_success(result, p->f.user);
return;
}