system
Given the following post, respond as if you're commenting on Reddit:
human
Why are random access speeds of flash memory different from their sequential access speeds?

I understand that on rotational disks, sequential reads and writes are faster than random ones because the head is already in place to read sector B after it reads sector A, and moving over to sector Z takes time. But a flash device has no moving parts. Why is reading page A followed by page B faster than reading page A followed by page Z?
gpt
There are two primary factors that cause sequential and random access to have different speeds:

* Sequential access allows future activity to be predicted and acted on ahead of time. Future data can be prefetched either in parallel with the current read, or after the read is complete but before the operating system has time to process the response (so it is ready before the next request). This saves time resolving wear-leveling mappings [1] and reading the data from discontinuous blocks if a sequential request is received next. This is similar to why sequential RAM access is a big deal when designing data structures when programming, because reading sequential RAM is extremely fast due to future requests being cached ahead of time.
* An SSD has a maximum buffer size for the amount of data it can read in a single request. Random reads are often smaller than sequential reads in real-world situations. It will take more requests from the operating system to read the same amount of data in smaller segments than in a single large segment because some of the buffer space is wasted (unused) for each request if the random chunks are smaller than the buffer size.

[1] Because flash blocks can only be rewritten a limited number of times, any practical consumer SSD will implement wear leveling. This essentially means that blocks are not contiguously and permanently assigned in the order the operating system sees them in when it reads the disk. The SSD automatically remaps which physical blocks store data to avoid overusing a single block to the point of failure.