Skip to content

Commit 4c3635e

Browse files
committed
stat: make latency buckets configurable
Allow the user to set how many latency buckets there are at the finest granularity (when unset the default is 10). The number of larger granularity buckets is calculated as the finest + 2. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent d3dacdc commit 4c3635e

File tree

9 files changed

+233
-146
lines changed

9 files changed

+233
-146
lines changed

HOWTO

+12-1
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,10 @@ Command line options
299299
Use the directory specified by `path` for generated state files instead
300300
of the current working directory.
301301

302+
.. option:: --latency-stats=nr
303+
304+
Change default latency stats number. The default buckets number is 10.
305+
302306
Any parameters following the options will be assumed to be job files, unless
303307
they match a job file parameter. Multiple job files can be listed and each job
304308
file will be regarded as a separate group. Fio will :option:`stonewall`
@@ -4045,13 +4049,20 @@ field was introduced or whether it's specific to some terse version):
40454049

40464050
<=1, 2, 4, 8, 16, 32, >=64
40474051

4052+
I/O latencies nanoseconds::
4053+
4054+
<=2, 4, 10, 20, 50, 100, 250, 500, 750, 1000
4055+
The number of buckets may vary.
4056+
40484057
I/O latencies microseconds::
40494058

40504059
<=2, 4, 10, 20, 50, 100, 250, 500, 750, 1000
4060+
The number of buckets may vary.
40514061

40524062
I/O latencies milliseconds::
40534063

40544064
<=2, 4, 10, 20, 50, 100, 250, 500, 750, 1000, 2000, >=2000
4065+
The number of buckets may vary.
40554066

40564067
Disk utilization [v3]::
40574068

@@ -4084,7 +4095,7 @@ minimal output v3, separated by semicolons::
40844095
In client/server mode terse output differs from what appears when jobs are run
40854096
locally. Disk utilization data is omitted from the standard terse output and
40864097
for v3 and later appears on its own separate line at the end of each terse
4087-
reporting cycle.
4098+
reporting cycle. The number of buckets may vary.
40884099

40894100

40904101
JSON output

client.c

+2
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,8 @@ int fio_handle_clients(struct client_ops *ops)
21502150

21512151
fio_client_json_fini();
21522152

2153+
stat_free_lat(&client_ts);
2154+
21532155
free(pfds);
21542156
return retval || error_clients;
21552157
}

debug.h

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ enum {
2323
FD_STEADYSTATE,
2424
FD_HELPERTHREAD,
2525
FD_ZBD,
26+
FD_STAT,
2627
FD_DEBUG_MAX,
2728
};
2829

fio.1

+16-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ Set this \fIcommand\fR as remote trigger.
176176
.BI \-\-aux\-path \fR=\fPpath
177177
Use the directory specified by \fIpath\fP for generated state files instead
178178
of the current working directory.
179+
.TP
180+
.BI \-\-latency\-stats \fR=\fPnr
181+
Change default latency stats number. The default buckets number is 10.
179182
.SH "JOB FILE FORMAT"
180183
Any parameters following the options will be assumed to be job files, unless
181184
they match a job file parameter. Multiple job files can be listed and each job
@@ -3748,11 +3751,22 @@ I/O depths:
37483751
.RS
37493752
.P
37503753
.B
3754+
I/O latencies nanoseconds:
3755+
.RE
3756+
.P
3757+
.nf
3758+
<=2, 4, 10, 20, 50, 100, 250, 500, 750, 1000
3759+
The number of buckets may vary.
3760+
.fi
3761+
.RS
3762+
.P
3763+
.B
37513764
I/O latencies microseconds:
37523765
.RE
37533766
.P
37543767
.nf
37553768
<=2, 4, 10, 20, 50, 100, 250, 500, 750, 1000
3769+
The number of buckets may vary.
37563770
.fi
37573771
.RS
37583772
.P
@@ -3762,6 +3776,7 @@ I/O latencies milliseconds:
37623776
.P
37633777
.nf
37643778
<=2, 4, 10, 20, 50, 100, 250, 500, 750, 1000, 2000, >=2000
3779+
The number of buckets may vary.
37653780
.fi
37663781
.RS
37673782
.P
@@ -3813,7 +3828,7 @@ minimal output v3, separated by semicolons:
38133828
In client/server mode terse output differs from what appears when jobs are run
38143829
locally. Disk utilization data is omitted from the standard terse output and
38153830
for v3 and later appears on its own separate line at the end of each terse
3816-
reporting cycle.
3831+
reporting cycle. The number of buckets may vary.
38173832
.SH JSON OUTPUT
38183833
The \fBjson\fR output format is intended to be both human readable and convenient
38193834
for automated parsing. For the most part its sections mirror those of the

