No performance gain using threads?

Y

Yash

I have a perl program that spawns as many threads as the number of
processors. Each thread reads lines from a set of files exclusively
assigned to it and after performing some in-memory operations, writes
the enriched lines back to disk.
The number of threads is limited by the number of files to process.
When I ran with a single file, it spawned just one thread and took 200
seconds to finish. I could see 1 CPU occupied by looking at the Task
Manager.
When I made 4 copies of the file, it spawned 4 threads and too 800
secs. I was expecting it to take a little more than 200 secs. All 4
CPUs were seen to be occupied.
There is no locking or synchronization between the threads.

This means that the program does not scale up as expected, by
processing more data in different threads.

Is there something else I might need to do in the program logic so
that adding more processors will help me process larger volumes of
data in the same time?

I am using Active Perl 5.8 on Windows 2000.


Thanks
 
B

Ben Morrow

I have a perl program that spawns as many threads as the number of
processors. Each thread reads lines from a set of files exclusively
assigned to it and after performing some in-memory operations, writes
the enriched lines back to disk.
The number of threads is limited by the number of files to process.
When I ran with a single file, it spawned just one thread and took 200
seconds to finish. I could see 1 CPU occupied by looking at the Task
Manager.
When I made 4 copies of the file, it spawned 4 threads and too 800
secs. I was expecting it to take a little more than 200 secs. All 4
CPUs were seen to be occupied.
There is no locking or synchronization between the threads.

Perl's threads are currently highly inefficient... you may want to look
into writing a little 'driver' program that starts several instances of
your processing program, rather than trying to thread.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top