-
Notifications
You must be signed in to change notification settings - Fork 17
Threading Model and File Access Patterns
By default, a single thread accesses each specified target file (modified by --threads-per-target (-t) or --total-threads (-F)). The thread keeps two asynchronous IO operations (--overlap (-o)) in flight at a time.
This image shows --threads-per-target=3 using 2 target files or disk partitions. 6 threads are created in total, so the total number of IO operations happening at once against these targets is 6*2=12.
Alternatively, --total-threads (-F) can be used to specify a total number of threads independent of the number of files. This option conflicts with --threads-per-target (-t).
Instead of each thread being assigned a single target, all threads do IO on all targets. The number of in flight IOs is per-target, so in the below image, each thread is keeping 4 asynchronous IO requests in-flight at a time, 2 for each target, so again there are at most 3*4=12 concurrent IO operations outstanding.
Each IO operation is 64KiB in size (--block-size (-b)). Each new operation started by the same thread will by default start 64KiB after the previous one (--sequential-stride (-s)).
By default, threads performing sequential operations will all start from offset 0 (--base-offset (-B)) of the target and continue up to the size of the file, or --target-size (-f) if it is specified. If multiple threads are doing work on a file, an stride between their starting offsets can be specified with --thread-stride (-T).
The following diagram illustrates how --block-size (-b), --sequential-stride (-s), --base-offset (-B), --target-size (-f) and --thread-stride (-T) are related, using --threads-per-target=3 and --overlap=2.
Thread stride need not be a multiple of sequential stride (or vice versa). When the end of file (or --target-size) is encountered, access wraps back to the beginning at an offset such that each thread will reproduce the same IO offsets on its next sweep through the target.
If --sequential-stride's optional 'i' specified is used at the start of the argument, all threads working on a file will share a current offset into the file; each IO operation started on that target will use this offset. --thread-stride cannot be used with this option.
If --random-align (-r) is used instead of --sequential-stride, IO will be done at a random offset aligned to the argument of -r (or the --block-size by default). The random number generator used by --random-align is seeded with 0 by default. Its seed can be specified with --rand-seed (-z), or -z can be specified alone to use a random seed (generate by C++11's std::random_device).