Reputation: 237
I have an application that spawns multiple child processes, which then go on to spawn multiple threads. I can control the number of processes and threads that are spawned. The threads do a specific read/write operation to a NAS, and I record how long this takes.
What's odd is that the time it takes to perform the read/write operation is longer with multiple threads. I read /proc/stat before starting the application and when finished, and got this (after some math):
cpu0: 1.0050% usrtime, 2.5126% systime, 95.4774% idle, 0.5025% softirq
cpu1: 0.0000% usrtime, 0.0000% systime, 100.0000% idle, 0.0000% softirq
I also checked sched_getaffinity, and both CPUs are enabled for the child processes. Is there something that I must do, besides spawning multiple threads, to make use of the multiple cores?
Upvotes: 1
Views: 271
Reputation: 11831
You're hardly using your CPU at all. Going out to Network Attached Storage, your bottleneck is most likely your network connection. How much data are you pushing and how much bandwidth can your pipeline (and your NAS) tolerate?
Upvotes: 3