Home | History | Annotate | Download | only in fio

Lines Matching defs:ts

27 	struct thread_stat *ts = &td->ts;
30 ts->usr_time = ts->sys_time = 0;
31 ts->ctx = 0;
32 ts->minf = ts->majf = 0;
37 struct thread_stat *ts = &td->ts;
40 ts->usr_time += mtime_since(&td->ru_start.ru_utime,
42 ts->sys_time += mtime_since(&td->ru_start.ru_stime,
44 ts->ctx += td->ru_end.ru_nvcsw + td->ru_end.ru_nivcsw
46 ts->minf += td->ru_end.ru_minflt - td->ru_start.ru_minflt;
47 ts->majf += td->ru_end.ru_majflt - td->ru_start.ru_majflt;
338 static void stat_calc_lat(struct thread_stat *ts, double *dst,
341 unsigned long total = ddir_rw_sum(ts->total_io_u);
358 void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat)
360 stat_calc_lat(ts, io_u_lat, ts->io_u_lat_u, FIO_IO_U_LAT_U_NR);
363 void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat)
365 stat_calc_lat(ts, io_u_lat, ts->io_u_lat_m, FIO_IO_U_LAT_M_NR);
387 static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
399 if (!ts->runtime[ddir])
403 runt = ts->runtime[ddir];
405 bw = (1000 * ts->io_bytes[ddir]) / runt;
406 io_p = num2str(ts->io_bytes[ddir], 4, 1, i2p, N2S_BYTE);
407 bw_p = num2str(bw, 4, 1, i2p, ts->unit_base);
408 bw_p_alt = num2str(bw, 4, 1, !i2p, ts->unit_base);
410 iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt;
416 (unsigned long long) ts->runtime[ddir]);
423 if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
425 if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev))
427 if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev))
430 if (ts->clat_percentiles) {
431 show_clat_percentiles(ts->io_u_plat[ddir],
432 ts->clat_stat[ddir].samples,
433 ts->percentile_list,
434 ts->percentile_precision, out);
436 if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
522 static void show_latencies(struct thread_stat *ts, struct buf_output *out)
527 stat_calc_lat_u(ts, io_u_lat_u);
528 stat_calc_lat_m(ts, io_u_lat_m);
677 static void show_ss_normal(struct thread_stat *ts, struct buf_output *out)
681 const int i2p = is_power_of_2(ts->kb_base);
683 if (!ts->ss_dur)
686 bw_mean = steadystate_bw_mean(ts);
687 iops_mean = steadystate_iops_mean(ts);
689 p1 = num2str(bw_mean / ts->kb_base, 4, ts->kb_base, i2p, ts->unit_base);
690 p1alt = num2str(bw_mean / ts->kb_base, 4, ts->kb_base, !i2p, ts->unit_base);
694 ts->ss_state & __FIO_SS_ATTAINED ? "yes" : "no",
696 ts->ss_state & __FIO_SS_IOPS ? "iops" : "bw",
697 ts->ss_state & __FIO_SS_SLOPE ? " slope": " mean dev",
698 ts->ss_criterion.u.f,
699 ts->ss_state & __FIO_SS_PCT ? "%" : "");
706 static void show_thread_status_normal(struct thread_stat *ts,
716 if (!ddir_rw_sum(ts->io_bytes) && !ddir_rw_sum(ts->total_io_u))
724 if (!ts->error) {
726 ts->name, ts->groupid, ts->members,
727 ts->error, (int) ts->pid, time_buf);
730 ts->name, ts->groupid, ts->members,
731 ts->error, ts->verror, (int) ts->pid,
735 if (strlen(ts->description))
736 log_buf(out, " Description : [%s]\n", ts->description);
738 if (ts->io_bytes[DDIR_READ])
739 show_ddir_status(rs, ts, DDIR_READ, out);
740 if (ts->io_bytes[DDIR_WRITE])
741 show_ddir_status(rs, ts, DDIR_WRITE, out);
742 if (ts->io_bytes[DDIR_TRIM])
743 show_ddir_status(rs, ts, DDIR_TRIM, out);
745 show_latencies(ts, out);
747 runtime = ts->total_run_time;
751 usr_cpu = (double) ts->usr_time * 100 / runt;
752 sys_cpu = (double) ts->sys_time * 100 / runt;
760 (unsigned long long) ts->ctx,
761 (unsigned long long) ts->majf,
762 (unsigned long long) ts->minf);
764 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
771 stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist);
777 stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist);
786 (unsigned long long) ts->total_io_u[0],
787 (unsigned long long) ts->total_io_u[1],
788 (unsigned long long) ts->total_io_u[2],
789 (unsigned long long) ts->short_io_u[0],
790 (unsigned long long) ts->short_io_u[1],
791 (unsigned long long) ts->short_io_u[2],
792 (unsigned long long) ts->drop_io_u[0],
793 (unsigned long long) ts->drop_io_u[1],
794 (unsigned long long) ts->drop_io_u[2]);
795 if (ts->continue_on_error) {
797 (unsigned long long)ts->total_err_count,
798 ts->first_error,
799 strerror(ts->first_error));
801 if (ts->latency_depth) {
803 (unsigned long long)ts->latency_target,
804 (unsigned long long)ts->latency_window,
805 ts->latency_percentile.u.f,
806 ts->latency_depth);
809 if (ts->nr_block_infos)
810 show_block_infos(ts->nr_block_infos, ts->block_infos,
811 ts->percentile_list, out);
813 if (ts->ss_dur)
814 show_ss_normal(ts, out);
817 static void show_ddir_status_terse(struct thread_stat *ts,
831 if (ts->runtime[ddir]) {
832 uint64_t runt = ts->runtime[ddir];
834 bw = ((1000 * ts->io_bytes[ddir]) / runt) / 1024; /* KiB/s */
835 iops = (1000 * (uint64_t) ts->total_io_u[ddir]) / runt;
839 (unsigned long long) ts->io_bytes[ddir] >> 10, bw, iops,
840 (unsigned long long) ts->runtime[ddir]);
842 if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
847 if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev))
852 if (ts->clat_percentiles) {
853 len = calc_clat_percentiles(ts->io_u_plat[ddir],
854 ts->clat_stat[ddir].samples,
855 ts->percentile_list, &ovals, &maxv,
865 log_buf(out, ";%f%%=%u", ts->percentile_list[i].u.f, ovals[i]);
868 if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev))
876 if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
890 static void add_ddir_status_json(struct thread_stat *ts,
906 if (ts->unified_rw_rep && ddir != DDIR_READ)
911 ts->unified_rw_rep ? "mixed" : ddirname[ddir], dir_object);
915 if (ts->runtime[ddir]) {
916 uint64_t runt = ts->runtime[ddir];
918 bw = ((1000 * ts->io_bytes[ddir]) / runt) / 1024; /* KiB/s */
919 iops = (1000.0 * (uint64_t) ts->total_io_u[ddir]) / runt;
922 json_object_add_value_int(dir_object, "io_bytes", ts->io_bytes[ddir] >> 10);
925 json_object_add_value_int(dir_object, "runtime", ts->runtime[ddir]);
926 json_object_add_value_int(dir_object, "total_ios", ts->total_io_u[ddir]);
927 json_object_add_value_int(dir_object, "short_ios", ts->short_io_u[ddir]);
928 json_object_add_value_int(dir_object, "drop_ios", ts->drop_io_u[ddir]);
930 if (!calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) {
941 if (!calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) {
952 if (ts->clat_percentiles) {
953 len = calc_clat_percentiles(ts->io_u_plat[ddir],
954 ts->clat_stat[ddir].samples,
955 ts->percentile_list, &ovals, &maxv,
967 snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f);
975 if (ts->io_u_plat[ddir][i]) {
977 json_object_add_value_int(clat_bins_object, (const char *)buf, ts->io_u_plat[ddir][i]);
982 if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
995 if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
1012 static void show_thread_status_terse_v2(struct thread_stat *ts,
1023 log_buf(out, "2;%s;%d;%d", ts->name, ts->groupid, ts->error);
1025 show_ddir_status_terse(ts, rs, DDIR_READ, out);
1027 show_ddir_status_terse(ts, rs, DDIR_WRITE, out);
1029 show_ddir_status_terse(ts, rs, DDIR_TRIM, out);
1032 if (ts->total_run_time) {
1033 double runt = (double) ts->total_run_time;
1035 usr_cpu = (double) ts->usr_time * 100 / runt;
1036 sys_cpu = (double) ts->sys_time * 100 / runt;
1043 (unsigned long long) ts->ctx,
1044 (unsigned long long) ts->majf,
1045 (unsigned long long) ts->minf);
1048 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
1049 stat_calc_lat_u(ts, io_u_lat_u);
1050 stat_calc_lat_m(ts, io_u_lat_m);
1064 if (ts->continue_on_error)
1065 log_buf(out, ";%llu;%d", (unsigned long long) ts->total_err_count, ts->first_error);
1069 if (strlen(ts->description))
1070 log_buf(out, ";%s", ts->description);
1075 static void show_thread_status_terse_v3_v4(struct thread_stat *ts,
1087 ts->name, ts->groupid, ts->error);
1089 show_ddir_status_terse(ts, rs, DDIR_READ, out);
1091 show_ddir_status_terse(ts, rs, DDIR_WRITE, out);
1094 show_ddir_status_terse(ts, rs, DDIR_TRIM, out);
1097 if (ts->total_run_time) {
1098 double runt = (double) ts->total_run_time;
1100 usr_cpu = (double) ts->usr_time * 100 / runt;
1101 sys_cpu = (double) ts->sys_time * 100 / runt;
1108 (unsigned long long) ts->ctx,
1109 (unsigned long long) ts->majf,
1110 (unsigned long long) ts->minf);
1113 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
1114 stat_calc_lat_u(ts, io_u_lat_u);
1115 stat_calc_lat_m(ts, io_u_lat_m);
1133 if (ts->continue_on_error)
1134 log_buf(out, ";%llu;%d", (unsigned long long) ts->total_err_count, ts->first_error);
1137 if (strlen(ts->description))
1138 log_buf(out, ";%s", ts->description);
1168 static struct json_object *show_thread_status_json(struct thread_stat *ts,
1182 json_object_add_value_string(root, "jobname", ts->name);
1183 json_object_add_value_int(root, "groupid", ts->groupid);
1184 json_object_add_value_int(root, "error", ts->error);
1196 add_ddir_status_json(ts, rs, DDIR_READ, root);
1197 add_ddir_status_json(ts
1198 add_ddir_status_json(ts, rs, DDIR_TRIM, root);
1201 if (ts->total_run_time) {
1202 double runt = (double) ts->total_run_time;
1204 usr_cpu = (double) ts->usr_time * 100 / runt;
1205 sys_cpu = (double) ts->sys_time * 100 / runt;
1212 json_object_add_value_int(root, "ctx", ts->ctx);
1213 json_object_add_value_int(root, "majf", ts->majf);
1214 json_object_add_value_int(root, "minf", ts->minf);
1218 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
1219 stat_calc_lat_u(ts, io_u_lat_u);
1220 stat_calc_lat_m(ts, io_u_lat_m);
1253 if (ts->continue_on_error) {
1254 json_object_add_value_int(root, "total_err", ts->total_err_count);
1255 json_object_add_value_int(root, "first_error", ts->first_error);
1258 if (ts->latency_depth) {
1259 json_object_add_value_int(root, "latency_depth", ts->latency_depth);
1260 json_object_add_value_int(root, "latency_target", ts->latency_target);
1261 json_object_add_value_float(root, "latency_percentile", ts->latency_percentile.u.f);
1262 json_object_add_value_int(root, "latency_window", ts->latency_window);
1266 if (strlen(ts->description))
1267 json_object_add_value_string(root, "desc", ts->description);
1269 if (ts->nr_block_infos) {
1275 len = calc_block_percentiles(ts->nr_block_infos, ts->block_infos,
1276 ts->percentile_list,
1291 ts->percentile_list[i].u.f);
1308 if (ts->ss_dur) {
1315 ts->ss_state & __FIO_SS_IOPS ? "iops" : "bw",
1316 ts->ss_state & __FIO_SS_SLOPE ? "_slope" : "",
1317 (float) ts->ss_limit.u.f,
1318 ts->ss_state & __FIO_SS_PCT ? "%" : "");
1323 json_object_add_value_int(tmp, "duration", (int)ts->ss_dur);
1324 json_object_add_value_int(tmp, "attained", (ts->ss_state & __FIO_SS_ATTAINED) > 0);
1326 snprintf(ss_buf, sizeof(ss_buf), "%f%s", (float) ts->ss_criterion.u.f,
1327 ts->ss_state & __FIO_SS_PCT ? "%" : "");
1329 json_object_add_value_float(tmp, "max_deviation", ts->ss_deviation.u.f);
1330 json_object_add_value_float(tmp, "slope", ts->ss_slope.u.f);
1343 if ((ts->ss_state & __FIO_SS_ATTAINED) || !(ts->ss_state & __FIO_SS_BUFFER_FULL))
1344 j = ts->ss_head;
1346 j = ts->ss_head == 0 ? ts->ss_dur - 1 : ts->ss_head - 1;
1347 for (i = 0; i < ts->ss_dur; i++) {
1348 k = (j + i) % ts->ss_dur;
1349 json_array_add_value_int(bw, ts->ss_bw_data[k]);
1350 json_array_add_value_int(iops, ts->ss_iops_data[k]);
1352 json_object_add_value_int(data, "bw_mean", steadystate_bw_mean(ts));
1353 json_object_add_value_int(data, "iops_mean", steadystate_iops_mean(ts));
1361 static void show_thread_status_terse(struct thread_stat *ts,
1366 show_thread_status_terse_v2(ts, rs, out);
1368 show_thread_status_terse_v3_v4(ts, rs, terse_version, out);
1373 struct json_object *show_thread_status(struct thread_stat *ts,
1381 show_thread_status_terse(ts, rs, out);
1383 ret = show_thread_status_json(ts, rs, opt_list);
1385 show_thread_status_normal(ts, rs, out);
1538 void init_thread_stat(struct thread_stat *ts)
1542 memset(ts, 0, sizeof(*ts));
1545 ts->lat_stat[j].min_val = -1UL;
1546 ts->clat_stat[j].min_val = -1UL;
1547 ts->slat_stat[j].min_val = -1UL;
1548 ts->bw_stat[j].min_val = -1UL;
1550 ts->groupid = -1;
1557 struct thread_stat *threadstats, *ts;
1613 ts = &threadstats[j];
1615 ts->clat_percentiles = td->o.clat_percentiles;
1616 ts->percentile_precision = td->o.percentile_precision;
1617 memcpy(ts->percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list));
1621 ts->members++;
1623 if (ts->groupid == -1) {
1627 strncpy(ts->name, td->o.name, FIO_JOBNAME_SIZE - 1);
1629 strncpy(ts->description, td->o.description,
1632 memset(ts->description, 0, FIO_JOBDESC_SIZE);
1638 ts->thread_number = td->thread_number;
1639 ts->groupid = td->groupid;
1644 ts->pid = td->pid;
1646 ts->kb_base = td->o.kb_base;
1647 ts->unit_base = td->o.unit_base;
1648 ts->unified_rw_rep = td->o.unified_rw_rep;
1649 } else if (ts->kb_base != td->o.kb_base && !kb_base_warned) {
1651 " %u as the base\n", ts->kb_base);
1653 } else if (ts->unit_base != td->o.unit_base && !unit_base_warned) {
1655 " %u as the base\n", ts->unit_base);
1659 ts->continue_on_error = td->o.continue_on_error;
1660 ts->total_err_count += td->total_err_count;
1661 ts->first_error = td->first_error;
1662 if (!ts->error) {
1665 ts->error = td->first_error;
1666 ts->verror[sizeof(ts->verror) - 1] = '\0';
1667 strncpy(ts->verror, td->verror, sizeof(ts->verror) - 1);
1669 ts->error = td->error;
1670 ts->verror[sizeof(ts->verror) - 1] = '\0';
1671 strncpy(ts->verror, td->verror, sizeof(ts->verror) - 1);
1675 ts->latency_depth = td->latency_qd;
1676 ts->latency_target = td->o.latency_target;
1677 ts->latency_percentile = td->o.latency_percentile;
1678 ts->latency_window = td->o.latency_window;
1680 ts->nr_block_infos = td->ts.nr_block_infos;
1681 for (k = 0; k < ts->nr_block_infos; k++)
1682 ts->block_infos[k] = td->ts.block_infos[k];
1684 sum_thread_stats(ts, &td->ts, idx == 1);
1687 ts->ss_state = td->ss.state;
1688 ts->ss_dur = td->ss.dur;
1689 ts->ss_head = td->ss.head;
1690 ts->ss_bw_data = td->ss.bw_data;
1691 ts->ss_iops_data = td->ss.iops_data;
1692 ts->ss_limit.u.f = td->ss.limit;
1693 ts->ss_slope.u.f = td->ss.slope;
1694 ts->ss_deviation.u.f = td->ss.deviation;
1695 ts->ss_criterion.u.f = td->ss.criterion;
1698 ts->ss_dur = ts->ss_state = 0;
1704 ts = &threadstats[i];
1705 if (ts->groupid == -1)
1707 rs = &runstats[ts->groupid];
1708 rs->kb_base = ts->kb_base;
1709 rs->unit_base = ts->unit_base;
1710 rs->unified_rw_rep += ts->unified_rw_rep;
1713 if (!ts->runtime[j])
1715 if (ts->runtime[j] < rs->min_run[j] || !rs->min_run[j])
1716 rs->min_run[j] = ts->runtime[j];
1717 if (ts->runtime[j] > rs->max_run[j])
1718 rs->max_run[j] = ts->runtime[j];
1721 if (ts->runtime[j])
1722 bw = ts->io_bytes[j] * 1000 / ts->runtime[j];
1728 rs->iobytes[j] += ts->io_bytes[j];
1782 ts = &threadstats[i];
1783 rs = &runstats[ts->groupid];
1787 fio_server_send_ts(ts, rs);
1790 show_thread_status_terse(ts, rs, &output[__FIO_OUTPUT_TERSE]);
1792 struct json_object *tmp = show_thread_status_json(ts, rs, opt_lists[i]);
1796 show_thread_status_normal(ts, rs, &output[__FIO_OUTPUT_NORMAL]);
1859 td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ];
1860 td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE];
1861 td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM];
1862 td->ts.total_run_time = mtime_since(&td->epoch, &tv);
1865 if (td_read(td) && td->ts.io_bytes[DDIR_READ])
1866 td->ts.runtime[DDIR_READ] += rt[i];
1867 if (td_write(td) && td->ts.io_bytes[DDIR_WRITE])
1868 td->ts.runtime[DDIR_WRITE] += rt[i];
1869 if (td_trim(td) && td->ts.io_bytes[DDIR_TRIM])
1870 td->ts.runtime[DDIR_TRIM] += rt[i];
1886 if (td_read(td) && td->ts.io_bytes[DDIR_READ])
1887 td->ts.runtime[DDIR_READ] -= rt[i];
1888 if (td_write(td) && td->ts.io_bytes[DDIR_WRITE])
1889 td->ts.runtime[DDIR_WRITE] -= rt[i];
1890 if (td_trim(td) && td->ts.io_bytes[DDIR_TRIM])
1891 td->ts.runtime[DDIR_TRIM] -= rt[i];
2162 struct thread_stat *ts = &td->ts;
2166 reset_io_stat(&ts->clat_stat[i]);
2167 reset_io_stat(&ts->slat_stat[i]);
2168 reset_io_stat(&ts->lat_stat[i]);
2169 reset_io_stat(&ts->bw_stat[i]);
2170 reset_io_stat(&ts->iops_stat[i]);
2172 ts->io_bytes[i] = 0;
2173 ts->runtime[i] = 0;
2174 ts->total_io_u[i] = 0;
2175 ts->short_io_u[i] = 0;
2176 ts->drop_io_u[i] = 0;
2179 ts->io_u_plat[i][j] = 0;
2183 ts->io_u_map[i] = 0;
2184 ts->io_u_submit[i] = 0;
2185 ts->io_u_complete[i] = 0;
2189 ts->io_u_lat_u[i] = 0;
2191 ts->io_u_lat_m[i] = 0;
2193 ts->total_submit = 0;
2194 ts->total_complete = 0;
2302 static void add_clat_percentile_sample(struct thread_stat *ts,
2308 ts->io_u_plat[ddir][idx]++;
2315 struct thread_stat *ts = &td->ts;
2320 add_stat_sample(&ts->clat_stat[ddir], usec);
2326 if (ts->clat_percentiles)
2327 add_clat_percentile_sample(ts, usec, ddir);
2344 * stored in td->ts.io_u_plat[ddir], recording it in a
2349 io_u_plat = (unsigned int *) td->ts.io_u_plat[ddir];
2373 struct thread_stat *ts = &td->ts;
2380 add_stat_sample(&ts->slat_stat[ddir], usec);
2391 struct thread_stat *ts = &td->ts;
2398 add_stat_sample(&ts->lat_stat[ddir], usec);
2410 struct thread_stat *ts = &td->ts;
2420 add_stat_sample(&ts->bw_stat[io_u->ddir], rate);
2497 td->ts.bw_stat, td->bw_log, true);
2503 struct thread_stat *ts = &td->ts;
2507 add_stat_sample(&ts->iops_stat[io_u->ddir], 1);
2521 td->ts.iops_stat, td->iops_log, false);
2590 uint32_t *info = &td->ts.block_infos[idx];
2591 assert(idx < td->ts.nr_block_infos);