Answer the question
In order to leave comments, you need to log in
What theoretically can limit the speed of streams more?
Abstract situation:
We want to create (very) many threads on some x86 machine and read a file from the hard disk in each of them.
What limitation, as the number of threads increases, will we rather run into: there will be "too high costs for creating and managing threads" or in the "queue for access to HDD".
Answer the question
In order to leave comments, you need to log in
The cost of creating a thread is optimized by the pool of the latter. It's not a question.
The question is different. What operating system is being used? Is there a forced thread switching? How much data is read from the hard drive? Is he consistent? How are threads synchronized?
The final result will depend on the answers to these questions.
Most likely (99%) the whole thing will rest on the railway, but not a fact.
As you increase the number of threads reading from different locations (if the file is large enough) on your hard disk, you may experience performance degradation due to I/O scheduling. For a hard drive, one of the slowest operations is seek, which is accompanied by a physical movement of the head. Various algorithms are used to minimize movement. For example, these may be modifications of the Elevator algorithm .
If reading becomes a bottleneck, it might be worth trying tweaking the scheduler.
Do you also want to make a mega fast file copyer? I saw a similar question on a forum. But seriously, and you really want to work with a bunch of files, then depending on the system, you need to use asynchronous I / O, implementations depend on the system, but you can also use universal functions like libevent, boost:: asio, etc. And this will be the best solution, run your own event handler for each HDD and go ahead. Well, a large number of threads will not help here, IOPS will not get higher from this, increase IOPS, cache in memory.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question