fio I/O Engine

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

    • ioengine option specifies which read/write system calls should be used behind the scenes to read/write data from file.
    • ioengine=sync specifies that fio should use read(2), write(2) behind the scenes. This is synchronous operation.
    • ioengine=psync specifies that fio should use pread(2), pwrite(2) behind the scenes. This is the default setting. This is synchronous operation.
    • ioengine=libaio specifies that fio should perform asynchronous read/write behind the scenes. You can refer fio documentation to see libaio usage examples.
    • </pre>
    • Homework 1: Repeat following experiment
      • Using strace let's verify that our understanding of what ioengine=xyz means is correct or not.
      • Use fio=sync setting in your fio file and 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 14766] openat(AT_FDCWD, "jobname.0.0", O_RDONLY) = 3
		[pid 14766] fadvise64(3, 0, 14000, POSIX_FADV_DONTNEED) = 0
		[pid 14766] fadvise64(3, 0, 14000, POSIX_FADV_RANDOM) = 0
		[pid 14766] read(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) = 4090
		[pid 14766] lseek(3, 8180, SEEK_SET)    = 8180
		[pid 14766] read(3, "\210\235L\24\27l\362Ri\206\\25\241\342\227K/\371\223T\34\227\1KZ\0\31\212\343\10\322"..., 4090) = 4090
		[pid 14766] lseek(3, 4090, SEEK_SET)    = 4090
		[pid 14766] read(3, "V\251\222{V\22\250q\tH\323\255_\3055.-\260\265QZ\23\306%\353\36 r\303\23\270d"..., 4090) = 4090
		[pid 14766] close(3)
		...

	
  • We can see in above trace file that file named 'jobname.0.0' is being opened and file descriptor 3 represents it.
  • Then read() system call is used to read 4090 bytes from file corresponding fd 3.
  • close(3) closes the file.

  • Homework 2: Repeat prev. experiment without having ioengine setting. What do you observe?
  • Homework 3: Repeat prev. experiment with ioengine=psync. What do you observe?
  • Homework 4: Repeat prev. experiment with ioengine=libaio. What do you observe? Refer this tutorial to know more about linux asynchronous i/o.

  • 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.