What is write amplification
The write amplification is an unwanted effect that occurs when the data is written to a storage device such as a NAND or NOR flash. It causes more data to be written to the storage device than the file system layer actually requested to be stored. The reason for this is that on these types of storage devices the data cannot be simply overwritten. Instead, the device driver has to write the new data to a new location that has to be erased first and then to invalidate the old data. Freeing the space occupied by the old data causes valid data to be copied from one location to another on the storage device which increases the number of write operations. In addition, the wear leveling procedure can cause additional write operations if the application stored data that rarely changes. The write amplification can have a negative effect on the lifetime of the storage device which is limited by the number of times an storage block can be erased. It can also have a negative impact on the write performance.
How the write amplification is measured
The write amplification is measured using the write amplification factor which is calculated as a ratio between the number of bytes written by the file system layer and the number of bytes written by the device driver to the storage device:
WAFactor = NumBytesWrittenFS / NumBytesWrittenDriver
WAFactor is calculated write amplification factor,
NumBytesWrittenFS is the number of bytes written by the file system layer and
NumBytesWrittenDriver is the number of bytes written by the device driver to the storage device.
The value of the write amplification factor can never be smaller than 1. The smaller is the value of the write amplification factor the longer is the lifetime of the storage device and the better is the write performance.
How to reduce the write amplification
Generally, the write amplification is dependent on the design of the device driver and on the state of the data on the storage device. However, it should be possible to reduce the write amplification factor by following these good practices:
Sequential data write
The lowest write amplification factor is achieved when the data is written sequentially to the storage device because the device drivers of emFile are optimized for this type of write operation. All the device drivers have a write amplification factor of 1 when the data is written sequentially to a newly low-level formatted device until the storage device is filled up.
The write amplification of Universal NAND driver
The write amplification factor of the Universal NAND drive is typically around 1.2. This means that if the application writes 1 MiB of data the file system will write approximately 1.2 MiB of data to the NAND flash device. The value of the write amplification factor can be used to calculate the approximate amount of data an application can write to the NAND flash device during its entire lifetime. The following formula can be used for this purpose:
NumBytesTotal = NumBytesNAND * MaxNumEraseCycles / WAFactor
NumBytesTotal is the total amount of data that can be written to NAND flash device in bytes,
NumBytesNAND is the total capacity of the NAND flash device in bytes,
MaxNumEraseCycles is the maximum number of times a NAND block can be erased and
WAFactor is the calculated write amplification factor as described above.
For example the total amount of data that can be written to a 128 MiB NAND flash device is about 1000 GiB if each NAND block can be erased 10,000 times with a write amplification factor of 1.2.