- td->ss.bw_data = calloc(td->ss.dur, sizeof(uint64_t));
- td->ss.iops_data = calloc(td->ss.dur, sizeof(uint64_t));
+ int intervals = td->ss.dur / (ss_check_interval / 1000L);
+
+ td->ss.bw_data = calloc(intervals, sizeof(uint64_t));
+ td->ss.iops_data = calloc(intervals, sizeof(uint64_t));
if (ss->state & FIO_SS_IOPS)
ss->sum_y += ss->iops_data[i];
else
ss->sum_y += ss->bw_data[i];
if (ss->state & FIO_SS_IOPS)
ss->sum_y += ss->iops_data[i];
else
ss->sum_y += ss->bw_data[i];
* equally spaced when they are often off by a few milliseconds.
* This assumption greatly simplifies the calculations.
*/
* equally spaced when they are often off by a few milliseconds.
* This assumption greatly simplifies the calculations.
*/
- ss->slope = (ss->sum_xy - (double) ss->sum_x * ss->sum_y / ss->dur) /
- (ss->sum_x_sq - (double) ss->sum_x * ss->sum_x / ss->dur);
+ ss->slope = (ss->sum_xy - (double) ss->sum_x * ss->sum_y / intervals) /
+ (ss->sum_x_sq - (double) ss->sum_x * ss->sum_x / intervals);
if (ss->state & FIO_SS_IOPS)
ss->sum_y += ss->iops_data[i];
else
ss->sum_y += ss->bw_data[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;
ss->state |= FIO_SS_BUFFER_FULL;
} else { /* easy to update the sum */
ss->sum_y -= ss->oldest_y;
- dprint(FD_STEADYSTATE, "sum_y: %llu, mean: %f, max diff: %f, "
+ dprint(FD_STEADYSTATE, "intervals: %d, sum_y: %llu, mean: %f, max diff: %f, "
(unsigned long long) ss->sum_y, mean,
ss->deviation, ss->criterion, ss->limit);
(unsigned long long) ss->sum_y, mean,
ss->deviation, ss->criterion, ss->limit);
- ss->tail = (ss->tail + 1) % ss->dur;
- if (ss->tail <= ss->head)
- ss->head = (ss->head + 1) % ss->dur;
+ ss->tail = (ss->tail + 1) % intervals;
+ if (ss->tail == ss->head)
+ ss->head = (ss->head + 1) % intervals;
- int i, j, ddir, prev_groupid, group_ramp_time_over = 0;
+ int ddir, prev_groupid, group_ramp_time_over = 0;
struct timespec now;
uint64_t group_bw = 0, group_iops = 0;
uint64_t td_iops, td_bytes;
bool ret;
prev_groupid = -1;
struct timespec now;
uint64_t group_bw = 0, group_iops = 0;
uint64_t td_iops, td_bytes;
bool ret;
prev_groupid = -1;
for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) {
td_iops += td->io_blocks[ddir];
td_bytes += td->io_bytes[ddir];
}
for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) {
td_iops += td->io_blocks[ddir];
td_bytes += td->io_bytes[ddir];
}
rate_time = mtime_since(&ss->prev_time, &now);
memcpy(&ss->prev_time, &now, sizeof(now));
rate_time = mtime_since(&ss->prev_time, &now);
memcpy(&ss->prev_time, &now, sizeof(now));
- /*
- * Begin monitoring when job starts but don't actually use
- * data in checking stopping criterion until ss->ramp_time is
- * over. This ensures that we will have a sane value in
- * prev_iops/bw the first time through after ss->ramp_time
- * is done.
- */
- group_bw += 1000 * (td_bytes - ss->prev_bytes) / rate_time;
- group_iops += 1000 * (td_iops - ss->prev_iops) / rate_time;
+ group_bw += rate_time * (td_bytes - ss->prev_bytes) /
+ (ss_check_interval * ss_check_interval / 1000L);
+ group_iops += rate_time * (td_iops - ss->prev_iops) /
+ (ss_check_interval * ss_check_interval / 1000L);
dprint(FD_STEADYSTATE, "steadystate_check() thread: %d, "
"groupid: %u, rate_msec: %ld, "
"iops: %llu, bw: %llu, head: %d, tail: %d\n",
dprint(FD_STEADYSTATE, "steadystate_check() thread: %d, "
"groupid: %u, rate_msec: %ld, "
"iops: %llu, bw: %llu, head: %d, tail: %d\n",
- i, td->groupid, rate_time,
+ __td_index, td->groupid, rate_time,
(unsigned long long) group_iops,
(unsigned long long) group_bw,
ss->head, ss->tail);
(unsigned long long) group_iops,
(unsigned long long) group_bw,
ss->head, ss->tail);
if (td2->groupid == td->groupid) {
td2->ss.state |= FIO_SS_ATTAINED;
fio_mark_td_terminate(td2);
}
if (td2->groupid == td->groupid) {
td2->ss.state |= FIO_SS_ATTAINED;
fio_mark_td_terminate(td2);
}
}
int td_steadystate_init(struct thread_data *td)
{
struct steadystate_data *ss = &td->ss;
struct thread_options *o = &td->o;
}
int td_steadystate_init(struct thread_data *td)
{
struct steadystate_data *ss = &td->ss;
struct thread_options *o = &td->o;
- ss->sum_x = o->ss_dur * (o->ss_dur - 1) / 2;
- ss->sum_x_sq = (o->ss_dur - 1) * (o->ss_dur) * (2*o->ss_dur - 1) / 6;
+ intervals = ss->dur / (ss_check_interval / 1000L);
+ ss->sum_x = intervals * (intervals - 1) / 2;
+ ss->sum_x_sq = (intervals - 1) * (intervals) * (2*intervals - 1) / 6;