How to use SSD to avoid writing slower?

Garbage Collection (GC) is an important task of FTL. We imaginary a small SSD space, to talk about the principle of garbage collection, and the concept of WA (Write Amplification) and OP (Over Provisioning) closely linked with it.

Small but complete. Cuihua, on the sparrow.

Figure 1-1 Fictitious small SSD space

We assume that the SSD has 4 channels (Channel, CH0-CH3) at the bottom, and connects 4 Dies (Dies on each Channel can be operated in parallel), assuming that each Die has only 6 flash blocks (Block0-Block5), so A total of 24 flash blocks. There are 9 small blocks in each flash block, and the size of each small block is the same as the logical page size. Among the 24 flash blocks, we assume that 20 of the flash block sizes are SSD capacity, which is the size of the SSD seen by the host; the other 4 flash blocks are reserved space beyond the SSD capacity, which we call OP (Over Provisioning). ).

Well, an SSD is in front of us and the eggs begin to write small movies.

Figure 1-2 After the Host Writes 4 Logical Page Data

We write four logical pages in sequence and write them to Die on different channels. The purpose of this write is to increase the underlying parallelism and improve write performance.

The user continues to write sequentially, and the firmware writes the data to each Die until it fills the entire SSD space (as seen by the host). as follows:

Figure 1-3 SSD filled with user space

The entire disk is full (from the user's point of view, the entire user space is full, but in the flash memory space, due to the existence of the OP, it is not full), what if the egg wants to put more small movies? Can not do anything, can only delete the small movies that have been watched, and free up space for new movies.

Continue to copy into small movies.

Figure 1-4 Write 4 logical pages after deleting 4 logical pages

Assume that you still write from logical page 1. At this point, the SSD writes the newly written logical page to the so-called OP space. For the SSD, there is no user space or OP space, it only sees the flash space. The host sends data, and the SSD writes to the flash memory. Someone above is red, how is it? Because the data of the logical pages 1-4 has been updated and written to a new place, the logical pages 1-4 of the previous position are invalid, expired, and become garbage. The user updates the data. Since the flash memory cannot be overwritten in the original position, the firmware can only find new data in another flash memory space, thus resulting in outdated data in the original flash memory and garbage.

Continue to write sequentially, with more and more red squares (more and more junk data). After all flash memory is full, the small SSD world looks like this:

Figure 1-5 Flash memory space is full

After all Block 5 on Die was filled, all Block 0 on Die was also red (these data are junk).

Not only is the entire user space now full, the entire flash space is full. What if the user wants to continue writing subsequent logical pages (after 36)?

At this time, garbage collection is needed. We temporarily walked out of the previous SSD system to see what is garbage collection.

What needs to be explained here is that in practice, the GC will not start until all the flash space is full, but the GC will be triggered before it is full. This is just an assumption for describing the GC.

Garbage collection is to read out the valid data (green in Figure 4-19) of a flash block, rewrite it, and then erase the flash block to get a new free flash block.

Figure 1-6 Example of garbage collection

In the figure, Block x above is valid data A, B, C, Block y The valid data above is D, E, F, G, the red square is invalid data. The garbage collection mechanism is to find a usable Block z, and then move the valid data of Block x and Block y to Block z so that there is no valid data on Block x and Block y, and it can be erased to become two available Flash block.

Figure 1-7 Erase Garbage Block into Available Data Blocks

Go back to our little SSD system.

In the above example, since we are writing sequentially, garbage is concentrated on Block 0 and there is no valid data on it. We erase them to free up new write space. The user can write new data to Block 0 on which the garbage collection is completed. From this example, we can see that: sequential writes, even if the flash memory is full write (Full Drive write) performance is better, because garbage collection can be completed quickly (perhaps only an erase action) .

But the reality is cruel: users write data, more likely to write data at random. Here is what a flash memory space looks like after it has been completely filled:

Figure 1-8 SSDs with Random Flash Memory Space

If the user continues to write data to the SSD, what happens to the SSD? Of course you need to do garbage collection. As the world has changed, the internal conditions of the SSDs are much more complex than previously seen. Spam data is scattered on each flash block rather than on some flash blocks. At this time, how do you select the flash blocks that need to be recycled? Yes, picking up more chunks of flash memory to recover, because there are fewer valid data and less data to be moved, this frees up flash blocks.

Count the number of garbage (red squares) for each flash block above:

Table 1-1 Statistics of Garbage on Each Flash Block

Since we are writing to 4 channels at the same time, we need to have an empty flash block for each channel. Therefore, when we do garbage collection, instead of reclaiming a flash block, we must pick one on all channels. Generally, all flash blocks with the same block number on each die are selected for garbage collection. In the above example, Block 0 has the largest amount of garbage (24 red squares, maximum), so we pick Block 0 as a flash block for garbage collection (Ignore PE count and other factors, just look at the number of garbage). After reclaiming, we rewrite the previous valid data (green box) above Block 0 back to these flash blocks (here, we assume that the recovered valid data and user data are written in the same flash block. Actually, they may be written separately. ).

Figure 1-9 BLOCK0 can continue to write data after garbage collection

At this time, with free space (white squares), users can continue to write data.

Rumors: SSD writes slower. That's right, in fact, there is a scientific basis for this: When available flash space is plentiful, SSDs do not need to do GC because there is always free space to write. SSDs are used early, and because they do not trigger the GC, they do not require extra reads and writes, so they are fast. Slowly, SSDs will slow down, mainly because SSDs need to do GC.

DIY Breadboard KIT

Diy Breadboard Kit,Breadboard And Jumper Wire Kit,Large Breadboard Kit,Breadboard Prototyping Kit

Cixi Zhongyi Electronics Factory , https://www.zybreadboard.com

Posted on