From: Vincent Fu Date: Fri, 2 Dec 2016 18:25:07 +0000 (-0500) Subject: steadystate: instead of including ss_sum_y in thread_stat record whether ss_sum_y... X-Git-Tag: fio-2.16~3^2~10 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=17df7023156b50ee7288eea0f118f1ac20b21ea2 steadystate: instead of including ss_sum_y in thread_stat record whether ss_sum_y is nonzero in ss_state via __FIO_SS_BUFFER_FULL --- diff --git a/client.c b/client.c index 96bb29c1..f1c75963 100644 --- a/client.c +++ b/client.c @@ -950,7 +950,6 @@ static void convert_ts(struct thread_stat *dst, struct thread_stat *src) dst->ss_dur = le64_to_cpu(src->ss_dur); dst->ss_state = le32_to_cpu(src->ss_state); dst->ss_head = le32_to_cpu(src->ss_head); - dst->ss_sum_y = le64_to_cpu(src->ss_sum_y); dst->ss_limit.u.f = fio_uint64_to_double(le64_to_cpu(src->ss_limit.u.i)); dst->ss_slope.u.f = fio_uint64_to_double(le64_to_cpu(src->ss_slope.u.i)); dst->ss_deviation.u.f = fio_uint64_to_double(le64_to_cpu(src->ss_deviation.u.i)); diff --git a/server.c b/server.c index bef4f826..780f09f4 100644 --- a/server.c +++ b/server.c @@ -1546,7 +1546,6 @@ void fio_server_send_ts(struct thread_stat *ts, struct group_run_stats *rs) p.ts.ss_dur = cpu_to_le64(ts->ss_dur); p.ts.ss_state = cpu_to_le32(ts->ss_state); p.ts.ss_head = cpu_to_le32(ts->ss_head); - p.ts.ss_sum_y = cpu_to_le64(ts->ss_sum_y); p.ts.ss_limit.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_limit.u.f)); p.ts.ss_slope.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_slope.u.f)); p.ts.ss_deviation.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_deviation.u.f)); diff --git a/stat.c b/stat.c index fab0a82d..75b45733 100644 --- a/stat.c +++ b/stat.c @@ -1320,7 +1320,7 @@ static struct json_object *show_thread_status_json(struct thread_stat *ts, ** otherwise it actually points to the second element ** in the list */ - if ((ts->ss_state & __FIO_SS_ATTAINED) || ts->ss_sum_y == 0) + if ((ts->ss_state & __FIO_SS_ATTAINED) || !(ts->ss_state & __FIO_SS_BUFFER_FULL)) j = ts->ss_head; else j = ts->ss_head == 0 ? ts->ss_dur - 1 : ts->ss_head - 1; @@ -1663,7 +1663,6 @@ void __show_run_stats(void) ts->ss_state = td->ss.state; ts->ss_dur = td->ss.dur; ts->ss_head = td->ss.head; - ts->ss_sum_y = td->ss.sum_y; ts->ss_bw_data = td->ss.bw_data; ts->ss_iops_data = td->ss.iops_data; ts->ss_limit.u.f = td->ss.limit; diff --git a/stat.h b/stat.h index eb7397d2..8a954791 100644 --- a/stat.h +++ b/stat.h @@ -217,7 +217,6 @@ struct thread_stat { uint64_t ss_dur; uint32_t ss_state; uint32_t ss_head; - uint64_t ss_sum_y; uint64_t *ss_iops_data; uint64_t *ss_bw_data; diff --git a/steadystate.c b/steadystate.c index 94d1f5e2..224995d1 100644 --- a/steadystate.c +++ b/steadystate.c @@ -73,21 +73,21 @@ static bool steadystate_slope(unsigned long iops, unsigned long bw, else new_val = bw; - if (ss->tail < ss->head || (ss->tail - ss->head == ss->dur - 1)) { - if (ss->sum_y == 0) { /* first time through */ - for(i = 0; i < ss->dur; i++) { + if (ss->state & __FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) { + if (!(ss->state & __FIO_SS_BUFFER_FULL)) { + /* first time through */ + for(i = 0, ss->sum_y = 0; i < ss->dur; i++) { if (ss->state & __FIO_SS_IOPS) ss->sum_y += ss->iops_data[i]; else ss->sum_y += ss->bw_data[i]; - j = ss->head + i; - if (j >= ss->dur) - j -= ss->dur; + j = (ss->head + i) % ss->dur; if (ss->state & __FIO_SS_IOPS) ss->sum_xy += i * ss->iops_data[j]; else ss->sum_xy += i * ss->bw_data[j]; } + ss->state |= __FIO_SS_BUFFER_FULL; } else { /* easy to update the sums */ ss->sum_y -= ss->oldest_y; ss->sum_y += new_val; @@ -141,13 +141,15 @@ static bool steadystate_deviation(unsigned long iops, unsigned long bw, ss->bw_data[ss->tail] = bw; ss->iops_data[ss->tail] = iops; - if (ss->tail < ss->head || (ss->tail - ss->head == ss->dur - 1)) { - if (ss->sum_y == 0) { /* first time through */ - for(i = 0; i < ss->dur; i++) + if (ss->state & __FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) { + if (!(ss->state & __FIO_SS_BUFFER_FULL)) { + /* first time through */ + for(i = 0, ss->sum_y = 0; i < ss->dur; i++) if (ss->state & __FIO_SS_IOPS) ss->sum_y += ss->iops_data[i]; else ss->sum_y += ss->bw_data[i]; + ss->state |= __FIO_SS_BUFFER_FULL; } else { /* easy to update the sum */ ss->sum_y -= ss->oldest_y; if (ss->state & __FIO_SS_IOPS) diff --git a/steadystate.h b/steadystate.h index deba5fb1..f390b073 100644 --- a/steadystate.h +++ b/steadystate.h @@ -48,6 +48,7 @@ enum { __FIO_SS_RAMP_OVER = 16, __FIO_SS_DATA = 32, __FIO_SS_PCT = 64, + __FIO_SS_BUFFER_FULL = 128, FIO_SS_IOPS = __FIO_SS_IOPS, FIO_SS_IOPS_SLOPE = __FIO_SS_IOPS | __FIO_SS_SLOPE,