brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: fio measures the random read performance of a disk with a test file

Performance
~/tips/tip-performance-fio-random-read

sudo apt install fio

Test small random reads, which feel closer to real use than big copies.

Copy speed looks great and the machine still feels slow with a database on it. Small reads from random places are a different test.

sudo apt install fio
cd /mnt/data
fio --name=randread --filename=fio.test --size=1G \
    --rw=randread --bs=4k --direct=1 --ioengine=libaio \
    --iodepth=32 --runtime=30 --time_based

--bs=4k sets small blocks, --direct=1 bypasses the page cache so you measure the drive and not your RAM, and --iodepth=32 keeps 32 requests in flight. In the output, look at the IOPS figure and the latency percentiles.

Run it again with --iodepth=1. That is closer to a single program waiting for each answer, and the number is usually far lower.

Remove the test file afterwards:

rm fio.test

Warning: --filename accepts a device such as /dev/sda, and a write test on a device destroys what is on it. I stick to a new file inside a mounted folder, with enough free space.

Results depend heavily on the settings, so only compare runs that used the same command. Some filesystems, ZFS in particular, treat direct reads differently and can still serve data from their own cache.

Further reading: fio documentation

More Performance tips EXPLAIN (SETTINGS) SELECT * FROM my_table WHERE id = 42; sudo apt install hyperfine dtparam=fan_temp0=55000 sudo cpufreq-set -g powersave Settings > Media Management > File Management > Analyze video files All Performance tips (9) All topics

Link