X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=eta.c;h=9fc6e279180a82b817552222afcdae57055af85c;hp=cfb8679379c6d5a89d268add26df235a320dee9d;hb=6348b5dee54f24f2e78872948653942336f4c14e;hpb=fc47559b84e9708f97b66ff4123950fb33de9dc3 diff --git a/eta.c b/eta.c index cfb86793..9fc6e279 100644 --- a/eta.c +++ b/eta.c @@ -94,7 +94,7 @@ static void check_str_update(struct thread_data *td) /* * Convert seconds to a printable string. */ -static void eta_to_str(char *str, unsigned long eta_sec) +void eta_to_str(char *str, unsigned long eta_sec) { unsigned int d, h, m, s; int disp_hour = 0; @@ -139,6 +139,15 @@ static int thread_eta(struct thread_data *td) bytes_total = td->fill_device_size; } + if (td->o.zone_size && td->o.zone_skip && bytes_total) { + unsigned int nr_zones; + uint64_t zone_bytes; + + zone_bytes = bytes_total + td->o.zone_size + td->o.zone_skip; + nr_zones = (zone_bytes - 1) / (td->o.zone_size + td->o.zone_skip); + bytes_total -= nr_zones * td->o.zone_skip; + } + /* * if writing and verifying afterwards, bytes_total will be twice the * size. In a mixed workload, verify phase will be the size of the @@ -156,9 +165,6 @@ static int thread_eta(struct thread_data *td) bytes_total <<= 1; } - if (td->o.zone_size && td->o.zone_skip) - bytes_total /= (td->o.zone_skip / td->o.zone_size); - if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING) { double perc, perc_t; @@ -180,6 +186,7 @@ static int thread_eta(struct thread_data *td) eta_sec = td->o.timeout + done_secs - elapsed; } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED || td->runstate == TD_INITIALIZED + || td->runstate == TD_SETTING_UP || td->runstate == TD_RAMP || td->runstate == TD_PRE_READING) { int t_eta = 0, r_eta = 0; @@ -313,6 +320,7 @@ int calc_thread_status(struct jobs_eta *je, int force) unified_rw_rep += td->o.unified_rw_rep; if (is_power_of_2(td->o.kb_base)) je->is_pow2 = 1; + je->unit_base = td->o.unit_base; if (td->o.bw_avg_time < bw_avg_time) bw_avg_time = td->o.bw_avg_time; if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING @@ -320,31 +328,32 @@ int calc_thread_status(struct jobs_eta *je, int force) || td->runstate == TD_PRE_READING) { je->nr_running++; if (td_read(td)) { - je->t_rate += td->o.rate[DDIR_READ]; - je->t_iops += td->o.rate_iops[DDIR_READ]; - je->m_rate += td->o.ratemin[DDIR_READ]; - je->m_iops += td->o.rate_iops_min[DDIR_READ]; + je->t_rate[0] += td->o.rate[DDIR_READ]; + je->t_iops[0] += td->o.rate_iops[DDIR_READ]; + je->m_rate[0] += td->o.ratemin[DDIR_READ]; + je->m_iops[0] += td->o.rate_iops_min[DDIR_READ]; } if (td_write(td)) { - je->t_rate += td->o.rate[DDIR_WRITE]; - je->t_iops += td->o.rate_iops[DDIR_WRITE]; - je->m_rate += td->o.ratemin[DDIR_WRITE]; - je->m_iops += td->o.rate_iops_min[DDIR_WRITE]; + je->t_rate[1] += td->o.rate[DDIR_WRITE]; + je->t_iops[1] += td->o.rate_iops[DDIR_WRITE]; + je->m_rate[1] += td->o.ratemin[DDIR_WRITE]; + je->m_iops[1] += td->o.rate_iops_min[DDIR_WRITE]; } if (td_trim(td)) { - je->t_rate += td->o.rate[DDIR_TRIM]; - je->t_iops += td->o.rate_iops[DDIR_TRIM]; - je->m_rate += td->o.ratemin[DDIR_TRIM]; - je->m_iops += td->o.rate_iops_min[DDIR_TRIM]; + je->t_rate[2] += td->o.rate[DDIR_TRIM]; + je->t_iops[2] += td->o.rate_iops[DDIR_TRIM]; + je->m_rate[2] += td->o.ratemin[DDIR_TRIM]; + je->m_iops[2] += td->o.rate_iops_min[DDIR_TRIM]; } je->files_open += td->nr_open_files; } else if (td->runstate == TD_RAMP) { je->nr_running++; je->nr_ramp++; - } else if (td->runstate == TD_SETTING_UP) + } else if (td->runstate == TD_SETTING_UP) { je->nr_running++; - else if (td->runstate < TD_RUNNING) + je->nr_setting_up++; + } else if (td->runstate < TD_RUNNING) je->nr_pending++; if (je->elapsed_sec >= 3) @@ -354,7 +363,7 @@ int calc_thread_status(struct jobs_eta *je, int force) check_str_update(td); - if (td->runstate > TD_RAMP) { + if (td->runstate > TD_SETTING_UP) { int ddir; for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) { @@ -416,12 +425,13 @@ int calc_thread_status(struct jobs_eta *je, int force) je->nr_threads = thread_number; memcpy(je->run_str, run_str, thread_number * sizeof(char)); - return 1; } void display_thread_status(struct jobs_eta *je) { + static struct timeval disp_eta_new_line; + static int eta_new_line_init, eta_new_line_pending; static int linelen_last; static int eta_good; char output[REAL_MAX_JOBS + 512], *p = output; @@ -433,17 +443,25 @@ void display_thread_status(struct jobs_eta *je) eta_to_str(eta_str, je->eta_sec); } + if (eta_new_line_pending) { + eta_new_line_pending = 0; + p += sprintf(p, "\n"); + } + p += sprintf(p, "Jobs: %d (f=%d)", je->nr_running, je->files_open); - if (je->m_rate || je->t_rate) { + if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) { char *tr, *mr; - mr = num2str(je->m_rate, 4, 0, je->is_pow2); - tr = num2str(je->t_rate, 4, 0, je->is_pow2); + mr = num2str(je->m_rate[0] + je->m_rate[1], 4, 0, je->is_pow2, 8); + tr = num2str(je->t_rate[0] + je->t_rate[1], 4, 0, je->is_pow2, 8); p += sprintf(p, ", CR=%s/%s KB/s", tr, mr); free(tr); free(mr); - } else if (je->m_iops || je->t_iops) - p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops); + } else if (je->m_iops[0] || je->m_iops[1] || je->t_iops[0] || je->t_iops[1]) { + p += sprintf(p, ", CR=%d/%d IOPS", + je->t_iops[0] + je->t_iops[1], + je->m_iops[0] + je->m_iops[1]); + } if (je->eta_sec != INT_MAX && je->nr_running) { char perc_str[32]; char *iops_str[DDIR_RWDIR_CNT]; @@ -455,15 +473,20 @@ void display_thread_status(struct jobs_eta *je) if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running) strcpy(perc_str, "-.-% done"); else { + double mult = 100.0; + + if (je->nr_setting_up && je->nr_running) + mult *= (1.0 - (double) je->nr_setting_up / (double) je->nr_running); + eta_good = 1; - perc *= 100.0; + perc *= mult; sprintf(perc_str, "%3.1f%% done", perc); } for (ddir = DDIR_READ; ddir < DDIR_RWDIR_CNT; ddir++) { rate_str[ddir] = num2str(je->rate[ddir], 5, - 1024, je->is_pow2); - iops_str[ddir] = num2str(je->iops[ddir], 4, 1, 0); + 1024, je->is_pow2, je->unit_base); + iops_str[ddir] = num2str(je->iops[ddir], 4, 1, 0, 0); } left = sizeof(output) - (p - output) - 1; @@ -486,6 +509,16 @@ void display_thread_status(struct jobs_eta *je) p += sprintf(p, "\r"); printf("%s", output); + + if (!eta_new_line_init) { + fio_gettime(&disp_eta_new_line, NULL); + eta_new_line_init = 1; + } else if (eta_new_line && + mtime_since_now(&disp_eta_new_line) > eta_new_line * 1000) { + fio_gettime(&disp_eta_new_line, NULL); + eta_new_line_pending = 1; + } + fflush(stdout); }