The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Threads and Threads Count ? varungupta UNIX for Advanced & Expert Users 2 03-21-2008 06:23 PM
threads vijlak SUN Solaris 3 01-29-2007 04:55 PM
threads Gerry405 UNIX for Dummies Questions & Answers 2 06-29-2005 12:30 AM
old threads norsk hedensk Post Here to Contact Site Administrators and Moderators 2 06-03-2003 02:16 PM
nfs threads i2admin UNIX for Advanced & Expert Users 1 03-06-2003 08:28 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-16-2007
Registered User
 

Join Date: Apr 2007
Posts: 75
How many threads do I use ?

Hi,

I have a program that has two types of threads:

1) Reader threads
2) Worker Threads

Readers: Their only job is to read files. They just read data from the files and put them into a buffer. They are obviously I/O intensive.

Workers: These are CPU intensive. They do some computation on the data which has been put into these buffers.

How many threads:

1) Worker: I think this answer is obvious. The number of worker threads should be equal to the number of CPUs in the sytem.

2) Reader: What about these? How can I determine the capability of I/O system ?

Specifically, I want the user to be able to specify the number of Reader and Worker threads the would like the program to use.

QUESTION: What guidelines should the user follow or use to determing this number ? How can they determine the capabilities of the I/O subsystem?

(The program uses 1 reader and 4 worker threads by default)
Reply With Quote
Forum Sponsor
  #2  
Old 07-16-2007
Registered User
 

Join Date: May 2007
Location: Glasgow, Scotland
Posts: 59
I guess the best way would be to include some sort of short benchmark testing ability in your program: the user tweaks the number of threads, chooses to benchmark, then the program tries for say 30 seconds to do as much work as possible, then outputs how many work units each type of thread got through?

I guess the number of workers would be platform specific, so for example, on Linux 2.6 you probably want nCPUs+1, whereas on Solaris10 on a T2000 you only want nCPUs worth of workers.

For readers, you probably don't want a hard disk to be in contention between 2 threads, but having a channel (SCSI or ATA) shared is probably a good move - to ensure that channel is saturated. So i guess readers boils down to the number of hard disk spindles you'll be touching.

Cheers,

-c

p.s. i tried to find some material that backs up my assertion you want nCPUs+1 worker threads on Linux2.6 (i heard this somewhere before), but i couldn't find any, so maybe i'm wrong there? Anyone else know?
Reply With Quote
  #3  
Old 07-16-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by the_learner View Post
Readers: Their only job is to read files. They just read data from the files and put them into a buffer. They are obviously I/O intensive.
Are these reading from files or from sockets? If so you could multiplex using select() so you only need a couple of threads to manage the select rather than a thread per socket.

If they are reading from files, do the files have to be read in parallel?
Reply With Quote
  #4  
Old 07-16-2007
Registered User
 

Join Date: Apr 2007
Posts: 23
Thanks for the replies !

Quote:
Originally Posted by porter View Post
If they are reading from files, do the files have to be read in parallel?
Not necessarily. They just have to read the files into a buffer.
Reply With Quote
  #5  
Old 07-17-2007
Registered User
 

Join Date: Apr 2007
Posts: 75
Hey, I have another question. Lets say I start this program on one machine. Then while it is running, I open up another console, log into the same machine and run the same program. Now there are two programs running. So now these two processes will compete against each other for the system resources right. So, obviously the program will take more time to complete. Am I right ? In general, as system load increases.. more users log onto the same system and start their own programs, the time taken by my program will increase right ?
Reply With Quote
  #6  
Old 07-17-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by the_learner View Post
the time taken by my program will increase right ?
Yes, no and maybe but not necessarily in that order .

1. You can adjust processes priority with nice.

2. A multi-user system shares it's resources, that's what they do.

3. Different architectures scale differently, some linearly, some exponentially.

4. A multiple CPU machine will exhibit different characteristics to a single CPU system.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:03 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0