4 ms·
I wonder how much of that is over-optimization for sequential reads. When I was working in filesystems (back in the spinning rust days), I saw some code whose j
by GauntletWizard 3y ago
I wonder how much of that is over-optimization for sequential reads. When I was working in filesystems (back in the spinning rust days), I saw some code whose job it was to prefetch the next several hunks of data when you accessed data - It was a scaling algorithm, so if the block you were accessing was already in memory it would read several more hunks, and the next time you accessed from that same sequence it'd read 2x more than that, up to a fairly high limit - It made sense in this context to, shortly after a file was opened, just read the entire file into memory if it seemed likely to be used in short order, because disk queue latency was often the major limiting factor.
What this meant was an at least 2x and often 100x read amplification for truly random reads. There were some heuristics to disable that, too, and then drive controllers started doing this directly so some code to managed that interaction, issuing more early in the "pretty sure we want to read more" path but dialing back the scaling. I would not be surprised if this type of logic is implemented into modern SSD controllers directly. When you issue a random read, it actually reads several sectors ahead, just in case those are the next requests.
If we disabled that - How much faster would the random reads path be? How much slower would the sequential be? I suspect (very heavily, given the availability of enterprise drives with precisely this kind of tuning available) that there's a lot of tradeoff to be made.
- zdw 3y agoEven "random" reads from "Random Access Memory" are slower than sequential reads - nearly everything in a computer is designed to exploit sequential locality "truly random" went the way of the dinosaur with the first CPU cache and memory bus wider than the size of read operations.
- mangamadaiyan 3y agoThe couple of filesystems whose guts I was familiar with used to perform sequential read detection to conditionally enable prefetching. Random reads did not suffer, and neither did sequential reads.
- kevincox 3y agoIn theory if everything was block sizes random could be the same as sequential. But as soon as you are pulling in extra data due to alignment you will have lost. Then you have to deal with prefetching being harder and other things that are arguably over-optimizations for sequential access.
- numpad0 3y agoTruly random reads means constantly de-selecting and re-selecting which chips and banks and upper addresses to read, so it'll never be faster or easier than sequential reads, unless the underlying technology would have (hypothetical)limitations for consecutive read operations.