Skip to contentSkip to conversation

stat: change json+ output format so that instead of printing the raw clat data structure, use actual durations instead of array indices and print only bins with nonzero counts

PATCH In review Vincent Fu 2 participants 8 messages Apr 16, 2017 – May 3, 2017 Kbuild

lore
Share & tools
lore

Vincent Fu

author
#0 lore raw

PATCH 1/6 stat: change json+ output format so that instead of printing the raw clat data structure, use actual durations instead of array indices and print only bins with nonzero counts

From: Vincent Fu <[email protected]>

---
 stat.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
stat.c +5 -6
index fde7af2..4a6e1b9 100644
@@ -98,7 +98,7 @@ static unsigned int plat_val_to_idx(unsigned int val)
  * Convert the given index of the bucket array to the value
  * represented by the bucket
  */
-static unsigned int plat_idx_to_val(unsigned int idx)
+static unsigned long long plat_idx_to_val(unsigned int idx)
 {
 	unsigned int error_bits, k, base;
 
@@ -972,12 +972,11 @@ static void add_ddir_status_json(struct thread_stat *ts,
 		clat_bins_object = json_create_object();
 		json_object_add_value_object(tmp_object, "bins", clat_bins_object);
 		for(i = 0; i < FIO_IO_U_PLAT_NR; i++) {
-			snprintf(buf, sizeof(buf), "%d", i);
-			json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
+			if (ts->io_u_plat[ddir][i]) {
+				snprintf(buf, sizeof(buf), "%llu", plat_idx_to_val(i));
+				json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
+			}
 		}
-		json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_BITS", FIO_IO_U_PLAT_BITS);
-		json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_VAL", FIO_IO_U_PLAT_VAL);
-		json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_NR", FIO_IO_U_PLAT_NR);
 	}
 
 	if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/6 Revert "tools/fio_latency2csv.py: add tool that converts json+ to CSV"

From: Vincent Fu <[email protected]>

This reverts commit 6cd4d583c75042bf1edd3d2d5c6626883755bfe4. The script is no longer needed because the json+ output format now automatically does the transformation carried out by the script.

---
 Makefile                 |   2 +-
 tools/fio_latency2csv.py | 101 -----------------------------------------------
 2 files changed, 1 insertion(+), 102 deletions(-)
 delete mode 100755 tools/fio_latency2csv.py
Makefile +1 -1
index 66083ff..1f0f5d0 100644
@@ -26,7 +26,7 @@ OPTFLAGS= -g -ffast-math
 CFLAGS	= -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) -I. -I$(SRCDIR)
 LIBS	+= -lm $(EXTLIBS)
 PROGS	= fio
-SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio tools/fiologparser.py tools/fio_latency2csv.py tools/hist/fiologparser_hist.py)
+SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio tools/fiologparser.py tools/hist/fiologparser_hist.py)
 
 ifndef CONFIG_FIO_NO_OPT
   CFLAGS += -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
tools/fio_latency2csv.py deleted +0 -101

101 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 3/6 server: update server version for the addition of the --stats option

In reply to Vincent Fu

From: Vincent Fu <[email protected]>

---
 server.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
server.h +1 -1
index 798d5a8..5c720d4 100644
@@ -49,7 +49,7 @@ struct fio_net_cmd_reply {
 };
 
 enum {
-	FIO_SERVER_VER			= 60,
+	FIO_SERVER_VER			= 61,
 
 	FIO_SERVER_MAX_FRAGMENT_PDU	= 1024,
 	FIO_SERVER_MAX_CMD_MB		= 2048,
Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 4/6 stat: reset_io_stats: fix a problem, rearrange some code

In reply to Vincent Fu

From: Vincent Fu <[email protected]>

1) Make sure all the io_u_lat_u/m are reset
2) Only need to zero out total_submit/complete once
3) Reset total/short/drop_io_u inside the other loop that iterates over data directions

---
 stat.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
stat.c +9 -8
index 4a6e1b9..5061bea 100644
@@ -2171,6 +2171,9 @@ void reset_io_stats(struct thread_data *td)
 
 		ts->io_bytes[i] = 0;
 		ts->runtime[i] = 0;
+		ts->total_io_u[i] = 0;
+		ts->short_io_u[i] = 0;
+		ts->drop_io_u[i] = 0;
 
 		for (j = 0; j < FIO_IO_U_PLAT_NR; j++)
 			ts->io_u_plat[i][j] = 0;
@@ -2180,17 +2183,15 @@ void reset_io_stats(struct thread_data *td)
 		ts->io_u_map[i] = 0;
 		ts->io_u_submit[i] = 0;
 		ts->io_u_complete[i] = 0;
+	}
+
+	for (i = 0; i < FIO_IO_U_LAT_U_NR; i++)
 		ts->io_u_lat_u[i] = 0;
+	for (i = 0; i < FIO_IO_U_LAT_M_NR; i++)
 		ts->io_u_lat_m[i] = 0;
-		ts->total_submit = 0;
-		ts->total_complete = 0;
-	}
 
-	for (i = 0; i < 3; i++) {
-		ts->total_io_u[i] = 0;
-		ts->short_io_u[i] = 0;
-		ts->drop_io_u[i] = 0;
-	}
+	ts->total_submit = 0;
+	ts->total_complete = 0;
 }
 
 static void __add_stat_to_log(struct io_log *iolog, enum fio_ddir ddir,
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH 5/6 client/server: make sure that all elements in io_u_lat_m[] are transferred and received

In reply to Vincent Fu

From: Vincent Fu <[email protected]>

FIO_IO_U_LAT_U_NR is 10 whereas FIO_IO_U_LAT_M_NR is 12. So we must iterate over io_u_lat_u and io_u_lat_m separately.

---
 client.c | 4 ++--
 server.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
client.c +2 -2
index 7934661..80096bf 100644
@@ -908,10 +908,10 @@ static void convert_ts(struct thread_stat *dst, struct thread_stat *src)
 		dst->io_u_complete[i]	= le32_to_cpu(src->io_u_complete[i]);
 	}
 
