Recently, I saw a friend using this tool, so I decided to play around with it over the weekend and make some notes.
Sometimes writing code isn’t just about the coding itself; it’s like developing a car—you can’t just know how to build a car, you also need to understand the roads. If a highway only allows a speed of 100 km/h, then it doesn’t matter how fast your car can go.
fio is used to test the performance of file systems.
—— Project GitHub Address
https://github.com/axboe/fio
—— Cross-Compile Your Own fio Executable
First, of course, download the source code. You can download the latest version directly from GitHub, or you can use the code from the release package. I am using the latest code here.
Get help information
./configure –help
Configure the cross-compiler and CPU architecture
./configure –prefix=output –cc=/mmt/rk3308_os/buildroot/output/rockchip_rk3308_release/host/bin/aarch64-linux-gcc –cpu=aarch64
After configuring the compiler and project, you can start compiling.
make -j64
The generated fio will be in the current directory; you can check the file attributes.
Then, we can use this executable file on the development board.
For example, we can execute a script to test the read and write speeds.
—— Parameter Explanation
1. filename=/userdata/1.test Test file; it can also be a block device file, or even memory or flash.
2. direct=1 Whether to use directIO, skipping the system’s built-in cache during testing.
When Linux reads and writes, the kernel maintains a cache, where data is first written to the cache and later written to physical storage FLASH in the background. Reading also prioritizes data from the cache. This speeds things up, but if there’s a power failure, the data in the cache is lost. That’s why there’s a mode called directIO, which skips the cache and directly reads and writes to the SSD for more accurate test results.
3. rw=read Sequential read I/O test.
4. rw=write Sequential write I/O test.
5. rw=randread Random read I/O test.
6. rw=write rw=randwrite Random write I/O test.
7. rw=write rw=randrw Random mixed read and write I/O test.
8. bs=4k Block size for a single I/O operation is 4k.
9. size=5G The size of the test file is 5G, tested with 4k I/O operations.
10. numjobs=8 Number of test threads is 8.
11. name=job1 Task name.
12. thread Use pthread_create to create threads; the other option is to fork processes. Processes are more costly than threads, so threads are generally used for testing.
Ok, that’s it.