#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/mman.h>
+#include <math.h>
#include "fio.h"
#ifndef FIO_NO_HAVE_SHM_H
#include "cgroup.h"
#include "profile.h"
#include "lib/rand.h"
-#include "memalign.h"
+#include "lib/memalign.h"
#include "server.h"
#include "lib/getrusage.h"
#include "idletime.h"
* if the queue is full, we MUST reap at least 1 event
*/
min_evts = min(td->o.iodepth_batch_complete_min, td->cur_depth);
- if ((full && !min_evts) || !td->o.iodepth_batch_complete_min)
+ if ((full && !min_evts) || !td->o.iodepth_batch_complete_min)
min_evts = 1;
if (time && (__should_check_rate(td, DDIR_READ) ||
*/
static long long usec_for_io(struct thread_data *td, enum fio_ddir ddir)
{
- uint64_t secs, remainder, bps, bytes;
+ uint64_t secs, remainder, bps, bytes, iops;
assert(!(td->flags & TD_F_CHILD));
bytes = td->rate_io_issue_bytes[ddir];
bps = td->rate_bps[ddir];
- if (bps) {
+
+ if (td->o.rate_process == RATE_PROCESS_POISSON) {
+ uint64_t val;
+ iops = bps / td->o.bs[ddir];
+ val = (int64_t) (1000000 / iops) *
+ -logf(__rand_0_1(&td->poisson_state));
+ if (val) {
+ dprint(FD_RATE, "poisson rate iops=%llu\n",
+ (unsigned long long) 1000000 / val);
+ }
+ td->last_usec += val;
+ return td->last_usec;
+ } else if (bps) {
secs = bytes / bps;
remainder = bytes % bps;
return remainder * 1000000 / bps + secs * 1000000;
- } else
- return 0;
+ }
+
+ return 0;
}
/*
if (flow_threshold_exceeded(td))
continue;
- if (bytes_issued >= total_bytes)
+ if (!td->o.time_based && bytes_issued >= total_bytes)
break;
io_u = get_io_u(td);