-	for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) {
+	for (i = 0; i < FIO_IO_U_LAT_U_NR; i++)
 		dst->io_u_lat_u[i]	= le32_to_cpu(src->io_u_lat_u[i]);
+	for (i = 0; i < FIO_IO_U_LAT_M_NR; i++)
 		dst->io_u_lat_m[i]	= le32_to_cpu(src->io_u_lat_m[i]);
-	}
 
 	for (i = 0; i < DDIR_RWDIR_CNT; i++)
 		for (j = 0; j < FIO_IO_U_PLAT_NR; j++)
server.c +2 -2
index 1b3bc30..1e269c2 100644
@@ -1497,10 +1497,10 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs)
 		p.ts.io_u_complete[i]	= cpu_to_le32(ts->io_u_complete[i]);
 	}
 
-	for (i = 0; i < FIO_IO_U_LAT_U_NR; i++) {
+	for (i = 0; i < FIO_IO_U_LAT_U_NR; i++)
 		p.ts.io_u_lat_u[i]	= cpu_to_le32(ts->io_u_lat_u[i]);
+	for (i = 0; i < FIO_IO_U_LAT_M_NR; i++)
 		p.ts.io_u_lat_m[i]	= cpu_to_le32(ts->io_u_lat_m[i]);
-	}
 
 	for (i = 0; i < DDIR_RWDIR_CNT; i++)
 		for (j = 0; j < FIO_IO_U_PLAT_NR; j++)
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH 6/6 gettime: make utime_since_now and mtime_since_now consistent in how they record the caller and put this all behind FIO_DEBUG_TIME

In reply to Vincent Fu

From: Vincent Fu <[email protected]>

---
 gettime.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
gettime.c +11 -0
index 85ba7cb..628aad6 100644
@@ -402,8 +402,14 @@ uint64_t utime_since(const struct timeval *s, const struct timeval *e)
 uint64_t utime_since_now(const struct timeval *s)
 {
 	struct timeval t;
+#ifdef FIO_DEBUG_TIME
+	void *p = __builtin_return_address(0);
 
+	fio_gettime(&t, p);
+#else
 	fio_gettime(&t, NULL);
+#endif
+
 	return utime_since(s, &t);
 }
 
@@ -429,9 +435,14 @@ uint64_t mtime_since(const struct timeval *s, const struct timeval *e)
 uint64_t mtime_since_now(const struct timeval *s)
 {
 	struct timeval t;
+#ifdef FIO_DEBUG_TIME
 	void *p = __builtin_return_address(0);
 
 	fio_gettime(&t, p);
+#else
+	fio_gettime(&t, NULL);
+#endif
+
 	return mtime_since(s, &t);
 }
 
Signature · 1 line
2.7.4
author
#6 lore raw
In reply to Vincent Fu

Jens, can you review this patch series?

The json+ change (PATCH 1/6 and 2/6) was a request from a user and makes the output easier to use.

The other patches fix problems with resetting the latency counters when --latency-target is used (PATCH 4/6) and make sure some forgotten latency counters are transferred in client/server mode (PATCH 5/6). PATCH 6/6 is a cleanup. You can ignore PATCH 3/6.

Vincent

Quoted 36 lines · Vincent Fu

From: Vincent Fu<[email protected]>

---
  stat.c | 11 +++++------
  1 file changed, 5 insertions(+), 6 deletions(-)
stat.c +5 -6
index fde7af2..4a6e1b9 100644
@@ -98,7 +98,7 @@ static unsigned int plat_val_to_idx(unsigned int val)
   * Convert the given index of the bucket array to the value
   * represented by the bucket
   */
-static unsigned int plat_idx_to_val(unsigned int idx)
+static unsigned long long plat_idx_to_val(unsigned int idx)
  {
  	unsigned int error_bits, k, base;
 
@@ -972,12 +972,11 @@ static void add_ddir_status_json(struct thread_stat *ts,
  		clat_bins_object = json_create_object();
  		json_object_add_value_object(tmp_object, "bins", clat_bins_object);
  		for(i = 0; i < FIO_IO_U_PLAT_NR; i++) {
-			snprintf(buf, sizeof(buf), "%d", i);
-			json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
+			if (ts->io_u_plat[ddir][i]) {
+				snprintf(buf, sizeof(buf), "%llu", plat_idx_to_val(i));
+				json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
+			}
  		}
-		json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_BITS", FIO_IO_U_PLAT_BITS);
-		json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_VAL", FIO_IO_U_PLAT_VAL);
-		json_object_add_value_int(clat_bins_object, "FIO_IO_U_PLAT_NR", FIO_IO_U_PLAT_NR);
  	}
 
  	if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
#7 lore raw
Quoted 9 lines · Vincent Fu

Jens, can you review this patch series?

The json+ change (PATCH 1/6 and 2/6) was a request from a user and makes the output easier to use.

The other patches fix problems with resetting the latency counters when --latency-target is used (PATCH 4/6) and make sure some forgotten latency counters are transferred in client/server mode (PATCH 5/6). PATCH 6/6 is a cleanup. You can ignore PATCH 3/6.

Looks good to me, this got lost since it arrived while I was away on vacation. I applied the series, skipping patch #3. Thanks Vincent!

Signature · 1 line
Jens Axboe