Live data from Hacker News

What every programmer should know about SSDs

databasearchitects.blogspot.com

101–110 of 163 posts

Re: What every programmer should know about SSDs

#101

One thing I'm still puzzled about SSD over-provisioning, which is also mentioned by the tutorial ( https://codecapsule.com/2014/02/12/coding-for-ssds-part-4-ad... ) recommended by the article: > A drive can be over-provisioned simply by formatting it to a logical partition capacity smaller than the maximum physical capacity. The remaining space, invisible to the user, will still be visible and used by the SSD control…

Any sector with nothing written on it can be used as scrap.

So if you partition the entire thing, but just never write to the full disk (you never use all the space), that also works as overprovisioning.

Partitioning just forces that to happen.

Re: What every programmer should know about SSDs

#102
post #31

The claim about parallelism isn't true. Most benchmarks and my own experience show that sequential reads are still significantly faster than random reads on most NVME drives. However, random read performance is only somewhere between a 3rd to half as fast as sequential compared to a magnetic disk where it's often 1/10th as fast.

What kind of queue depth do you test the read performance? The sequential can be made fast at low queue depth by the SSD controller doing prefetch reads internally. I've worked on such algorithms myself.

Show me a benchmark at any queue depth where random reads are as fast as the fastest sequential rate for that drive. It's simply not true.

I suspect it has something to do with prediction on the controller but I'm also not confidently spewing a bunch of bullshit about drive architecture unlike this article.

Re: What every programmer should know about SSDs

#103
post #82
post #81

Earlier quoted context omitted.

The kernel can't optimize that because sqlite is specifically requesting it to force a write.

Yes but you can configure the kernel to ignore that, and by default it does. For example, way back in the day, to get more life out of my laptop during college, I configured the kernel to only write to disk once an hour or when the buffer filled up. That effectively meant I was only writing to disk once per hour when I shut down to change classes. The modern linux kernel doesn't actually write to disk when fsync is c…

> The modern linux kernel doesn't actually write to disk when fsync is called. It buffers the writes in a cache.

Do you have a reference for this? That would break every ACID database that I'm aware of, including sqlite and postgresql. There has been a lot of work in the last few years to fix data durability issues with fsync (e.g. https://lwn.net/Articles/752063/), so I would be very surprised to hear that fsync is now a no-op.

Re: What every programmer should know about SSDs

#104
post #82
post #81

Earlier quoted context omitted.

The kernel can't optimize that because sqlite is specifically requesting it to force a write.

Yes but you can configure the kernel to ignore that, and by default it does. For example, way back in the day, to get more life out of my laptop during college, I configured the kernel to only write to disk once an hour or when the buffer filled up. That effectively meant I was only writing to disk once per hour when I shut down to change classes. The modern linux kernel doesn't actually write to disk when fsync is c…

>The modern linux kernel doesn't actually write to disk when fsync is called

Source for this? This seems to be contradicted by the man page for fsync

https://man7.org/linux/man-pages/man2/fdatasync.2.html

       fsync() transfers ("flushes") all modified in-core data of (i.e.,
       modified buffer cache pages for) the file referred to by the file
       descriptor fd to the disk device (or other permanent storage
       device) so that all changed information can be retrieved even if
       the system crashes or is rebooted.  This includes writing through
       or flushing a disk cache if present.  The call blocks until the
       device reports that the transfer has completed.
>I configured the kernel to only write to disk once an hour or when the buffer filled up. That effectively meant I was only writing to disk once per hour when I shut down to change classes.

Sounds great until you get a kernel panic or random shutdown, in which case you potentially get file corruption and/or data loss.

Re: What every programmer should know about SSDs

#105

One thing I'm still puzzled about SSD over-provisioning, which is also mentioned by the tutorial ( https://codecapsule.com/2014/02/12/coding-for-ssds-part-4-ad... ) recommended by the article: > A drive can be over-provisioned simply by formatting it to a logical partition capacity smaller than the maximum physical capacity. The remaining space, invisible to the user, will still be visible and used by the SSD control…

The SSD maintains a translation table for all the virtual addresses exposed by the drive, that maps to the underlying flash physical addresses. Any physical address not in that table, is unallocated and the drive can use freely.

Re: What every programmer should know about SSDs

#106
post #26

Things I have learned about SSDs: If you want to go fast & save NAND lifetime, use append-only log structures. If you want to go even faster & save even more NAND lifetime, batch your writes in software (i.e. some ring buffer with natural back-pressure mechanism) and then serialize them with a single writer into an append-only log structure. Many newer devices have something like this at the hardware level, but your…

LMDB has similar write characteristics where its b-tree is append-only. This gives LMDB amazing performance and very robust ACID transaction support as immutability is baked in.

Re: What every programmer should know about SSDs

#107
post #78

Earlier quoted context omitted.

Do you have a current source for that? I've turned on plenty of cell phones that hadn't been charged or powered on for a couple of years and everything worked normally. Same with thumb drives I've picked up after years. I mean, anything can fail after three months. Your statement doesn't really add anything without stating the failure rates . For all I know the failure rate could be less than that of physical hard dr…

https://images.anandtech.com/doci/9248/2_575px.PNG from https://www.anandtech.com/show/9248/the-truth-about-ssd-data...

Thanks, now I understand where this is coming from.

And the linked article makes clear it's not a worry at all. Key part:

> All in all, there is absolutely zero reason to worry about SSD data retention in typical client environment. Remember that the figures presented here are for a drive that has already passed its endurance rating, so for new drives the data retention is considerably higher, typically over ten years for MLC NAND based SSDs...

Average users virtually never pass the endurance rating, so @teddyh's claim seems awfully sensationalistic.

Re: What every programmer should know about SSDs

#108
post #84

Earlier quoted context omitted.

With O_DIRECT though you're opting out of the filesystem's caching (well, VFS's), forced flushes, and most FS level optimizations, so I'd expect it to perform on par with direct partition access. Do you have numbers showing an advantage of going directly to the block device? Personally, I'd consider the management advantages of a filesystem compelling absent specific performance numbers showing the benefit of direct…

You do when it does that/respects it which isn’t always. The point is that you have more layers. If you’re trying to be as direct as possible, more layers is unhelpful. Since you get most of the same advantages management wise with lvm while using the block interface (including snapshots, resizing, and all the other management goodies), you’re not exactly getting much extra functionality either.

Your concerns are all theoretical and the management disadvantages of direct partition access are real with or without LVM (which itself is exactly the sort of middle layer you claim to be worried about.)

Do you have numbers or not?

Re: What every programmer should know about SSDs

#110
post #105

One thing I'm still puzzled about SSD over-provisioning, which is also mentioned by the tutorial ( https://codecapsule.com/2014/02/12/coding-for-ssds-part-4-ad... ) recommended by the article: > A drive can be over-provisioned simply by formatting it to a logical partition capacity smaller than the maximum physical capacity. The remaining space, invisible to the user, will still be visible and used by the SSD control…

The SSD maintains a translation table for all the virtual addresses exposed by the drive, that maps to the underlying flash physical addresses. Any physical address not in that table, is unallocated and the drive can use freely.

So over-provisioning has to be done before any writes to the drive? What if I want to over-provision a used drive? Discard all blocks first?
Post reply on HN