filesetup: better handle non-uniform distributions
authorVincent Fu <vincent.fu@samsung.com>
Thu, 20 Apr 2023 15:12:22 +0000 (15:12 +0000)
committerVincent Fu <vincent.fu@samsung.com>
Thu, 20 Apr 2023 15:24:39 +0000 (15:24 +0000)
commit073974b24aac23610e9e13e3eb56438ad108ab31
treec894dca44313154b1e0721b455a83ba1defd3e4c
parent223decddb199e9af0c5cd357d28c43e48dbcea7a
filesetup: better handle non-uniform distributions

When we have a random workload with multiple files, randrepeat=0, and a
non-uniform random distribution, the offsets touched will follow the
same sequence for all files:

$ ./fio --name=test --nrfiles=2 --randrepeat=0 --filesize=16k \
--debug=io --rw=randread --norandommap \
--random_distribution=normal:50 | grep complete:

io       23042 complete: io_u 0x55bd982f6000: off=0x2000,len=0x1000,ddir=0,file=test.0.0
io       23042 complete: io_u 0x55bd982f6000: off=0x2000,len=0x1000,ddir=0,file=test.0.1
io       23042 complete: io_u 0x55bd982f6000: off=0x3000,len=0x1000,ddir=0,file=test.0.0
io       23042 complete: io_u 0x55bd982f6000: off=0x3000,len=0x1000,ddir=0,file=test.0.1
io       23042 complete: io_u 0x55bd982f6000: off=0x2000,len=0x1000,ddir=0,file=test.0.0
io       23042 complete: io_u 0x55bd982f6000: off=0x2000,len=0x1000,ddir=0,file=test.0.1
io       23042 complete: io_u 0x55bd982f6000: off=0x3000,len=0x1000,ddir=0,file=test.0.0
io       23042 complete: io_u 0x55bd982f6000: off=0x3000,len=0x1000,ddir=0,file=test.0.1

Notice that the blocks touched for test.0.0 and test.0.1 follow the same
sequence.

This patch allows the sequence of offsets touched to differ between
files by always involving the filename in the seed used for each file.
The randrepeat setting will still be respected as it is involved in
determining the value for td->rand_seeds[FIO_RAND_BLOCK_OFF].

With the patch applied the above invocation produces output like:

io       23022 complete: io_u 0x55ed2cd2c000: off=0x2000,len=0x1000,ddir=0,file=test.0.0
io       23022 complete: io_u 0x55ed2cd2c000: off=0x2000,len=0x1000,ddir=0,file=test.0.1
io       23022 complete: io_u 0x55ed2cd2c000: off=0x3000,len=0x1000,ddir=0,file=test.0.0
io       23022 complete: io_u 0x55ed2cd2c000: off=0x2000,len=0x1000,ddir=0,file=test.0.1
io       23022 complete: io_u 0x55ed2cd2c000: off=0x2000,len=0x1000,ddir=0,file=test.0.0
io       23022 complete: io_u 0x55ed2cd2c000: off=0x3000,len=0x1000,ddir=0,file=test.0.1
io       23022 complete: io_u 0x55ed2cd2c000: off=0x1000,len=0x1000,ddir=0,file=test.0.0
io       23022 complete: io_u 0x55ed2cd2c000: off=0x2000,len=0x1000,ddir=0,file=test.0.1

Signed-off-by: Vincent Fu <vincent.fu@samsung.com>
filesetup.c