Lines Matching defs:ts
21 struct thread_stat *ts = &td->ts;
24 ts->usr_time += mtime_since(&td->ru_start.ru_utime,
26 ts->sys_time += mtime_since(&td->ru_start.ru_stime,
28 ts->ctx += td->ru_end.ru_nvcsw + td->ru_end.ru_nivcsw
30 ts->minf += td->ru_end.ru_minflt - td->ru_start.ru_minflt;
31 ts->majf += td->ru_end.ru_majflt - td->ru_start.ru_majflt;
314 static void stat_calc_lat(struct thread_stat *ts, double *dst,
317 unsigned long total = ddir_rw_sum(ts->total_io_u);
334 void stat_calc_lat_u(struct thread_stat *ts, double *io_u_lat)
336 stat_calc_lat(ts, io_u_lat, ts->io_u_lat_u, FIO_IO_U_LAT_U_NR);
339 void stat_calc_lat_m(struct thread_stat *ts, double *io_u_lat)
341 stat_calc_lat(ts, io_u_lat, ts->io_u_lat_m, FIO_IO_U_LAT_M_NR);
363 static void show_ddir_status(struct group_run_stats *rs, struct thread_stat *ts,
375 if (!ts->runtime[ddir])
379 runt = ts->runtime[ddir];
381 bw = (1000 * ts->io_bytes[ddir]) / runt;
382 io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p, 8);
383 bw_p = num2str(bw, 6, 1, i2p, ts->unit_base);
385 iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt;
391 (unsigned long long) ts->runtime[ddir]);
397 if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
399 if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev))
401 if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev))
404 if (ts->clat_percentiles) {
405 show_clat_percentiles(ts->io_u_plat[ddir],
406 ts->clat_stat[ddir].samples,
407 ts->percentile_list,
408 ts->percentile_precision);
410 if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
488 static void show_latencies(struct thread_stat *ts)
493 stat_calc_lat_u(ts, io_u_lat_u);
494 stat_calc_lat_m(ts, io_u_lat_m);
500 static void show_thread_status_normal(struct thread_stat *ts,
509 if (!ddir_rw_sum(ts->io_bytes) && !ddir_rw_sum(ts->total_io_u))
515 if (!ts->error) {
517 ts->name, ts->groupid, ts->members,
518 ts->error, (int) ts->pid, time_buf);
521 ts->name, ts->groupid, ts->members,
522 ts->error, ts->verror, (int) ts->pid,
526 if (strlen(ts->description))
527 log_info(" Description : [%s]\n", ts->description);
529 if (ts->io_bytes[DDIR_READ])
530 show_ddir_status(rs, ts, DDIR_READ);
531 if (ts->io_bytes[DDIR_WRITE])
532 show_ddir_status(rs, ts, DDIR_WRITE);
533 if (ts->io_bytes[DDIR_TRIM])
534 show_ddir_status(rs, ts, DDIR_TRIM);
536 show_latencies(ts);
538 runtime = ts->total_run_time;
542 usr_cpu = (double) ts->usr_time * 100 / runt;
543 sys_cpu = (double) ts->sys_time * 100 / runt;
551 (unsigned long long) ts->ctx,
552 (unsigned long long) ts->majf,
553 (unsigned long long) ts->minf);
555 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
562 stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist);
568 stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist);
577 (unsigned long long) ts->total_io_u[0],
578 (unsigned long long) ts->total_io_u[1],
579 (unsigned long long) ts->total_io_u[2],
580 (unsigned long long) ts->short_io_u[0],
581 (unsigned long long) ts->short_io_u[1],
582 (unsigned long long) ts->short_io_u[2],
583 (unsigned long long) ts->drop_io_u[0],
584 (unsigned long long) ts->drop_io_u[1],
585 (unsigned long long) ts->drop_io_u[2]);
586 if (ts->continue_on_error) {
588 (unsigned long long)ts->total_err_count,
589 ts->first_error,
590 strerror(ts->first_error));
592 if (ts->latency_depth) {
594 (unsigned long long)ts->latency_target,
595 (unsigned long long)ts->latency_window,
596 ts->latency_percentile.u.f,
597 ts->latency_depth);
601 static void show_ddir_status_terse(struct thread_stat *ts,
614 if (ts->runtime[ddir]) {
615 uint64_t runt = ts->runtime[ddir];
617 bw = ((1000 * ts->io_bytes[ddir]) / runt) / 1024;
618 iops = (1000 * (uint64_t) ts->total_io_u[ddir]) / runt;
622 (unsigned long long) ts->io_bytes[ddir] >> 10, bw, iops,
623 (unsigned long long) ts->runtime[ddir]);
625 if (calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev))
630 if (calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev))
635 if (ts->clat_percentiles) {
636 len = calc_clat_percentiles(ts->io_u_plat[ddir],
637 ts->clat_stat[ddir].samples,
638 ts->percentile_list, &ovals, &maxv,
648 log_info(";%f%%=%u", ts
651 if (calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev))
659 if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
673 static void add_ddir_status_json(struct thread_stat *ts,
689 if (ts->unified_rw_rep && ddir != DDIR_READ)
694 ts->unified_rw_rep ? "mixed" : ddirname[ddir], dir_object);
698 if (ts->runtime[ddir]) {
699 uint64_t runt = ts->runtime[ddir];
701 bw = ((1000 * ts->io_bytes[ddir]) / runt) / 1024;
702 iops = (1000.0 * (uint64_t) ts->total_io_u[ddir]) / runt;
705 json_object_add_value_int(dir_object, "io_bytes", ts->io_bytes[ddir] >> 10);
708 json_object_add_value_int(dir_object, "runtime", ts->runtime[ddir]);
709 json_object_add_value_int(dir_object, "total_ios", ts->total_io_u[ddir]);
710 json_object_add_value_int(dir_object, "short_ios", ts->short_io_u[ddir]);
711 json_object_add_value_int(dir_object, "drop_ios", ts->drop_io_u[ddir]);
713 if (!calc_lat(&ts->slat_stat[ddir], &min, &max, &mean, &dev)) {
724 if (!calc_lat(&ts->clat_stat[ddir], &min, &max, &mean, &dev)) {
735 if (ts->clat_percentiles) {
736 len = calc_clat_percentiles(ts->io_u_plat[ddir],
737 ts->clat_stat[ddir].samples,
738 ts->percentile_list, &ovals, &maxv,
750 snprintf(buf, sizeof(buf), "%f", ts->percentile_list[i].u.f);
754 if (!calc_lat(&ts->lat_stat[ddir], &min, &max, &mean, &dev)) {
767 if (calc_lat(&ts->bw_stat[ddir], &min, &max, &mean, &dev)) {
784 static void show_thread_status_terse_v2(struct thread_stat *ts,
794 log_info("2;%s;%d;%d", ts->name, ts->groupid, ts->error);
796 show_ddir_status_terse(ts, rs, DDIR_READ);
798 show_ddir_status_terse(ts, rs, DDIR_WRITE);
800 show_ddir_status_terse(ts, rs, DDIR_TRIM);
803 if (ts->total_run_time) {
804 double runt = (double) ts->total_run_time;
806 usr_cpu = (double) ts->usr_time * 100 / runt;
807 sys_cpu = (double) ts->sys_time * 100 / runt;
814 (unsigned long long) ts->ctx,
815 (unsigned long long) ts->majf,
816 (unsigned long long) ts->minf);
819 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
820 stat_calc_lat_u(ts, io_u_lat_u);
821 stat_calc_lat_m(ts, io_u_lat_m);
835 if (ts->continue_on_error)
836 log_info(";%llu;%d", (unsigned long long) ts->total_err_count, ts->first_error);
840 if (strlen(ts->description))
841 log_info(";%s", ts->description);
846 static void show_thread_status_terse_v3_v4(struct thread_stat *ts,
857 ts->name, ts->groupid, ts->error);
859 show_ddir_status_terse(ts, rs, DDIR_READ);
861 show_ddir_status_terse(ts, rs, DDIR_WRITE);
864 show_ddir_status_terse(ts, rs, DDIR_TRIM);
867 if (ts->total_run_time) {
868 double runt = (double) ts->total_run_time;
870 usr_cpu = (double) ts->usr_time * 100 / runt;
871 sys_cpu = (double) ts->sys_time * 100 / runt;
878 (unsigned long long) ts->ctx,
879 (unsigned long long) ts->majf,
880 (unsigned long long) ts->minf);
883 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
884 stat_calc_lat_u(ts, io_u_lat_u);
885 stat_calc_lat_m(ts, io_u_lat_m);
903 if (ts->continue_on_error)
904 log_info(";%llu;%d", (unsigned long long) ts->total_err_count, ts->first_error);
907 if (strlen(ts->description))
908 log_info(";%s", ts->description);
913 static struct json_object *show_thread_status_json(struct thread_stat *ts,
924 json_object_add_value_string(root, "jobname", ts->name);
925 json_object_add_value_int(root, "groupid", ts->groupid);
926 json_object_add_value_int(root, "error", ts->error);
928 add_ddir_status_json(ts, rs, DDIR_READ, root);
929 add_ddir_status_json(ts, rs, DDIR_WRITE, root);
930 add_ddir_status_json(ts, rs, DDIR_TRIM, root);
933 if (ts->total_run_time) {
934 double runt = (double) ts->total_run_time;
936 usr_cpu = (double) ts->usr_time * 100 / runt;
937 sys_cpu = (double) ts->sys_time * 100 / runt;
944 json_object_add_value_int(root, "ctx", ts->ctx);
945 json_object_add_value_int(root, "majf", ts->majf);
946 json_object_add_value_int(root, "minf", ts->minf);
950 stat_calc_dist(ts->io_u_map, ddir_rw_sum(ts->total_io_u), io_u_dist);
951 stat_calc_lat_u(ts, io_u_lat_u);
952 stat_calc_lat_m(ts, io_u_lat_m);
985 if (ts->continue_on_error) {
986 json_object_add_value_int(root, "total_err", ts->total_err_count);
987 json_object_add_value_int(root, "first_error", ts->first_error);
990 if (ts->latency_depth) {
991 json_object_add_value_int(root, "latency_depth", ts->latency_depth);
992 json_object_add_value_int(root, "latency_target", ts->latency_target);
993 json_object_add_value_float(root, "latency_percentile", ts->latency_percentile.u.f);
994 json_object_add_value_int(root, "latency_window", ts->latency_window);
998 if (strlen(ts->description))
999 json_object_add_value_string(root, "desc", ts->description);
1004 static void show_thread_status_terse(struct thread_stat *ts,
1008 show_thread_status_terse_v2(ts, rs);
1010 show_thread_status_terse_v3_v4(ts, rs, terse_version);
1015 struct json_object *show_thread_status(struct thread_stat *ts,
1019 show_thread_status_terse(ts, rs);
1021 return show_thread_status_json(ts, rs);
1023 show_thread_status_normal(ts, rs);
1172 void init_thread_stat(struct thread_stat *ts)
1176 memset(ts, 0, sizeof(*ts));
1179 ts->lat_stat[j].min_val = -1UL;
1180 ts->clat_stat[j].min_val = -1UL;
1181 ts->slat_stat[j].min_val = -1UL;
1182 ts->bw_stat[j].min_val = -1UL;
1184 ts->groupid = -1;
1191 struct thread_stat *threadstats, *ts;
1237 ts = &threadstats[j];
1239 ts->clat_percentiles = td->o.clat_percentiles;
1240 ts->percentile_precision = td->o.percentile_precision;
1241 memcpy(ts->percentile_list, td->o.percentile_list, sizeof(td->o.percentile_list));
1244 ts->members++;
1246 if (ts->groupid == -1) {
1250 strncpy(ts->name, td->o.name, FIO_JOBNAME_SIZE - 1);
1252 strncpy(ts->description, td->o.description,
1255 memset(ts->description, 0, FIO_JOBDESC_SIZE);
1261 ts->thread_number = td->thread_number;
1262 ts->groupid = td->groupid;
1267 ts->pid = td->pid;
1269 ts->kb_base = td->o.kb_base;
1270 ts->unit_base = td->o.unit_base;
1271 ts->unified_rw_rep = td->o.unified_rw_rep;
1272 } else if (ts->kb_base != td->o.kb_base && !kb_base_warned) {
1274 " %u as the base\n", ts->kb_base);
1276 } else if (ts->unit_base != td->o.unit_base && !unit_base_warned) {
1278 " %u as the base\n", ts->unit_base);
1282 ts->continue_on_error = td->o.continue_on_error;
1283 ts->total_err_count += td->total_err_count;
1284 ts->first_error = td->first_error;
1285 if (!ts->error) {
1288 ts->error = td->first_error;
1289 ts->verror[sizeof(ts->verror) - 1] = '\0';
1290 strncpy(ts->verror, td->verror, sizeof(ts->verror) - 1);
1292 ts->error = td->error;
1293 ts->verror[sizeof(ts->verror) - 1] = '\0';
1294 strncpy(ts->verror, td->verror, sizeof(ts->verror) - 1);
1298 ts->latency_depth = td->latency_qd;
1299 ts->latency_target = td->o.latency_target;
1300 ts->latency_percentile = td->o.latency_percentile;
1301 ts->latency_window = td->o.latency_window;
1303 sum_thread_stats(ts, &td->ts, idx);
1309 ts = &threadstats[i];
1310 rs = &runstats[ts->groupid];
1311 rs->kb_base = ts->kb_base;
1312 rs->unit_base = ts->unit_base;
1313 rs->unified_rw_rep += ts->unified_rw_rep;
1316 if (!ts->runtime[j])
1318 if (ts->runtime[j] < rs->min_run[j] || !rs->min_run[j])
1319 rs->min_run[j] = ts->runtime[j];
1320 if (ts->runtime[j] > rs->max_run[j])
1321 rs->max_run[j] = ts->runtime[j];
1324 if (ts->runtime[j]) {
1325 unsigned long runt = ts->runtime[j];
1328 kb = ts->io_bytes[j] / rs->kb_base;
1336 rs->io_kb[j] += ts->io_bytes[j] / rs->kb_base;
1375 ts = &threadstats[i];
1376 rs = &runstats[ts->groupid];
1379 fio_server_send_ts(ts, rs);
1381 show_thread_status_terse(ts, rs);
1383 struct json_object *tmp = show_thread_status_json(ts, rs);
1386 show_thread_status_normal(ts, rs);
1420 ts = &threadstats[i];
1421 rs = &runstats[ts->groupid];
1422 show_thread_status_terse(ts, rs);
1453 td->ts.runtime[DDIR_READ] += rt[i];
1455 td->ts.runtime[DDIR_WRITE] += rt[i];
1457 td->ts.runtime[DDIR_TRIM] += rt[i];
1460 td->ts.io_bytes[DDIR_READ] = td->io_bytes[DDIR_READ];
1461 td->ts.io_bytes[DDIR_WRITE] = td->io_bytes[DDIR_WRITE];
1462 td->ts.io_bytes[DDIR_TRIM] = td->io_bytes[DDIR_TRIM];
1463 td->ts.total_run_time = mtime_since(&td->epoch, &tv);
1480 td->ts.runtime[DDIR_READ] -= rt[i];
1482 td->ts.runtime[DDIR_WRITE] -= rt[i];
1484 td->ts.runtime[DDIR_TRIM] -= rt[i];
1629 struct thread_stat *ts = &td->ts;
1633 reset_io_stat(&ts->clat_stat[i]);
1634 reset_io_stat(&ts->slat_stat[i]);
1635 reset_io_stat(&ts->lat_stat[i]);
1636 reset_io_stat(&ts->bw_stat[i]);
1637 reset_io_stat(&ts->iops_stat[i]);
1639 ts->io_bytes[i] = 0;
1640 ts->runtime[i] = 0;
1643 ts->io_u_plat[i][j] = 0;
1647 ts->io_u_map[i] = 0;
1648 ts->io_u_submit[i] = 0;
1649 ts->io_u_complete[i] = 0;
1650 ts->io_u_lat_u[i] = 0;
1651 ts->io_u_lat_m[i] = 0;
1652 ts->total_submit = 0;
1653 ts->total_complete = 0;
1657 ts->total_io_u[i] = 0;
1658 ts->short_io_u[i] = 0;
1659 ts->drop_io_u[i] = 0;
1761 static void add_clat_percentile_sample(struct thread_stat *ts,
1767 ts->io_u_plat[ddir][idx]++;
1773 struct thread_stat *ts = &td->ts;
1778 add_stat_sample(&ts->clat_stat[ddir], usec);
1783 if (ts->clat_percentiles)
1784 add_clat_percentile_sample(ts, usec, ddir);
1790 struct thread_stat *ts = &td->ts;
1795 add_stat_sample(&ts->slat_stat[ddir], usec);
1804 struct thread_stat *ts = &td->ts;
1809 add_stat_sample(&ts->lat_stat[ddir], usec);
1818 struct thread_stat *ts = &td->ts;
1843 add_stat_sample(&ts->bw_stat[ddir], rate);
1857 struct thread_stat *ts = &td->ts;
1882 add_stat_sample(&ts->iops_stat[ddir], iops);