From patchwork Thu May 5 15:17:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9025241 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 57785BF29F for ; Thu, 5 May 2016 15:17:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5B75820384 for ; Thu, 5 May 2016 15:17:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 453572038D for ; Thu, 5 May 2016 15:17:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756834AbcEEPRV (ORCPT ); Thu, 5 May 2016 11:17:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:33825 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756682AbcEEPRT (ORCPT ); Thu, 5 May 2016 11:17:19 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id CE94EAD91; Thu, 5 May 2016 15:17:17 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 762951E09D5; Thu, 5 May 2016 17:17:16 +0200 (CEST) From: Jan Kara To: Jens Axboe Cc: linux-block@vger.kernel.org, Jan Kara Subject: [PATCH 1/9] Better max estimate for line graphs Date: Thu, 5 May 2016 17:17:04 +0200 Message-Id: <1462461432-1900-2-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1462461432-1900-1-git-send-email-jack@suse.cz> References: <1462461432-1900-1-git-send-email-jack@suse.cz> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jan Kara Use maximum of rolling average as the upper range end for the line graph to use better the available space in the plot. Signed-off-by: Jan Kara --- iowatcher/main.c | 33 +++++++++++++++++++-------------- iowatcher/plot.c | 28 ++++++++++++++++++++++++---- iowatcher/plot.h | 1 + 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/iowatcher/main.c b/iowatcher/main.c index 2797afb91866..cbe915571c0e 100644 --- a/iowatcher/main.c +++ b/iowatcher/main.c @@ -774,7 +774,7 @@ static void plot_tput(struct plot *plot, unsigned int min_seconds, struct trace_file *tf; char *units; char line[128]; - u64 max = 0; + u64 max = 0, val; if (active_graphs[TPUT_GRAPH_INDEX] == 0) return; @@ -783,10 +783,12 @@ static void plot_tput(struct plot *plot, unsigned int min_seconds, svg_alloc_legend(plot, num_traces * 2); list_for_each_entry(tf, &all_traces, list) { - if (tf->tput_writes_gld->max > max) - max = tf->tput_writes_gld->max; - if (tf->tput_reads_gld->max > max) - max = tf->tput_reads_gld->max; + val = line_graph_roll_avg_max(tf->tput_writes_gld); + if (val > max) + max = val; + val = line_graph_roll_avg_max(tf->tput_reads_gld); + if (val > max) + max = val; } list_for_each_entry(tf, &all_traces, list) { if (tf->tput_writes_gld->max > 0) @@ -835,7 +837,7 @@ static void plot_fio_tput(struct plot *plot, struct trace_file *tf; char *units; char line[128]; - u64 max = 0; + u64 max = 0, val; if (num_fio_traces == 0 || active_graphs[FIO_GRAPH_INDEX] == 0) return; @@ -844,8 +846,9 @@ static void plot_fio_tput(struct plot *plot, svg_alloc_legend(plot, num_fio_traces); list_for_each_entry(tf, &fio_traces, list) { - if (tf->fio_gld->max > max) - max = tf->fio_gld->max; + val = line_graph_roll_avg_max(tf->fio_gld); + if (val > max) + max = val; } list_for_each_entry(tf, &fio_traces, list) { @@ -1190,7 +1193,7 @@ static void plot_latency(struct plot *plot, unsigned int min_seconds, struct trace_file *tf; char *units; char line[128]; - u64 max = 0; + u64 max = 0, val; if (active_graphs[LATENCY_GRAPH_INDEX] == 0) return; @@ -1199,8 +1202,9 @@ static void plot_latency(struct plot *plot, unsigned int min_seconds, svg_alloc_legend(plot, num_traces); list_for_each_entry(tf, &all_traces, list) { - if (tf->latency_gld->max > max) - max = tf->latency_gld->max; + val = line_graph_roll_avg_max(tf->latency_gld); + if (val > max) + max = val; } list_for_each_entry(tf, &all_traces, list) @@ -1236,14 +1240,15 @@ static void plot_iops(struct plot *plot, unsigned int min_seconds, { struct trace_file *tf; char *units; - u64 max = 0; + u64 max = 0, val; if (active_graphs[IOPS_GRAPH_INDEX] == 0) return; list_for_each_entry(tf, &all_traces, list) { - if (tf->iop_gld->max > max) - max = tf->iop_gld->max; + val = line_graph_roll_avg_max(tf->iop_gld); + if (val > max) + max = val; } list_for_each_entry(tf, &all_traces, list) diff --git a/iowatcher/plot.c b/iowatcher/plot.c index 012d4f97e635..372406b47569 100644 --- a/iowatcher/plot.c +++ b/iowatcher/plot.c @@ -759,6 +759,29 @@ void scale_line_graph_time(u64 *max, char **units) *max /= div; } +static int rolling_span(struct graph_line_data *gld) +{ + if (rolling_avg_secs) + return rolling_avg_secs; + return (gld->stop_seconds - gld->min_seconds) / 25; +} + + +double line_graph_roll_avg_max(struct graph_line_data *gld) +{ + unsigned int i; + int rolling; + double avg, max = 0; + + rolling = rolling_span(gld); + for (i = gld->min_seconds; i < gld->stop_seconds; i++) { + avg = rolling_avg(gld->data, i, rolling); + if (avg > max) + max = avg; + } + return max; +} + int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2) { unsigned int i; @@ -776,10 +799,8 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, if (thresh1 && thresh2) rolling = 0; - else if (rolling_avg_secs) - rolling = rolling_avg_secs; else - rolling = (gld->stop_seconds - gld->min_seconds) / 25; + rolling = rolling_span(gld); for (i = gld->min_seconds; i < gld->stop_seconds; i++) { avg = rolling_avg(gld->data, i, rolling); @@ -795,7 +816,6 @@ int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, x = (double)(i - gld->min_seconds) / xscale; if (!thresh1 && !thresh2) { - if (!printed_header) { write_check(fd, start, strlen(start)); printed_header = 1; diff --git a/iowatcher/plot.h b/iowatcher/plot.h index 7e87b1d134db..d65bbcf3396e 100644 --- a/iowatcher/plot.h +++ b/iowatcher/plot.h @@ -137,6 +137,7 @@ char *pick_fio_color(void); char *pick_cpu_color(void); void reset_cpu_color(void); int svg_io_graph(struct plot *plot, struct graph_dot_data *gdd); +double line_graph_roll_avg_max(struct graph_line_data *gld); int svg_line_graph(struct plot *plot, struct graph_line_data *gld, char *color, int thresh1, int thresh2); struct graph_line_data *alloc_line_data(unsigned int min_seconds, unsigned int max_seconds, unsigned int stop_seconds); struct graph_dot_data *alloc_dot_data(unsigned int min_seconds, unsigned int max_seconds, u64 min_offset, u64 max_offset, unsigned int stop_seconds, char *color, char *label);