增加future性能监控的可读性。
This commit is contained in:
@@ -21,6 +21,7 @@ struct future_promise_instance
|
||||
MESA_htable_handle name_table;
|
||||
char statsd_server_ip[256];
|
||||
int statsd_server_port;
|
||||
enum field_calc_algo favorite;
|
||||
char histogram_bins[256];
|
||||
screen_stat_handle_t fs_handle;
|
||||
};
|
||||
@@ -63,6 +64,7 @@ void future_promise_library_init(const char* profile)
|
||||
|
||||
int value=0;
|
||||
memset(&g_FP_instance,0,sizeof(g_FP_instance));
|
||||
g_FP_instance.favorite=FS_CALC_SPEED;
|
||||
strcpy(g_FP_instance.histogram_bins, FP_HISTOGRAM_BINS);
|
||||
if(profile!=NULL)
|
||||
{
|
||||
@@ -72,8 +74,12 @@ void future_promise_library_init(const char* profile)
|
||||
MESA_load_profile_int_def(profile, "STAT", "statsd_port", &(g_FP_instance.statsd_server_port), 0);
|
||||
MESA_load_profile_string_def(profile, "STAT", "histogram_bins",
|
||||
g_FP_instance.histogram_bins, sizeof(g_FP_instance.histogram_bins), FP_HISTOGRAM_BINS);
|
||||
|
||||
|
||||
MESA_load_profile_int_def(profile, "STAT", "print_diff",
|
||||
&value, 1);
|
||||
if(value==0)
|
||||
{
|
||||
g_FP_instance.favorite=FS_CALC_CURRENT;
|
||||
}
|
||||
}
|
||||
if(g_FP_instance.no_stats)
|
||||
{
|
||||
@@ -114,7 +120,7 @@ void future_promise_library_init(const char* profile)
|
||||
FS_set_para(fs, STATS_SERVER_PORT, &(g_FP_instance.statsd_server_port), sizeof(g_FP_instance.statsd_server_port));
|
||||
}
|
||||
FS_set_para(fs, HISTOGRAM_GLOBAL_BINS, g_FP_instance.histogram_bins, strlen(g_FP_instance.histogram_bins)+1);
|
||||
g_FP_instance.fsid_f_num=FS_register(fs, FS_STYLE_FIELD, FS_CALC_CURRENT, "futures");
|
||||
g_FP_instance.fsid_f_num=FS_register(fs, FS_STYLE_FIELD, g_FP_instance.favorite, "futures");
|
||||
FS_start(fs);
|
||||
g_FP_instance.fs_handle=fs;
|
||||
g_is_FP_init=1;
|
||||
@@ -165,11 +171,11 @@ static long field_get_set_cb(void * data, const uchar * key, uint size, void * u
|
||||
{
|
||||
field_id=(int*)malloc(sizeof(int)*2);
|
||||
snprintf(buff,sizeof(buff),"%s(ms)",(char*)key);
|
||||
field_id[0]=FS_register_histogram(args->fs_handle, FS_CALC_SPEED, buff,
|
||||
field_id[0]=FS_register_histogram(args->fs_handle, g_FP_instance.favorite, buff,
|
||||
1, 30*1000,3);
|
||||
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);
|
||||
field_id[1]=FS_register(args->fs_handle, FS_STYLE_FIELD, g_FP_instance.favorite, buff);
|
||||
args->fsid_failed=field_id[1];
|
||||
ret = MESA_htable_add(args->htable, key, size, (void*)field_id);
|
||||
assert(ret>=0);
|
||||
|
||||
@@ -1224,7 +1224,7 @@ void cache_pend(const struct tfe_http_session * session, unsigned int thread_id,
|
||||
}
|
||||
void cache_read(const struct tfe_http_session * session, unsigned int thread_id, struct pangu_http_ctx * ctx)
|
||||
{
|
||||
ctx->f_cache_query=future_create("cache_get", cache_read_on_succ, cache_read_on_fail, ctx);
|
||||
ctx->f_cache_query=future_create("cache_read", cache_read_on_succ, cache_read_on_fail, ctx);
|
||||
int ret=web_cache_async_read(g_pangu_rt->cache, thread_id, session->req, &(ctx->cmid), ctx->f_cache_query);
|
||||
if(ret==0)
|
||||
{
|
||||
|
||||
@@ -1164,7 +1164,7 @@ int web_cache_async_read(struct cache_handle* handle, unsigned int thread_id,
|
||||
promise_set_ctx(p, query_ctx, cache_query_ctx_free_cb);
|
||||
|
||||
ATOMIC_INC(&(handle->stat_val[STAT_CACHE_READING]));
|
||||
query_ctx->f_tango_cache_fetch=future_create("_cache_get", cache_query_obj_on_succ, cache_query_obj_on_fail, p);
|
||||
query_ctx->f_tango_cache_fetch=future_create("_cache_read", cache_query_obj_on_succ, cache_query_obj_on_fail, p);
|
||||
int ret=tango_cache_fetch_object(handle->clients[thread_id], query_ctx->f_tango_cache_fetch, &meta);
|
||||
if(ret<0)
|
||||
{
|
||||
@@ -1311,7 +1311,7 @@ struct cache_update_context* web_cache_write_start(struct cache_handle* handle,
|
||||
_cache_put_ctx->url=tfe_strdup(session->req->req_spec.url);
|
||||
_cache_put_ctx->start=time(NULL);
|
||||
_cache_put_ctx->ref_handle=handle;
|
||||
_cache_put_ctx->f=future_create("cache_put", wrap_cache_write_on_succ, wrap_cache_write_on_fail, _cache_put_ctx);
|
||||
_cache_put_ctx->f=future_create("_cache_wrt", wrap_cache_write_on_succ, wrap_cache_write_on_fail, _cache_put_ctx);
|
||||
write_ctx=tango_cache_update_start(handle->clients[thread_id], _cache_put_ctx->f, &meta);
|
||||
if(write_ctx==NULL)//exceed maximum cache memory size.
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user