Optimize file copying with multiple streams

Can you copy files faster through multithreading?

Change . To clarify, suppose you are using CopyFile (src, tgt). It seems logical that under certain circumstances you can use multiple threads to speed things up.

Edit A few more thoughts:

Naturally, it depends on the HW / storage in question.

If you copy from one disk to another, for example, it’s pretty clear that you can read and write at the same time using two streams, thereby saving the cost of the fastest of the two (usually reading). But you do not need many threads to read / write in parallel, just async-IO.

But if async-IO can really speed up (up to 2x) when reading / writing from different disks, why is this not a standard CopyFile implementation? (or that?)

+3
source share
6 answers

You can see the advantage, especially if the files are on different devices, in which case I / O can be very efficiently shut down.

However, there are also cases where you could easily cause a beating of hardware, so I do not think that this is an optimization that should be taken lightly.

Regarding the additional question you added:

async-IO ( 2x), / , CopyFile? ( ?)

CopyFile(), , :

, ( - ) - , .

+2

, . , , . , SAN, , , SAN .

+4
+3

. CPU.

+2

, , , , IO, IO .

, , .

+1

CopyFile, , (, ), , / (, / ), - .

To improve performance, it can be fully implemented in the kernel.

+1
source

Source: https://habr.com/ru/post/1703051/


All Articles