init.c

+20-1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ static struct option l_opts[FIO_NR_OPTIONS] = {
293293
.has_arg = no_argument,
294294
.val = 'A' | FIO_CLIENT_FLAG,
295295
},
296+
{
297+
.name = (char *) "latency-stats",
298+
.has_arg = required_argument,
299+
.val = 'n' | FIO_CLIENT_FLAG,
300+
},
296301
{
297302
.name = NULL,
298303
},
@@ -537,6 +542,8 @@ static void put_job(struct thread_data *td)
537542
if (td->o.name)
538543
free(td->o.name);
539544

545+
stat_free_lat(&td->ts);
546+
540547
memset(td, 0, sizeof(*td));
541548
segments[cur_segment].nr_threads--;
542549
thread_number--;
@@ -1532,6 +1539,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
15321539
td->ts.clat_low_prio_stat[i].min_val = ULONG_MAX;
15331540
}
15341541
td->ts.sync_stat.min_val = ULONG_MAX;
1542+
stat_alloc_lat(&td->ts);
15351543
td->ddir_seq_nr = o->ddir_seq_nr;
15361544

15371545
if ((o->stonewall || o->new_group) && prev_group_jobs) {
@@ -2241,6 +2249,7 @@ static void usage(const char *name)
22412249
printf(" --trigger=cmd\t\tSet this command as local trigger\n");
22422250
printf(" --trigger-remote=cmd\tSet this command as remote trigger\n");
22432251
printf(" --aux-path=path\tUse this path for fio state generated files\n");
2252+
printf(" --latency-stats=nr\tChange default latency stats number\n");
22442253
printf("\nFio was written by Jens Axboe <[email protected]>\n");
22452254
}
22462255

@@ -2322,6 +2331,10 @@ const struct debug_level debug_levels[] = {
23222331
.help = "Zoned Block Device logging",
23232332
.shift = FD_ZBD,
23242333
},
2334+
{ .name = "stat",
2335+
.help = "Statisitics logging",
2336+
.shift = FD_STAT,
2337+
},
23252338
{ .name = NULL, },
23262339
};
23272340

@@ -2906,11 +2919,17 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
29062919
}
29072920
trigger_timeout /= 1000000;
29082921
break;
2909-
29102922
case 'A':
29112923
did_arg = true;
29122924
merge_blktrace_only = true;
29132925
break;
2926+
case 'n':
2927+
if (!stat_set_lat(atoi(optarg))) {
2928+
log_err("fio: bad latency stats number\n");
2929+
exit_val = 1;
2930+
do_exit++;
2931+
}
2932+
break;
29142933
case '?':
29152934
log_err("%s: unrecognized option '%s'\n", argv[0],
29162935
argv[optind - 1]);

io_u.c

+10-95
Original file line numberDiff line numberDiff line change
@@ -1045,129 +1045,44 @@ void io_u_mark_depth(struct thread_data *td, unsigned int nr)
10451045

