Zfs 3
Zfs 3
Synchronous Reads
Purpose
This command benchmarks sequential read performance for a high-concurrency workload
(2 jobs, 32 I/O depth) with a controlled throughput rate (125 MiB/s). It simulates scenarios
like large file reads (e.g., video streaming) in an asynchronous I/O environment.
Command
3. Disable Prefetching
echo 1 | sudo tee /sys/module/zfs/parameters/zfs_prefetch_disable > /dev/null
5. Run FIO
sudo fio --name=test_seq_read_async --rw=read --bs=1M --size=1G --numjobs=2
--runtime=120 --time_based --rate=125m --iodepth=32 --ioengine=libaio
--directory=/var/lib/docker --fallocate=none --group_reporting
Command Explanation
● --rw=read: Runs a read operation.
● --ioengine=sync: Forces synchronous I/O.
● --bs=4k: Block size is 4 KiB.
● --size=1G: Test 1 GiB of data.
Results
Look at the outputs from the fio tests for the following metrics.
1. Throughput (READ in MiB/s): Check the READ line for throughput.
2. IOPS: Check the iops value.
3. CPU Usage: Look at cpu usage.
4. Total Data Read: Look for total read data.
Non-Tunable Table
Grafana Results
Throughput
node_zfs_zpool_dataset_reads
Operation: Rate
node_cpu_seconds_total
Command
3. Enable Prefetching
echo 0 | sudo tee /sys/module/zfs/parameters/zfs_prefetch_disable > /dev/null
Compare Results
Look at the outputs from the fio tests for the following metrics.
1. Throughput (READ in MiB/s): Check the READ line for throughput.
2. IOPS: Check the iops value.
3. CPU Usage: Look at cpu usage.
4. Total Data Read: Look for total read data.
Comparison Table
Grafana Results
Throughput
node_zfs_zpool_dataset_reads
Operation: Rate
node_cpu_seconds_total
3. Explanation
Recordsize Adjustment
The recordsize parameter determines the block size used by
ZFS for reading and writing data. By default, it is set to 128 KiB, which is optimized for
larger, sequential workloads like backups or video streaming. For synchronous reads,
which often involve small, random I/O operations (e.g., database queries), a smaller
recordsize (e.g., 4 KiB) is more suitable. This matches the typical block size of such
workloads and reduces read amplification, meaning ZFS doesn’t fetch more data than
necessary. The result is improved IOPS and reduced latency, as the system processes
only the required data.
Metadata-Only Caching
ZFS uses the Adaptive Replacement Cache (ARC) to store
both data and metadata. Metadata includes information like file paths, directory
structures, and permissions, which are frequently accessed in workloads involving
synchronous reads. By setting the cache to prioritize metadata
(primarycache=metadata), ZFS focuses on storing this critical information, ensuring
quicker lookups and file access. This avoids filling the cache with raw data blocks that
are less frequently reused, leading to higher cache efficiency and faster response
times.
Prefetching
Prefetching allows ZFS to anticipate sequential read operations by
loading adjacent blocks into memory before they are explicitly requested. While
synchronous reads can sometimes involve random I/O, many workloads (such as log
file processing) have a degree of sequential access. Keeping prefetching enabled
ensures that ZFS can proactively load contiguous data blocks into the ARC, reducing
disk reads and improving throughput for sequential parts of the workload. This
optimization is especially beneficial for workloads with mixed I/O patterns.