|
|
|
@ -56,12 +56,12 @@ struct grpc_timers_log { |
|
|
|
|
int num_entries; |
|
|
|
|
int capacity; |
|
|
|
|
int capacity_limit; |
|
|
|
|
FILE *fp; |
|
|
|
|
FILE* fp; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
grpc_timers_log* grpc_timers_log_global = NULL; |
|
|
|
|
|
|
|
|
|
grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE *dump) { |
|
|
|
|
grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE* dump) { |
|
|
|
|
grpc_timers_log* log = gpr_malloc(sizeof(*log)); |
|
|
|
|
|
|
|
|
|
/* TODO (vpai): Allow allocation below limit */ |
|
|
|
@ -78,22 +78,22 @@ grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE *dump) { |
|
|
|
|
return log; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void log_report_locked(grpc_timers_log *log) { |
|
|
|
|
FILE *fp = log->fp; |
|
|
|
|
static void log_report_locked(grpc_timers_log* log) { |
|
|
|
|
FILE* fp = log->fp; |
|
|
|
|
int i; |
|
|
|
|
for (i=0;i<log->num_entries;i++) { |
|
|
|
|
for (i = 0; i < log->num_entries; i++) { |
|
|
|
|
grpc_timer_entry* entry = &(log->log[i]); |
|
|
|
|
fprintf(fp, "GRPC_LAT_PROF "); |
|
|
|
|
grpc_precise_clock_print(&entry->tm, fp); |
|
|
|
|
fprintf(fp, " %s#%d,%s:%d\n", entry->tag, entry->seq, |
|
|
|
|
entry->file, entry->line); |
|
|
|
|
fprintf(fp, " %s#%d,%s:%d\n", entry->tag, entry->seq, entry->file, |
|
|
|
|
entry->line); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Now clear out the log */ |
|
|
|
|
log->num_entries=0; |
|
|
|
|
log->num_entries = 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void grpc_timers_log_destroy(grpc_timers_log *log) { |
|
|
|
|
void grpc_timers_log_destroy(grpc_timers_log* log) { |
|
|
|
|
gpr_mu_lock(&log->mu); |
|
|
|
|
log_report_locked(log); |
|
|
|
|
gpr_mu_unlock(&log->mu); |
|
|
|
@ -104,8 +104,8 @@ void grpc_timers_log_destroy(grpc_timers_log *log) { |
|
|
|
|
gpr_free(log); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void grpc_timers_log_add(grpc_timers_log *log, const char *tag, int seq, |
|
|
|
|
const char *file, int line) { |
|
|
|
|
void grpc_timers_log_add(grpc_timers_log* log, const char* tag, int seq, |
|
|
|
|
const char* file, int line) { |
|
|
|
|
grpc_timer_entry* entry; |
|
|
|
|
|
|
|
|
|
/* TODO (vpai) : Improve concurrency */ |
|
|
|
@ -132,9 +132,7 @@ void grpc_timers_log_global_init(void) { |
|
|
|
|
void grpc_timers_log_global_destroy(void) { |
|
|
|
|
grpc_timers_log_destroy(grpc_timers_log_global); |
|
|
|
|
} |
|
|
|
|
#else /* !GRPC_LATENCY_PROFILER */ |
|
|
|
|
void grpc_timers_log_global_init(void) { |
|
|
|
|
} |
|
|
|
|
void grpc_timers_log_global_destroy(void) { |
|
|
|
|
} |
|
|
|
|
#else /* !GRPC_LATENCY_PROFILER */ |
|
|
|
|
void grpc_timers_log_global_init(void) {} |
|
|
|
|
void grpc_timers_log_global_destroy(void) {} |
|
|
|
|
#endif /* GRPC_LATENCY_PROFILER */ |
|
|
|
|