Commit 9ef4fea2 authored by Joanne Hugé's avatar Joanne Hugé

Add histogram for diff ts measures

parent 2ba307c4
......@@ -26,6 +26,7 @@
#define MAX_KERNEL_LATENCY 1000
#define MAX_RTT 1000
#define MAX_JITTER 1000
#define MAX_DIFF_TS 1000
#define MAX_BUFFER_SIZE 1024
......
......@@ -65,6 +65,7 @@ static void sighand(int sig_num);
static uint64_t kernel_latency_hist[MAX_KERNEL_LATENCY];
static uint64_t jitter_hist[MAX_JITTER];
static uint64_t diff_ts_hist[MAX_DIFF_TS];
static main_param_t main_params;
static thread_param_t thread_params;
static ingress_param_t ingress_params;
......@@ -84,6 +85,7 @@ static pthread_cond_t emit_signal_ts_received;
static int64_t min_diff_ts = INT_MAX;
static int64_t max_diff_ts = 0;
static int64_t avg_diff_ts = 0;
static uint64_t high_diff_ts = 0;
static char ts_tracemark_buf[64];
......@@ -264,6 +266,14 @@ static void *tsn_thread(void *p) {
max_diff_ts = _max_(diff_us, max_diff_ts);
avg_diff_ts = (avg_diff_ts * ingress_stats.packets_received + diff_us) / (ingress_stats.packets_received + 1);
// Histogram
if (enable_histograms) {
if (diff_us > ((int)MAX_DIFF_TS) || diff_us < 0)
high_diff_ts++;
else
diff_ts_hist[diff_us]++;
}
// If the latency hits the tracing threshold, stop tracing
if (main_params.enable_tracing &&
(max_diff_ts > ((int64_t)thread_params.latency_threshold))) {
......@@ -400,6 +410,7 @@ int main(int argc, char *argv[]) {
if (enable_histograms) {
memset(kernel_latency_hist, 0, sizeof(kernel_latency_hist));
memset(jitter_hist, 0, sizeof(jitter_hist));
memset(diff_ts_hist, 0, sizeof(diff_ts_hist));
}
// Enable ftrace
......@@ -481,6 +492,21 @@ static void print_histograms() {
duration_hour = duration / NSEC_PER_SEC / 3600;
duration_minutes = duration / NSEC_PER_SEC / 60 - duration_hour * 60;
if (thread_params.enable_diff_ts) {
printf("# RX latency histogram\n");
max_latency = histogram_max(diff_ts_hist, MAX_DIFF_TS - 1);
for (int j = 0; j < max_latency; j++)
printf(" %06d %015" PRIi64 "\n", j, diff_ts_hist[j]);
printf(
"# Duration: %dh%d\n"
"# Lost packets: %" PRIu64 "\n",
duration_hour, duration_minutes, high_diff_ts);
}
else {
max_jitter = histogram_max(jitter_hist, MAX_JITTER - 1);
min_jitter = histogram_min(jitter_hist, MAX_JITTER - 1);
......@@ -510,6 +536,7 @@ static void print_histograms() {
"# Lost packets: %" PRIu64 "\n",
MAX_JITTER / 2 - min_jitter, duration_hour, duration_minutes,
ingress_stats.high_jitter);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment