Read vs. Write Time

Which operation requires more time - reading from disk or writing to disk for the same amount of data and the same place in memory?

+6
io file-io
source share
3 answers

This is actually a pretty tricky question, and it requires an understanding of how your I / O system is configured. The simple example you are quoting (reading / writing a fixed amount of data to a specific location on disk) is not as realistic as you think. Here is a brief description of things that can affect I / O performance.

Read / write performance is reduced to the totality of all the above effects plus the characteristics of the workload that you load onto the disk (data size, read and write frequency, etc.). As in most cases, you need to experiment with your application, the OS that you are going to run, and your specific disk configuration to get a realistic idea of ​​how it runs.

+17
source share

Short answer: it depends a lot.

From the application level, entries usually appear faster. since you are actually only requesting that the OS write data, and the OS can quickly return to you and write data at your leisure. When reading, you need to wait until the OS returns to you with the data you want.

The file system can dramatically affect the speed of reading and writing ... often a lot of work happens when writing, but if you add a file that can speed up.

Most SSDs are much slower to write than to read.

+3
source share

Buffers will affect the time for reading and writing in large numbers. Buffers can be supported by the operating system in RAM, and many drives also contain internal buffers, which are part of the disk controller.

Note that the operating system can cache part of the file in RAM, so reading from these parts can complete very quickly. In addition, the operating system can cache writes to RAM until there is a sufficient amount to write to disk. The call to the "write" function may return after copying data only to another memory area.

In short, to summarize, if you need to write bits to a disk (using a flash operation or something like that), this operation will be at least until it is read from the disk, most likely longer.

+1
source share

All Articles