You are probably facing two problems.
One of them was mentioned: you read several files at once. These readings will alternate, leading to a beating of the disc. You want to read entire files at once, and then only multithreading of calculations from the data.
Secondly, you are overheading the Python multiprocessing module. It does not actually use threads, but instead starts several processes and serializes the results through a pipe. This is very slow for bulk data - in fact, it seems slower than the work you do in the stream (at least in the example). This is a real world problem caused by GIL.
If I modify do () to return None instead of container.items () to disable an extra copy of the data, this example is faster than a single stream if the files are already cached:
Two threads: 0.36 with a 16 percent processor.
One thread (replace pool.map with a card): 0: 00.52elap 98% CPU
Unfortunately, the GIL problem is fundamental and cannot be used from within Python.
source share