fio block size

  • Create a new file and add following lines to the file. Let's name the file as "fio_script"
    		
    		[jobname]
    		rw=read
    		size=8192
    		bs=4090
    		
    		
  • We run fio script by using fio command:
     
    		
    		Syntax $fio <scriptname>
    		Eg: $fio fio_script
    		
    		
  • Let's understand what "bs=4090" line means:

    • bs=4090 specifies how much data single read/write call should read/write from input file
    • You may recall the syntax of read() system call. 3rd parameter passed to read() is count i.e. number of bytes to read from file specified by file descriptor. (Same is true for write())
      	read(int fd, void *buf, size_t count);
      	
    • Homework 1: Repeat following experiment
      • Using strace let's verify that our understanding of what bs=xyz means is correct or not.
      • Run following command.
    	$ strace -f fio fioScript 2> strace_out
    	
  • Above command traces the sytem calls made by fio process that performed above fio task and outputs the tracing result into file named 'strace_out'
  • Search for '4090' in the strace_out file. You will probably see following:
		...
	[pid  6460] openat(AT_FDCWD, "jobname.0.0", O_RDONLY) = 3
	[pid  6460] fadvise64(3, 0, 8192, POSIX_FADV_DONTNEED) = 0
	[pid  6460] fadvise64(3, 0, 8192, POSIX_FADV_RANDOM) = 0
	[pid  6460] pread64(3, "5\340(\3148\240\231\26\6\234j\251\362\315\351\n\200S*\7\t\345\r\25pJ%\367\v9\235\30"..., 4090, 0) = 4090
	[pid  6460] pread64(3, "V\251\222{V\22\250q\tH\323\255_\3055.-\260\265QZ\23\306%\353\36 r\303\23\270d"...,  4090, 4090) = 4090
	[pid 6460] close(3)                    = 0
		...

	
  • We can see in above trace file that file named 'jobname.0.0' is being opened and file descriptor 3 represents it.
  • Then pread() system call (instead of read() )is used to read 4090 bytes from file corresponding fd 3.
  • close(3) closes the file.
  • Note: Also observe that we had specified 8192 bytes as the job size. But we can see that only 4090 + 4090 bytes were read. This suggests that read/write happens only if atleast block size amount of data is available to be read/written.

  • Homework 2: Repeat prev. experiment with job size=14000 bytes. What do you observe? How many pread64() calls are being made?
  • Homework 3: Read manpages of pread64() and fadvise64().

  • Note:We have not specified the file on which read should happen. In this case, fio automatically first creates a file and then performs read operation on that file.
  • </ul>