Flexible I/O Tester development
 help / color / mirror / Atom feed
* [PATCH 0/2] stat cleanup/bugfix patches
@ 2019-02-07 15:51 vincentfu
  2019-02-07 15:51 ` [PATCH 1/2] stat: clean up calc_clat_percentiles vincentfu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: vincentfu @ 2019-02-07 15:51 UTC (permalink / raw)
  To: axboe, fio; +Cc: Vincent Fu

From: Vincent Fu <vincent.fu@wdc.com>

Jens, please consider these two cleanup/bugfix patches for stat.c

Vincent

Vincent Fu (2):
  stat: clean up calc_clat_percentiles
  stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns'
    parent

 stat.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

-- 
2.17.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] stat: clean up calc_clat_percentiles
  2019-02-07 15:51 [PATCH 0/2] stat cleanup/bugfix patches vincentfu
@ 2019-02-07 15:51 ` vincentfu
  2019-02-07 15:51 ` [PATCH 2/2] stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns' parent vincentfu
  2019-02-07 16:49 ` [PATCH 0/2] stat cleanup/bugfix patches Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: vincentfu @ 2019-02-07 15:51 UTC (permalink / raw)
  To: axboe, fio; +Cc: Vincent Fu

From: Vincent Fu <vincent.fu@wdc.com>

We already know the size of the buffer needed. So there
is no need to do anything fancy when allocating it.
---
 stat.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/stat.c b/stat.c
index 351c49cc..7c843e6b 100644
--- a/stat.c
+++ b/stat.c
@@ -139,7 +139,6 @@ unsigned int calc_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
 {
 	unsigned long long sum = 0;
 	unsigned int len, i, j = 0;
-	unsigned int oval_len = 0;
 	unsigned long long *ovals = NULL;
 	bool is_last;
 
@@ -161,6 +160,10 @@ unsigned int calc_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
 	if (len > 1)
 		qsort((void *)plist, len, sizeof(plist[0]), double_cmp);
 
+	ovals = malloc(len * sizeof(*ovals));
+	if (!ovals)
+		return 0;
+
 	/*
 	 * Calculate bucket values, note down max and min values
 	 */
@@ -170,11 +173,6 @@ unsigned int calc_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
 		while (sum >= (plist[j].u.f / 100.0 * nr)) {
 			assert(plist[j].u.f <= 100.0);
 
-			if (j == oval_len) {
-				oval_len += 100;
-				ovals = realloc(ovals, oval_len * sizeof(*ovals));
-			}
-
 			ovals[j] = plat_idx_to_val(i);
 			if (ovals[j] < *minv)
 				*minv = ovals[j];
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns' parent
  2019-02-07 15:51 [PATCH 0/2] stat cleanup/bugfix patches vincentfu
  2019-02-07 15:51 ` [PATCH 1/2] stat: clean up calc_clat_percentiles vincentfu
@ 2019-02-07 15:51 ` vincentfu
  2019-02-07 16:49 ` [PATCH 0/2] stat cleanup/bugfix patches Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: vincentfu @ 2019-02-07 15:51 UTC (permalink / raw)
  To: axboe, fio; +Cc: Vincent Fu

From: Vincent Fu <vincent.fu@wdc.com>

In the JSON output, the 'percentiles' object currently always appears within the
'clat_ns' object. Put it inside the 'lat_ns' object when --lat_percentiles=1 is set.
---
 stat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/stat.c b/stat.c
index 7c843e6b..c1f46e1d 100644
--- a/stat.c
+++ b/stat.c
@@ -1088,7 +1088,8 @@ static void add_ddir_status_json(struct thread_stat *ts,
 		len = 0;
 
 	percentile_object = json_create_object();
-	json_object_add_value_object(tmp_object, "percentile", percentile_object);
+	if (ts->clat_percentiles)
+		json_object_add_value_object(tmp_object, "percentile", percentile_object);
 	for (i = 0; i < len; i++) {
 		snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f);
 		json_object_add_value_int(percentile_object, (const char *)buf, ovals[i]);
@@ -1127,6 +1128,8 @@ static void add_ddir_status_json(struct thread_stat *ts,
 	json_object_add_value_int(tmp_object, "max", max);
 	json_object_add_value_float(tmp_object, "mean", mean);
 	json_object_add_value_float(tmp_object, "stddev", dev);
+	if (ts->lat_percentiles)
+		json_object_add_value_object(tmp_object, "percentile", percentile_object);
 	if (output_format & FIO_OUTPUT_JSON_PLUS && ts->lat_percentiles)
 		json_object_add_value_object(tmp_object, "bins", clat_bins_object);
 
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] stat cleanup/bugfix patches
  2019-02-07 15:51 [PATCH 0/2] stat cleanup/bugfix patches vincentfu
  2019-02-07 15:51 ` [PATCH 1/2] stat: clean up calc_clat_percentiles vincentfu
  2019-02-07 15:51 ` [PATCH 2/2] stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns' parent vincentfu
@ 2019-02-07 16:49 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-02-07 16:49 UTC (permalink / raw)
  To: vincentfu, fio; +Cc: Vincent Fu

On 2/7/19 8:51 AM, vincentfu@gmail.com wrote:
> From: Vincent Fu <vincent.fu@wdc.com>
> 
> Jens, please consider these two cleanup/bugfix patches for stat.c
> 
> Vincent
> 
> Vincent Fu (2):
>   stat: clean up calc_clat_percentiles
>   stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns'
>     parent
> 
>  stat.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)

Looks good, applied both. Thanks Vincent.

-- 
Jens Axboe



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-02-07 16:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-07 15:51 [PATCH 0/2] stat cleanup/bugfix patches vincentfu
2019-02-07 15:51 ` [PATCH 1/2] stat: clean up calc_clat_percentiles vincentfu
2019-02-07 15:51 ` [PATCH 2/2] stat: put 'percentiles' object in appropriate 'clat_ns' or 'lat_ns' parent vincentfu
2019-02-07 16:49 ` [PATCH 0/2] stat cleanup/bugfix patches Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox