Skip to content

Commit c3c85d6

Browse files
committed
stat: Allocate latency stats to change number
This icludes changes below also. 1. Ramp up fio server version 2. Add --latency-stats option to change default latency stats number 3. MAINT: Delete unused latency case values 4. MAINT: Add debug option statistics logging 5. Add support for changeable latency statistics depth levels 6. Update manual and help to add latency-stats option 7. Fix to show latency stats changed depth levels 8. Add struct thread_stat pointer member value padding Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent d3dacdc commit c3c85d6

File tree

9 files changed

+212
-144
lines changed

9 files changed

+212
-144
lines changed

HOWTO

+4
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.
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`

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

+3
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.
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

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)