by arielweisberg · 12y ago · 0 comments
You don't get fraction of a millisecond random reads from spinning disks without caching... period. So whatever you think your measuring you aren't.
My experience with performance measurements is that the vast majority of people don't measure what they think they are measuring or don't measure what is actually relevant for the use case (and all related use cases that need to be considered). And if you don't know what the expected result is they can be equally useless because you can't know that your results don't fit reality or the speed of light or whatever.
I wish I had a great answer for how you can get started doing performance work, but it starts with understanding the orders of magnitude of various operations. Flash seeks are hundreds of micros for crappy flash, spindles are ~4 milliseconds and that is with fast spindles. If you are working in memory you should know the difference between instructions (for instructions branching and stalled execution vs continuous execution) and cache misses and the various kinds of cache misses (different tiers, remote NUMA) as well as what happens when you have contended mutual exclusion or CAS primitives.
Minor point though: Digital Ocean at least advertises SSD for their servers, not spinning disk. Fraction of a ms random reads seem within the realm of possibility.
1. OS issues write to RAID HBA, write is stored to NVRAM (or battery-backed RAM on older cards).
2. RAID HBA issues write command to disk.
3. Disk accepts write into onboard buffer, acknowledges it as committed.
4. RAID controller releases cached pages.
5. Power loss.
...and you've lost data.EDIT: Notice that the write never actually touches disk in this scenario. Once a disk drive acknowledges a write, the RAID controller releases the data that was "written" from its cache. Disk writes take milliseconds, while memory writes take microseconds, and usually just nanoseconds. That leaves a relatively huge window during which the power could go out, but before which a write has been safely persisted to disk.
There is no reason for the RAID controller to not let the on-disk cache and scheduling work while it is doing writeback, it only needs acknowledgement at the end before it flushes it's non-volatile cache.
This could also be something that I don't know about. Maybe in the world of disks write barriers are < some disable write caching command? Can controllers issue writes large enough to make up for the lack of caching + write barriers? I have no idea, how SATA works.
Again this gets into why it is hard to know what to expect from a disk IO benchmark. You have to know how the caches are operating and there are many of them and configuration can vary.