83 points · by ecliptik · 3y ago · 67 comments
To me it sounds like it's the manufacturers were the true partners in crime here.
Here is a barchart from some of the older Samsung SSD's https://www.diskusjon.no/uploads/monthly_06_2017/post-5591-0...
https://www.diskusjon.no/uploads/monthly_06_2017/post-5591-0...
As soon as you deplete the SLC cache you are down to ~50MB/s
Of course you should ideally be free to change the firmware of the hardware you own, but for that you would have to develop firmware with the desired features yourself.
We do the same thing for automobiles - which have diverse value-add feature sets, but for which we've pushed the average safety level consistently up due to their important and ubiquity.
I think higher prices for enterprise-grade disks are more about reliability than NCQ behaviour.
Each HDD and/or SSD is its own computer, with its own CPU (controller) and RAM (cache). Each video card is its own computer with its own CPU (GPU) and RAM (video RAM). Every USB controller is its own computer with its own CPU and RAM. Each NIC is its own computer with its own CPU and RAM.
And so on and so forth.
Do disks lie? Fuck yeah, and so does everything else. Much like the human world, everyone (everything) lies so the system as a whole can (hopefully) keep running smoothly.
Same with all other hardware indeed, like printers for instance.
That's not how you make a smoothly running system, it's how you make one that insists everything is fine while it's all going to shit.
You could call it "adversarial compatibility", and we owe a lot of tech progress to it.
ATA/IDE was introduced in 1986 and a replacement for CHS wasn't introduced until 2002 when the 8 GB limit of the multiple of the fake CHS sizes became a problem.
1. The kind of drives you’re using if you’re running a distributed consensus in production is going to be enterprise where these kind of games are played a lot less
2. Establishing consensus is time consuming - by the time peers ack it, you will have flushed to disk. In a common 3 replica scenario, that means 1/3 nodes is taken care of.
3. The probability of 2 disks failing simultaneously in ways that cause a problem is pretty small.
But yeah, if your concensus has to be durably written and your flash controller is lying to you, your concensus is worthless (even reading what you wrote isn’t good enough because again - controller can lie to you and satisfy reads from the buffer too)
A disk AND an UPS is probably the minimal combination that you can guarantee that your data is actually persisted.
Which leads me to another question, should it really be the responsibility of each component to gracefully handle a random, instantaneous power loss?
Couldn't we have a small power bank on the motherboard keeping, say, 2 seconds of power and signaling emergency shutdown to components?
In a sense, that is very similar to sending a SIGTERM to a process to allow it to gracefully stop.
Personally I think it should be the responsibility of the operating system. All filesystem operations on modern computers should be atomic, and either entirely succeed or entirely fail. And the OS should work with hard disk manufacturers to make sure their devices meet whatever expectation the OS makes of them.
Hilariously, the OS already uses transactions for its own filesystem metadata operations. But they don't share that capability with end user applications, which end up either being quietly broken in the event of power loss (most apps) or horribly complex to make up for the OS's shortfalls (most databases).
There are dozens of solutions in userland, from git's content-addressing to on-disk B+trees. There should just be a simple, effective, correct transactional filesystem API provided by the OS that applications can simply use. The best part of this proposal: a solution implemented by the OS directly would probably be faster than what most people would implement in userland anyway. Its ridiculous this doesn't already exist.
There's simply no structural reason for power failure (or application crashes) to be able to put hard disk data into an inconsistent, corrupt state.
Well that seems a bit over the top. You would pay the price of full consistency for every write, while just one write every 3 years will fail. It would be insanely slow and wasteful.
Not to mention, that would basically disallow any kind of OS or hardware caching, which is immensely important for 99% of use cases.
> the OS should work with hard disk manufacturers to make sure their devices meet whatever expectation the OS makes of them
This is a bit of wishful thinking. We've seen already on numerous cases (Nvidia?) that OS developpers have very little leverage on hardware manufacturers. The best they could do is issue some kind of "Linux certified" label, which honestly nobody would care about.
Also, I guess there is some form of optimum that users and providers reach in terms of stability versus performance. If one OS provides x10 performance for 99.99% of uses while an other one provides 100% safety for /10 performance, I'm not sure users would choose the latter.
Why would it disallow caches? Just issue writes to a new location on disk and switch reads across to it after the write transaction has committed.
In any case, most writes aren’t performance sensitive. I’m thinking things like saving a file when code editing. My editor shouldn’t need to do some obscure, fragile renaming dance just to overwrite a file safely. It wouldn’t write 10x slower. Just have the OS do what it needs to do so my editor doesn’t have to.
And big transactions (like installing software or OS updates) could just do the whole update to a new location and then atomically swap to it. It shouldn’t cost any performance at all beyond a few pointers being moved around at the end of the transaction.
Maybe doing it for all writes is too much. Let databases opt out if they want to do their own thing. But I think it would be a much better default. Right now all good software does some version of this themselves. An OS level solution would allow all those hacks to be removed. If anything, I’d expect performance to improve.
It was recently deprecated because almost nobody uses it.
https://learn.microsoft.com/en-us/windows/win32/fileio/trans...
Finally, it’s unlikely that implementing it in the OS would be faster because there’s a bunch of flash translation logic and garbage collection that has to happen - much faster if all of that happens on the other side of the PCIe bus with a dedicated coprocessor with a dedicated SPI directly to raw flash.
We could start with a nice implementation in the OS. Probably with a way for applications to opt in and out. And then optimize over time. Optimizations could include better integration with the way NVMe devices actually work, rather than the way they pretend to work to the rest of your computer.
No structural reason no, but a lot of other reasons. You can install your favourite atomic file operations library in your PL of choice and run some benchmarks to identify reason #1.
It's usually a RAID card cache Battery Backup Unit, which keeps the cache contents till the power would be resumed.
HDDs doesn't have anything like this and enterprise grade SSDs have a super capacitor to flush the cache.
Add to this SMR shenanigans.
> should it really be the responsibility of each component to gracefully handle a random, instantaneous power loss?
IMO, no. Sure, theoretically it sounds nice, but nowadays you can have literally gigabytes of data in transit and it's hard to make sure what even if you manage to write it what it would be logically consistent.
> Couldn't we have a small power bank on the motherboard keeping, say, 2 seconds of power and signaling emergency shutdown to components?
You are asking for:
a) a bank of supercaps - pricey, require proper isolation, have a lot of stored power => fails with sparks at best; or
b) LiPo rechargeable battery - pricey, require proper isolation, can pillow => fails with toxic smoke and fires.
And still this doesn't guarantee the data would be consistent.
BTW, there was a thing back in the day, UPS which could be installed in the case (usually 2x5.25"). While it sounds neat, it's the worst of all other variants:
small capacity - no place for a big battery
needs servicing - every 3 years replacement for battery
still can fail with sparks and fire
Just like the numerous ups and raid batteries I've had that reported they were fine until the moment they were actually needed.
Some server disks might have a backup power source, but that's certainly not a consumer hardware.
As far as I know this mechanism is not used for write caches.