I believe that there are not a few players who have heard about purchasing SSD to support trim, but I am sure most players have not understood what trim is doing so far, just follow suit, here I will explain the trim command in detail.
Q: Why do we need trim?
A: We all know that when a file is deleted, the operating system does not actually Delete the data-"In fact, it only marks the Covered Area in the index area before the hard disk, so the next time the data is to be written again, it can overwrite the marked area. This is why the so-called file recovery software can be restored. (Data still exists )."
Note: the hard disk itself does not know the status of the current data, but it is controlled to do this. The above works perfectly on an ordinary mechanical hard disk because they can directly overwrite the old area, but it won't work when it is used on nand flash memory, when all the flash memory is fully written and no spare (never written) blocks can be used, the speed will be reduced.
In SSD flash memory, data storage is generally stored in the smallest unit of page (typically 4 kb), and 128 pages constitute a block (Block ), data can be read and written on pages of 4 kb size, but can only be deleted with a block size of 128 KB (page. When reading data or writing data to an unused page, the SSD speed is very fast, but Overwriting data is complicated, many steps are required. The steps are as follows:
When all idle SSD blocks are used, write operations are performed again. The data can only be overwritten to the region marked as deleted by the operating system. This is also the beginning of the Speed Drop:
To override a file system with a 4 kb page, copy the entire kb block to the cache. Then, delete the 4 kb page in the cache and replace it with the new data. Next, clear the 512kb area of the entire flash memory and write the new data back from the cache. If you need to override a lot of blocks at the same time-"for example, a series of small file random write operations or simply write a large file to SSD". You will overload your SSD cache quickly, and then your write speed will "vertically drop"... It tells you how slow it may be. SSD with less cache in the early stage may even have a latency of nearly 1 second (jmf602 stream). To fix this problem, SSD manufacturers add more and more external caches to the new master controller, although this solves the random Write Card problem to a certain extent, however, it cannot solve the problem of speed reduction during SSD overwriting.
Q: What did the trim command do?
A: in short, this problem occurs because the operating system and file system cannot communicate with the SSD master to delete files. If there is any data that has not been cleared before, all write pages must be cleared before rewriting, which seriously affects the write speed. There are two ways to fix this problem:
The first is to regularly run the garbage collection program (GC) (this operation is a bit like sorting, when the SSD is idle, scan all valid pages and combine them into a block containing all valid pages. Invalid pages and blocks will be completely cleared ).
The second better way is to let the system tell the SSD data when the data is deleted, so that the SSD can immediately erase the blocks occupied by the data. This is what the trim Command did.
After a file is deleted in a system that supports trim, the operating system sends a command to SSD to let him know that the page where the data is located can be directly written, it is equivalent to changing the control from the operating system to the firmware of the SSD master controller. SSD copies the entire block containing the deleted data to the cache, clears the block, and writes the valid data page back, the difference is that the delay is equal to the time from the time when the data is overwritten to the time when the data is deleted (at this time, you are not sensitive to speed, if you delete a large amount of data, you can observe that the hard drive lights flash in a few seconds after you delete them.) Naturally, the SSD speed will return, because there are available empty blocks when you write data. A program named wiper in the SSD controlled by barefoot scans the entire disk and clears the deleted page (similar to trim operations, manual operations ), make SSD as new. In fact, this program backs up valid data in advance before clearing all deleted data. Because the unique algorithm of the program corresponds to the master control, the master control of other systems is not supported. Because it is not a real trim command (not a command issued by the system), it can support old systems such as XP.
So we can say that the real secret that trim ensures that the speed will not fall is: we have done what we will do in advance. However, this will be done sooner or later, so it will basically not affect the existing SSD write count (lifetime ).
Many people say that trim is produced for testing. This is true, because 1. Trim cannot speed up, but it just ensures that the speed is as low as possible. (Actually, the speed of the capacity not used on the SSD does not decrease. Trim cleared the block in advance. You can write it directly next time .) 2. Trim did not change what it was originally intended to do, but it did not need to be done before testing the software, so it "seemed" faster.
For GC, the old pages are merged into new blocks because they are moved and organized. Deleting invalid old blocks sacrifices the number of write times (lifetime ). However, GC supports raid.
Q: What are the requirements for trim support? Does raid support trim?
A: First of all, I am also a player, not an industry player. Therefore, the answer below may be incorrect. You are welcome to point out that the answer is updated at any time. The answer is not always in the future.
Three elements of trim: 1. System: win7, 2008r2, Linux core 2.6.28 or above.
2. Firmware: the SSD manufacturer must include the trim algorithm in the firmware.
3. DRIVER: Ms driver, supported by Intel ahci driver. It depends on the later update.
The above three points are indispensable.
The disks in the raid array do not support trim, but raid supports GC.
The sf1200 and sf1500 master SSDS under the current firmware must use intel's ahci driver. msahci does not support trim. This bug occurs because the main control algorithm is extremely special and adopts a reformed compression algorithm. As a result, when data is deleted, the trim command is sent to the wrong page and block, leading to a trim failure.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service