steadystate: instead of including ss_sum_y in thread_stat record whether ss_sum_y...
authorVincent Fu <Vincent.Fu@sandisk.com>
Fri, 2 Dec 2016 18:25:07 +0000 (13:25 -0500)
committerVincent Fu <Vincent.Fu@sandisk.com>
Wed, 7 Dec 2016 21:03:18 +0000 (16:03 -0500)
client.c
server.c
stat.c
stat.h
steadystate.c
steadystate.h

index 96bb29c..f1c7596 100644 (file)
--- 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));
index bef4f82..780f09f 100644 (file)
--- 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 fab0a82..75b4573 100644 (file)
--- 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 eb7397d..8a95479 100644 (file)
--- 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;
index 94d1f5e..224995d 100644 (file)
@@ -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)
index deba5fb..f390b07 100644 (file)
@@ -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,