jgreco
Resident Grinch
- Joined
- May 29, 2011
- Messages
- 18,680
However, I would have thought the read performance would have been higher than the write performance?
And you thought this, .. why?
Let me rearrange your thinking about these processes a bit. Keep an open mind and forget some of your preconceived notions.
When you are writing, your traffic comes in over the network, and is immediately placed in the next ZFS transaction group (TXG) to be written. This is effectively a write cache, and it is in system memory, so this fills as fast as those poor little packets can be pulled off the network and dumped in main memory. When the TXG fills, this one moves to a different state, where it flushes out to disk, and a new one opens for current write traffic. This does not imply that you can write forever at unlimited speed; you can only have the current and flushing transaction groups. But your write speeds are effectively limited to the lower of your network speed or your pool speed, with the TXG's acting as a buffer or cache mechanism in between. So as long as you can push traffic at the NAS at high speed, and the pool can write it at high speed, you get really high write speeds.
On the other hand, let's consider a read. The NAS has no idea that you're about to open /mnt/pool/your/data/file/123, so it has to wait for that request to come in over the network. It hopefully has the metadata for that directory in ARC, but has to do a seek to get the first blocks of data. That request goes down to the HDD, takes some milliseconds to seek, reads the data into main memory, then shovels it out the network at you. It may do a limited amount of speculative prefetching to optimize the next read request, but if your file is 1GB or 1TB, it isn't going to read all of that. It has no idea whether or not you're going to ask for it. So maybe it reads 1MB of your file into cache, and the next few read requests are fulfilled from ARC. Now another read request comes in, and the ARC doesn't have the data, so again, the system has to go out to the pool, and pull the data into main memory, before returning it to you.
The write process is effectively a fast-as-it-can-go firehose, while the read process is more of a lock-step process because the NAS isn't prescient.