10461046
static void io_u_mark_lat_nsec(struct thread_data *td, unsigned long long nsec)
10471047
{
1048-
int idx = 0;
1048+
int idx;
10491049

10501050
assert(nsec < 1000);
10511051

1052-
switch (nsec) {
1053-
case 750 ... 999:
1054-
idx = 9;
1055-
break;
1056-
case 500 ... 749:
1057-
idx = 8;
1058-
break;
1059-
case 250 ... 499:
1060-
idx = 7;
1061-
break;
1062-
case 100 ... 249:
1063-
idx = 6;
1064-
break;
1065-
case 50 ... 99:
1066-
idx = 5;
1067-
break;
1068-
case 20 ... 49:
1069-
idx = 4;
1070-
break;
1071-
case 10 ... 19:
1072-
idx = 3;
1073-
break;
1074-
case 4 ... 9:
1075-
idx = 2;
1076-
break;
1077-
case 2 ... 3:
1078-
idx = 1;
1079-
fallthrough;
1080-
case 0 ... 1:
1081-
break;
1082-
}
1052+
idx = stat_get_lat_idx(nsec);
10831053

10841054
assert(idx < FIO_IO_U_LAT_N_NR);
10851055
td->ts.io_u_lat_n[idx]++;
10861056
}
10871057

10881058
static void io_u_mark_lat_usec(struct thread_data *td, unsigned long long usec)
10891059
{
1090-
int idx = 0;
1060+
int idx;
10911061

10921062
assert(usec < 1000 && usec >= 1);
10931063

1094-
switch (usec) {
1095-
case 750 ... 999:
1096-
idx = 9;
1097-
break;
1098-
case 500 ... 749:
1099-
idx = 8;
1100-
break;
1101-
case 250 ... 499:
1102-
idx = 7;
1103-
break;
1104-
case 100 ... 249:
1105-
idx = 6;
1106-
break;
1107-
case 50 ... 99:
1108-
idx = 5;
1109-
break;
1110-
case 20 ... 49:
1111-
idx = 4;
1112-
break;
1113-
case 10 ... 19:
1114-
idx = 3;
1115-
break;
1116-
case 4 ... 9:
1117-
idx = 2;
1118-
break;
1119-
case 2 ... 3:
1120-
idx = 1;
1121-
fallthrough;
1122-
case 0 ... 1:
1123-
break;
1124-
}
1064+
idx = stat_get_lat_idx(usec);
11251065

11261066
assert(idx < FIO_IO_U_LAT_U_NR);
11271067
td->ts.io_u_lat_u[idx]++;
11281068
}
11291069

11301070
static void io_u_mark_lat_msec(struct thread_data *td, unsigned long long msec)
11311071
{
1132-
int idx = 0;
1072+
int idx;
1073+
int nr = stat_get_lat_m_nr();
11331074

11341075
assert(msec >= 1);
11351076

11361077
switch (msec) {
11371078
default:
1138-
idx = 11;
1079+
idx = nr - 1;
11391080
break;
11401081
case 1000 ... 1999:
1141-
idx = 10;
1142-
break;
1143-
case 750 ... 999:
1144-
idx = 9;
1145-
break;
1146-
case 500 ... 749:
1147-
idx = 8;
1082+
idx = nr - 2;
11481083
break;
1149-
case 250 ... 499:
1150-
idx = 7;
1151-
break;
1152-
case 100 ... 249:
1153-
idx = 6;
1154-
break;
1155-
case 50 ... 99:
1156-
idx = 5;
1157-
break;
1158-
case 20 ... 49:
1159-
idx = 4;
1160-
break;
1161-
case 10 ... 19:
1162-
idx = 3;
1163-
break;
1164-
case 4 ... 9:
1165-
idx = 2;
1166-
break;
1167-
case 2 ... 3:
1168-
idx = 1;
1169-
fallthrough;
1170-
case 0 ... 1:
1084+
case 1 ... 999:
1085+
idx = stat_get_lat_idx(msec);
11711086
break;
11721087
}
11731088

server.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct fio_net_cmd_reply {
4848
};
4949

5050
enum {
51-
FIO_SERVER_VER = 91,
51+
FIO_SERVER_VER = 92,
5252

5353
FIO_SERVER_MAX_FRAGMENT_PDU = 1024,
5454
FIO_SERVER_MAX_CMD_MB = 2048,

0 commit comments

Comments
 (0)