diff options
| author | Qiuwen Lu <[email protected]> | 2016-11-07 21:32:09 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2016-11-07 21:32:09 +0800 |
| commit | 68331f40c991c9e4347a700c9acd4987ee59619e (patch) | |
| tree | 55ae75d5ac4405b20dda9a5525065cdb4e9ccc72 | |
| parent | e3d37338024044f71d39c9ffe268d0f718af6b86 (diff) | |
增加VNode详细统计功能:底层支持对prod、cons的入包、出包和丢包数统计。
| -rw-r--r-- | core/include/mr_vnode.h | 24 | ||||
| -rw-r--r-- | core/src/vman.c | 2 | ||||
| -rw-r--r-- | core/src/vnode.c | 45 | ||||
| -rw-r--r-- | runtime/include/mr_runtime.h | 1 | ||||
| -rw-r--r-- | runtime/src/app.c | 6 |
5 files changed, 61 insertions, 17 deletions
diff --git a/core/include/mr_vnode.h b/core/include/mr_vnode.h index e787df8..e6fc8cd 100644 --- a/core/include/mr_vnode.h +++ b/core/include/mr_vnode.h @@ -13,9 +13,17 @@ extern "C" { struct tunnel_block { + /* should be deleted */ unsigned int deleted; + /* Prod Queue Count */ unsigned int nr_prodq; + /* Cons Queue Count */ unsigned int nr_consq; + /* Tunnel's Producer */ + struct vnode_prod * prod; + /* Tunnel's Consumer */ + struct vnode_cons * cons; + /* Tunnel Descs */ struct tunnel_desc * descs[0]; }; @@ -27,6 +35,20 @@ struct tunnel_block_list_item TAILQ_HEAD(tunnel_block_list, tunnel_block_list_item); +struct vnode_cons_stat +{ + uint64_t object_enqueue; + uint64_t object_drop; +} __rte_cache_aligned; + +struct vnode_prod_stat +{ + uint64_t object_enqueue; + uint64_t object_dequeue; + uint64_t object_drop_by_app; + uint64_t object_drop_by_dup; +} __rte_cache_aligned; + /* Virtual Data-Node Consumer Structure */ struct vnode_cons { @@ -38,6 +60,7 @@ struct vnode_cons struct tunnel_block_list block_list; unsigned int nr_block; unsigned int cur_attach; + struct vnode_cons_stat stat[MR_GSID_MAX]; }; /* Virtual Data-Node Producer Structure */ @@ -51,6 +74,7 @@ struct vnode_prod struct tunnel_block_list block_list; unsigned int nr_block; unsigned int cur_attach; + struct vnode_prod_stat stat[MR_GSID_MAX]; }; /* Virtual Data-Node Consumer Queue Structure */ diff --git a/core/src/vman.c b/core/src/vman.c index 4d0ea4b..7c1da28 100644 --- a/core/src/vman.c +++ b/core/src/vman.c @@ -255,7 +255,7 @@ const char * vnode_sym, const char * prod_sym, unsigned int nr_prod_queue) if (prod == NULL) { MR_LOG(INFO, BASE, "VNodeMan, VNodeManRegisterProducer, " - "Cannot create consumer %s for vnode %s", prod_sym, vnode_sym); + "Cannot create consumer %s for vnode %s. \n", prod_sym, vnode_sym); return -2; } diff --git a/core/src/vnode.c b/core/src/vnode.c index 5fda579..8f67f76 100644 --- a/core/src/vnode.c +++ b/core/src/vnode.c @@ -48,6 +48,12 @@ #define __write_unlock(x) #endif + +#define VNODE_STAT_UPDATE(desc, gsid, item, value) \ +do { \ + desc->stat[gsid].item += value; } while(0) \ + + /* Tunnel Description Structure */ struct tunnel_desc { @@ -127,8 +133,8 @@ static inline void tunnel_enqueue_without_buffer(struct tunnel_desc * desc, return; } -static inline void tunnel_enqueue(struct tunnel_desc * desc, struct vnode_ops * ops, - void * obj) +static inline void tunnel_enqueue(struct vnode_prod * prod, struct vnode_cons * cons, + struct tunnel_desc * desc, struct vnode_ops * ops, void * obj) { // disable sz_buffer, enqueue object directly. // TODO: 优化无缓冲队列 @@ -139,7 +145,9 @@ static inline void tunnel_enqueue(struct tunnel_desc * desc, struct vnode_ops * return; } #endif - + + thread_id_t gsid = mr_gsid_id(); + // append the object at the tail of enqueue buffer. unsigned int pos; pos = desc->sz_en_buffer_used; @@ -158,8 +166,8 @@ static inline void tunnel_enqueue(struct tunnel_desc * desc, struct vnode_ops * int n_send = rte_ring_sp_enqueue_burst(desc->tunnel_object, desc->en_buffer, n_to_send); - UPDATE_VNODE_STAT(tunnel_enqueue, n_send); - + VNODE_STAT_UPDATE(cons, gsid, object_enqueue, n_to_send); + // release all the objects which not send successfully. if(unlikely(n_send < n_to_send)) { @@ -169,8 +177,9 @@ static inline void tunnel_enqueue(struct tunnel_desc * desc, struct vnode_ops * ops->op_object_delete(object_to_be_free); } - UPDATE_VNODE_STAT(tunnel_enqueue_fail, n_to_send - n_send); - UPDATE_EVENT_STAT(ev_rx_entunnel_failed, n_to_send - n_send); + unsigned int n_drop = n_to_send - n_send; + VNODE_STAT_UPDATE(cons, gsid, object_drop, n_drop); + VNODE_STAT_UPDATE(prod, gsid, object_drop_by_app, n_drop); } desc->sz_en_buffer_used = 0; @@ -238,9 +247,13 @@ int tunnel_block_try_gc(struct tunnel_block * block, struct vnode_ops * ops) } /* Alloc a block of tunnels, and init all the tunnels */ -struct tunnel_block * tunnel_block_new(struct vnode_ops * ops, const char * symbol, - unsigned int nr_prodq, unsigned int nr_consq, unsigned int tunnel_size, unsigned int tun_sz_buffer) +struct tunnel_block * tunnel_block_new(struct vnode_ops * ops, const char * symbol, + struct vnode_prod * prod, struct vnode_cons * cons, + unsigned int tunnel_size, unsigned int tun_sz_buffer) { + unsigned int nr_prodq = prod->nr_prodq; + unsigned int nr_consq = cons->nr_consq; + unsigned int block_size = sizeof(struct tunnel_block) + sizeof(struct tunnel_desc *) * (nr_prodq * nr_consq); @@ -257,6 +270,8 @@ struct tunnel_block * tunnel_block_new(struct vnode_ops * ops, const char * symb return NULL; } + block->cons = cons; + block->prod = prod; block->nr_consq = nr_consq; block->nr_prodq = nr_prodq; block->deleted = 0; @@ -306,16 +321,14 @@ err: static inline void tunnel_block_enqueue_with_hash(struct tunnel_block * block, struct vnode_ops * ops, int prodq, void * obj[], uint32_t hash[], int nr_obj) { - unsigned int consq; struct tunnel_desc * tunnel; - UPDATE_VNODE_STAT(block_enqueue, nr_obj); - + for (unsigned int i = 0; i < nr_obj; i++) { assert(obj[i] != NULL); - consq = hash[i] % block->nr_consq; + unsigned int consq = hash[i] % block->nr_consq; tunnel = *tunnel_block_index(block, prodq, consq); - tunnel_enqueue(tunnel, ops, obj[i]); + tunnel_enqueue(block->prod, block->cons, tunnel, ops, obj[i]); } } @@ -400,7 +413,7 @@ int vnode_prod_increase_unsafe(struct vnode * vnode, struct vnode_ops * ops, nr_consq = cons->nr_consq; // create commucation tunnel for each cons and prods - block = tunnel_block_new(ops, block_sym, nr_prodq, nr_consq, + block = tunnel_block_new(ops, block_sym, prod, cons, vnode->sz_tunnel, vnode->sz_tunnel_buffer); if (block == NULL) { @@ -459,7 +472,7 @@ struct vnode_cons * cons) nr_prodq = prod->nr_prodq; // create commucation tunnel for each cons and prods - block = tunnel_block_new(ops, block_sym, nr_prodq, nr_consq, + block = tunnel_block_new(ops, block_sym, prod, cons, vnode->sz_tunnel, vnode->sz_tunnel_buffer); if (block == NULL) { diff --git a/runtime/include/mr_runtime.h b/runtime/include/mr_runtime.h index 098d0a0..94e27f6 100644 --- a/runtime/include/mr_runtime.h +++ b/runtime/include/mr_runtime.h @@ -47,6 +47,7 @@ void mr_on_exit_register(void(*exit_fn)(void * arg), void * arg); void mr_thread_hook(); thread_id_t mr_thread_id(); +thread_id_t mr_gsid_id(); socket_id_t mr_socket_id(); cpu_id_t mr_cpu_id(); app_id_t mr_app_id(); diff --git a/runtime/src/app.c b/runtime/src/app.c index 9533066..908b43f 100644 --- a/runtime/src/app.c +++ b/runtime/src/app.c @@ -539,6 +539,12 @@ thread_id_t mr_thread_id() return currect_thread_info->sid; } +thread_id_t mr_gsid_id() +{ + assert(currect_thread_info != NULL); + return currect_thread_info->gsid; +} + socket_id_t mr_socket_id() { assert(currect_thread_info != NULL); |
