Skip to content

Commit

Permalink
add three performance counters: net_poll_cq_num, sync_stay_timer, cq_…
Browse files Browse the repository at this point in the history
…stay_timer
  • Loading branch information
JiakunYan committed May 19, 2024
1 parent 2bcf0c3 commit 5772430
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 15 deletions.
1 change: 1 addition & 0 deletions lci/backend/ibv/server_ibv.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ static inline int LCISD_poll_cq(LCIS_endpoint_t endpoint_pp,
#ifdef LCI_ENABLE_MULTITHREAD_PROGRESS
LCIU_release_spinlock(&endpoint_p->cq_lock);
#endif
if (ne > 0) LCII_PCOUNTER_ADD(net_poll_cq_num, ne);
for (int i = 0; i < ne; i++) {
LCI_DBG_Assert(
wc[i].status == IBV_WC_SUCCESS, "Failed status %s (%d) for wr_id %d\n",
Expand Down
1 change: 1 addition & 0 deletions lci/backend/ofi/server_ofi.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ static inline int LCISD_poll_cq(LCIS_endpoint_t endpoint_pp,
LCISI_OFI_CS_EXIT(endpoint_p, LCI_BACKEND_TRY_LOCK_POLL)
ret = ne;
if (ne > 0) {
LCII_PCOUNTER_ADD(net_poll_cq_num, ne);
// Got an entry here
for (int i = 0; i < ne; i++) {
if (fi_entry[i].flags & FI_RECV) {
Expand Down
7 changes: 5 additions & 2 deletions lci/profile/performance_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern LCT_pcounter_ctx_t LCII_pcounter_ctx;
_macro(net_send_failed_lock) \
_macro(net_send_failed_nomem) \
_macro(net_recv_failed_nopacket) \
_macro(net_poll_cq_num) \
_macro(progress_call) \
_macro(packet_get) \
_macro(packet_put) \
Expand All @@ -42,6 +43,8 @@ extern LCT_pcounter_ctx_t LCII_pcounter_ctx;
_macro(unexpected_msg)

#define LCII_PCOUNTER_TIMER_FOR_EACH(_macro) \
_macro(sync_stay_timer) \
_macro(cq_stay_timer) \
_macro(useful_progress_timer) \
_macro(refill_rq_timer) \
_macro(update_posted_recv) \
Expand All @@ -50,11 +53,11 @@ extern LCT_pcounter_ctx_t LCII_pcounter_ctx;
_macro(cq_push_timer) \
_macro(cq_pop_timer) \
_macro(serve_rts_timer) \
_macro(rts_mem_timer) \
_macro(rts_mem_timer) \
_macro(rts_send_timer) \
_macro(serve_rtr_timer) \
_macro(rtr_mem_reg_timer) \
_macro(rtr_put_timer) \
_macro(rtr_put_timer) \
_macro(serve_rdma_timer) \
_macro(packet_stealing_timer) \
_macro(mem_reg_timer) \
Expand Down
4 changes: 4 additions & 0 deletions lci/runtime/completion/cq.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ LCI_error_t LCI_queue_pop(LCI_comp_t cq, LCI_request_t* request)
LCII_context_t* ctx = LCT_queue_pop(cq);
#endif
if (ctx == NULL) return LCI_ERR_RETRY;
LCII_PCOUNTER_ADD(cq_stay_timer, LCT_now() - ctx->time);
*request = LCII_ctx2req(ctx);
LCII_PCOUNTER_ADD(comp_consume, 1);
return LCI_OK;
Expand All @@ -83,6 +84,7 @@ LCI_error_t LCI_queue_wait(LCI_comp_t cq, LCI_request_t* request)
ctx = LCT_queue_pop(cq);
#endif
}
LCII_PCOUNTER_ADD(cq_stay_timer, LCT_now() - ctx->time);
*request = LCII_ctx2req(ctx);
LCII_PCOUNTER_ADD(comp_consume, 1);
return LCI_OK;
Expand All @@ -101,6 +103,7 @@ LCI_error_t LCI_queue_pop_multiple(LCI_comp_t cq, size_t request_count,
ctx = LCT_queue_pop(cq);
#endif
if (ctx != NULL) {
LCII_PCOUNTER_ADD(cq_stay_timer, LCT_now() - ctx->time);
requests[count] = LCII_ctx2req(ctx);
++count;
} else {
Expand All @@ -124,6 +127,7 @@ LCI_error_t LCI_queue_wait_multiple(LCI_comp_t cq, size_t request_count,
ctx = LCT_queue_pop(cq);
#endif
if (ctx != NULL) {
LCII_PCOUNTER_ADD(cq_stay_timer, LCT_now() - ctx->time);
requests[count] = LCII_ctx2req(ctx);
++count;
} else {
Expand Down
3 changes: 3 additions & 0 deletions lci/runtime/completion/cq.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ static inline void LCII_queue_push(LCI_comp_t cq, LCII_context_t* ctx)
#ifdef LCI_USE_INLINE_CQ
LCM_aqueue_push(cq, ctx);
#else
#ifdef LCI_USE_PERFORMANCE_COUNTER
ctx->time = LCT_now();
#endif
LCT_queue_push(cq, ctx);
#endif
LCII_PCOUNTER_END(cq_push_timer);
Expand Down
14 changes: 8 additions & 6 deletions lci/runtime/completion/sync_flag.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ LCI_error_t LCII_sync_signal(LCI_comp_t completion, LCII_context_t* ctx)
{
LCII_sync_t* sync = completion;
LCI_DBG_Assert(sync != NULL, "synchronizer is a NULL pointer!\n");
#ifdef LCI_USE_PERFORMANCE_COUNTER
ctx->time = LCT_now();
#endif
uint_fast64_t tail = 0;
uint_fast64_t pos = 0;
if (sync->threshold > 1) {
Expand Down Expand Up @@ -98,14 +101,13 @@ LCI_error_t LCI_sync_test(LCI_comp_t completion, LCI_request_t request[])
&sync->tail, &expected, top2, LCIU_memory_order_release,
LCIU_memory_order_relaxed);
if (succeed) {
if (request)
for (int i = 0; i < sync->threshold; ++i) {
for (int i = 0; i < sync->threshold; ++i) {
LCII_PCOUNTER_ADD(sync_stay_timer, LCT_now() - sync->ctx[i]->time);
if (request)
request[i] = LCII_ctx2req(sync->ctx[i]);
}
else
for (int i = 0; i < sync->threshold; ++i) {
else
LCIU_free(sync->ctx[i]);
}
}
LCII_PCOUNTER_ADD(comp_consume, sync->threshold);
return LCI_OK;
} else {
Expand Down
3 changes: 3 additions & 0 deletions lci/runtime/lcii.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ typedef struct __attribute__((aligned(LCI_CACHE_LINE))) {
LCI_tag_t tag; // 4 bytes
// used by LCI internally
LCI_comp_t completion; // 8 bytes
#ifdef LCI_USE_PERFORMANCE_COUNTER
LCT_time_t time; // 8 bytes
#endif
} LCII_context_t;
/**
* comp_type: user-defined comp_type
Expand Down
2 changes: 1 addition & 1 deletion lct/api/lct.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ LCT_API int LCT_get_rank();
extern char LCT_hostname[HOST_NAME_MAX + 1];

// time
typedef uint64_t LCT_time_t;
typedef int64_t LCT_time_t;
LCT_API LCT_time_t LCT_now();
LCT_API double LCT_time_to_ns(LCT_time_t time);
LCT_API double LCT_time_to_us(LCT_time_t time);
Expand Down
15 changes: 10 additions & 5 deletions lct/pcounter/pcounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,25 @@ struct timer_t {
}
void end(LCT_time_t time)
{
entry.add(static_cast<int64_t>(time - start_time));
entry.add(time - start_time);
start_time = 0;
--start_count;
}
void add(LCT_time_t time) { entry.add(static_cast<int64_t>(time)); }
void add(LCT_time_t time) { entry.add(time); }
[[nodiscard]] entry_t get() const
{
entry_t ret = entry;
if (consecutive_start) {
// min and max is not valid
ret.min = -1;
ret.max = -1;
ret.min = 1;
ret.max = 0;
}
ret.total = static_cast<int64_t>(LCT_time_to_ns(ret.total));
// else {
// ret.min = static_cast<int64_t>(LCT_time_to_ns(ret.min));
// ret.max = static_cast<int64_t>(LCT_time_to_ns(ret.max));
// }
// ret.total = static_cast<int64_t>(LCT_time_to_ns(ret.total));
// Here we exploit the fact that LCT_time_to_ns is an identity function.
return ret;
}
bool consecutive_start;
Expand Down
2 changes: 1 addition & 1 deletion lct/util/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LCT_time_t LCT_now()
fprintf(stderr, "Cannot get time!\n");
abort();
}
return t1.tv_sec * long(1e9) + t1.tv_nsec;
return (LCT_time_t)t1.tv_sec * (LCT_time_t)1e9 + (LCT_time_t)t1.tv_nsec;
}

double LCT_time_to_ns(LCT_time_t time) { return (double)time; }
Expand Down

0 comments on commit 5772430

Please sign in to comment.