Write amplification

From SEGGER Wiki
Revision as of 13:44, 28 July 2021 by Marius (talk | contribs) (Created page with "== 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 cause...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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 is write amplification 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

where: WAFactor - calculated write amplification factor. NumBytesWrittenFS - Number of bytes written by the file system layer. NumBytesWrittenDriver - Number of bytes written by the device driver.

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.

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

where: NumBytesTotal - Total amount of data that can be written to NAND flash device. NumBytesNAND - Capacity of the NAND flash device. MaxNumEraseCycles - Maximum number of times a NAND block can be erased. WAFactor - calculated write amplification factor.

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