Okay, let's analyze the bottleneck and explore potential optimizations, keeping your hardware limitations in mind. 400MB/s from a BTRFS RAID5 setup with that many disks is definitely lower than expected.
Here's a breakdown of likely culprits and potential solutions, ordered by priority (in my opinion):
1. RAID5 Write Hole / Checksum Calculation (Likely Culprit)
-
Problem: RAID5 inherently suffers from the "write hole" problem and is known for slower write performance, especially when dealing with many small files. The checksum calculation for parity also adds overhead. While you're focused on read performance, the way the data is written and organized heavily impacts read performance. BTRFS's RAID5 implementation has some quirks and challenges.
-
Solutions:
-
Consider RAID6 Conversion (if feasible and you accept the write penalty): RAID6 provides significantly better data protection and, depending on the controller and software implementation, can sometimes improve read performance in degraded states (one drive failed). However, RAID6 incurs a higher write penalty than RAID5. The N5105 may struggle with the higher computational load of RAID6 parity calculation, but it's worth considering if data integrity is paramount and you're willing to experiment.
-
Re-evaluate RAID5: While RAID5 is relatively space-efficient, it's often not the best choice for performance, especially with modern large-capacity drives. You are using the RAID5 profile for data.
-
RAID1 or RAID10 Alternative: This would provide much faster read performance but at the cost of usable storage space. This likely will NOT fit the available space.
-
RAID-like alternative: Erasure Coding: This uses Reed-Solomon codes and has tunable redundancy and performance. This gives more flexibility than RAID5 or RAID6, which have fixed parameters. There are many options here.
-
Investigate 'mkfs.btrfs' options:
-
RAID stripe width: If not specified, BTRFS will likely be using a suboptimal stripe width. Experiment with different stripe widths to see if you can improve read/write performance. This may require a full rebuild, so it is tedious.
-
Chunk size: Chunk size affects how data is written in parallel across the disks. Experiment with different chunk sizes to see if you can improve performance. You'll likely need to rebuild the FS for this.
-
Backup and Test: Before any major changes, BACK UP YOUR DATA! Experiment on a smaller subset of the disks (if possible) to see how different configurations impact performance before committing to a full rebuild.
2. Disk Fragmentation (Less Likely After Defrag, But Still Possible)
-
Problem: Even after defragmentation, fragmentation can still occur, especially with copy-on-write filesystems like BTRFS. This forces the disk heads to jump around more, slowing down reads.
-
Solutions:
-
Schedule Regular Balance Operations: btrfs balance start -dusage=0 -musage=0 /path/to/mountpoint. Run this periodically (e.g., weekly or monthly) during off-peak hours. This helps redistribute data and metadata across the disks, potentially reducing fragmentation. The -dusage=0 and -musage=0 options aggressively rebalance even almost full chunks.
-
Consider SSD Cache (If Possible): Even a small SSD used as a BTRFS cache (using bcache or lvmcache) can significantly improve read performance, especially for frequently accessed files. This goes against your "no hardware change" rule, but I mention it as a highly effective solution. A small 128GB SSD could make a huge difference.
3. CPU Bottleneck (Possible, Given the N5105)
4. BTRFS Metadata Overhead
-
Problem: BTRFS is a very feature-rich filesystem, and this comes with metadata overhead. The raid1c3 for metadata is a good choice for redundancy, but it also increases the write amplification for metadata writes.
-
Solutions:
metadata_ratio Tuning (Advanced and Risky): The metadata_ratio setting controls the amount of space reserved for metadata. Reducing this value can improve storage efficiency, but it can also lead to performance problems if the filesystem runs out of metadata space. This is a risky setting to adjust without a deep understanding of BTRFS internals.
5. SATA Bus Contention (Less Likely with N5105, But Possible)
6. RAM Issues (Unlikely with 32GB)
-
Problem: Insufficient RAM can cause excessive swapping, which significantly slows down performance. However, with 32GB of RAM, this is unlikely unless you have other memory-intensive applications running.
-
Solutions:
- Monitor RAM Usage: Use
free -m or htop to monitor RAM usage during file transfers. If you're seeing significant swap usage, you may need to investigate other processes that are consuming RAM.
In summary, here's a suggested troubleshooting approach:
- Monitor CPU Usage: Check if the CPU is pegged at 100% during reads.
- Experiment with Zstd Compression Levels: Try lower compression levels or temporarily disable compression to see if it improves performance.
- Schedule Regular Balance Operations: Run
btrfs balance start -dusage=0 -musage=0 /path/to/mountpoint.
- Consider RAID6 (or alternate RAID-like scheme): If data integrity is paramount and you're willing to accept a potential write penalty. BACK UP DATA FIRST!
- Monitor RAM Usage: Ensure you're not swapping excessively.
- Consider SSD Cache (If Possible): A small SSD as a cache can significantly improve read performance.
Good luck! Remember to back up your data before making any significant changes.