SUMMARY: Single Threaded Code and Multi CPU

From: Manuel Gil - Reach Networks Inc. New York (mgil@reach.com)
Date: Wed May 07 1997 - 07:59:27 CDT


Greetings Sun Managers,

Many Thanks to the following Gurus for their quick response to my
questions:

adminsis@intelideas.com
jbeers@LANcomp.COM
amof@SubaruSparcDev.subaru1.com
gibian@stars1.hanscom.af.mil
Glenn.Satchell@Uniq.com.au
mstier@hotmail.com
s.voss@terradata.de

In short, single threated code doesn't take advantage of a multiprocessor
machine.
And to check the status of individual CPUs, use mpstat. There were other
answers regarding this, but mpstat is closer to what I was looking for.

A compilation of the responses follow. Again, many thanks to all.

Regards,

Manuel

============================================================================
>From adminsis@intelideas.com Tue May 6 15:01:52 1997 >From

> 1) In a multi-processor System (Ultra 3000, Solaris 2.5.1), how does the
> system handle single threated code? Will it distribute the work among
> CPUs? will the system scheduel one CPU to take care of it? How do I
> check this?

        Multithreaded programs do a better job on multiprocessor systems.
However, remember that even the O/S is multithreaded, so unless you have
a single-thread cpu-intensive task, you don't have to worry too much
about it. Solaris will handle it.

> 2) On a similar system, how can I check the load on each CPU individually?

        Get top from a SunSite. My favourite is sunsite.unc.edu.

Saludos,

Alfredo Sola
Administrador del sistema

==============================================================================
>From jbeers@LANcomp.COM Tue May 6 14:52:33 1997

On Tue, 6 May 1997, Manuel Gil - Reach Networks Inc. New York wrote:
>
> 1) In a multi-processor System (Ultra 3000, Solaris 2.5.1), how does the
> system handle single threated code? Will it distribute the work among
> CPUs? will the system scheduel one CPU to take care of it? How do I
> check this?
>
Can't help you here. Sorry.
 
> 2) On a similar system, how can I check the load on each CPU individually?
> When I do 'sar -u' I assume I get an average of all the CPUs,
> though I've also read another version (from Summaries posted here) that
> indicate that sar will show the data of the 1st CPU only.
>
I have used a utility called proctool. It gives information about process
utilization as well as per CPU statistics. Below is the information from
the Proctool - Help (about) windows. Hope this helps.

-------------

ProCtool

ProCtool is a tool for monitoring and controlling processes on a system.
It is available on Solaris only.

Proctool is available in binary form for free. It may also be freely
distributed within and outside of Sun Microsystems. It is not an official
Sun Microsystems product, and it carries no implied support or endorsement
from Sun Microsystems. Please do not attempt to log proctool support
calls with the Sun Answer Center.

The authors, however, intend to support this product on their own time and
we encourage you to file bug reports, requests for enhancements and/or
comments with us at:

    morgan.herrington@west.sun.com (Morgan Herrington)

and

    walter.nielsen@eng.sun.com (Walter Nielsen)

We will announce new versions of proctool outside of Sun on the newsgroup
"comp.unix.solaris", however, we will also maintain a separate
"notification" alias which we will use to inform interested users about
new releases of the tool. If you would like to be added, just send a
short email giving us permission to add you (along with your preferred
email address).

We intend to keep the latest version(s) of proctool (with documentation,
help and startup files) available to the general internet, via anonymous
ftp from:

    sunsite.unc.edu:/pub/sun-info/mde/proctool/proctool_X.Y.tar.Z

and available within Sun at:

    newstop.ebay:/sun/MDE/Performance/proctool/proctool_X.Y.tar.Z

(where X.Y is replaced by the appropriate Solaris version number).
Proctool sometimes appears on other servers, however, these other
locations are not maintained by the authors. If you would like to verify
that the binaries you download have not been tampered with, please contact
the authors and ask for checksums using "sum" or "md5" (whichever you
prefer).

We have chosen not to release source for proctool. We feel this reduces
our support burden and simplifies our relationship with Sun. Please
contact us directly for any special situations.

---------------

-jwb

      --------------------------------------------------------------------
      | James Beers | Phone: (908) 981-1991 |
      | LAN & Computer Integrators, Inc. | FAX: (908) 981-1858 |
      | 242 Old New Brunswick Road, Suite 200 | Email: |
      | Piscataway, NJ 08854 | jbeers@lancomp.com |
      --------------------------------------------------------------------

=============================================================================
>From amof@SubaruSparcDev.subaru1.com Tue May 6 14:47:13 1997

Hi Manuel,

   I'm sure there's plenty of people around who can answer this better than
   me, but here goes...
 
> 1) In a multi-processor System (Ultra 3000, Solaris 2.5.1), how does the
> system handle single threated code? Will it distribute the work among
> CPUs? will the system scheduel one CPU to take care of it? How do I
> check this?

  You can lock a process onto a CPU if you want to... but generally its not
  advised. The system will always schedule the runnable threads (whether
  they're from different or same process) onto available CPU's. If you lock
  a process to a CPU it tends to get in the way of this and decrease overall
  system throughput. Typically over the life of a process it will migrate
  from one CPU to another fairly frequently. I'm not sure if there is any
  tool for watching which processor(s) your process is on (besides, it probably
  migrates quickly enough you wouldn't be able to keep up, anyway). The later
  versions of 'top' don't. I think proctool may (at least I think it used to).

  I should note that for single threaded code - it only has one thread of
  control, so it will only ever be running on one CPU at any given time... but
  which CPU it is on will change over time.

>
> 2) On a similar system, how can I check the load on each CPU individually?

mpstat

> When I do 'sar -u' I assume I get an average of all the CPUs,
> though I've also read another version (from Summaries posted here) that
> indicate that sar will show the data of the 1st CPU only.

No, as far as I know sar will give you the sum of the CPU's (I guess that's
the same as the average...). So if you have four CPU's and just one compute
intensive task, sar should report 25% user).

I guess I'm kinda' curious - is there a reason why you're concerned? What
are you trying to acheive?

Cheers,

Andrew.

==============================================================================
>From gibian@stars1.hanscom.af.mil Tue May 6 13:51:02 1997

Manuel,

>> 1) In a multi-processor System (Ultra 3000, Solaris 2.5.1), how does the
>> system handle single threated code? Will it distribute the work among
>> CPUs? will the system scheduel one CPU to take care of it? How do I
>> check this?

Well, while your code may be single threa<d>ed, many of the system libraries are
multi-threaded, so you should see a win even on a single process. Additionally,
if you have more than one process ready to execute in parallel, with a
multi-processor, they really can. On a uni-processor, multi-processing is done
by time-slicing the single cpu and switching it around when a task has to wait
for something, usually an i/o to complete. On a multi-processor, multiple
processes can really be getting work accomplished at the same moment in time.

>> 2) On a similar system, how can I check the load on each CPU individually?
>> When I do 'sar -u' I assume I get an average of all the CPUs,
>> though I've also read another version (from Summaries posted here) that
>> indicate that sar will show the data of the 1st CPU only.

Have you tried mpstat? (I wish I HAD the multiprocessor system to monitor!)

-Marc

Marc S. Gibian
Telos Comsys phone: (617) 377-6350
PRISM/TFS email: gibian@stars1.hanscom.af.mil

=============================================================================
>From Glenn.Satchell@Uniq.com.au Tue May 6 19:20:22 1997

For your first question a single threaded program has only one kernel
Light Weight Process (LWP) associated with it, thus when the kernel
comes to running that process it can only run on one CPU at a time. The
kernel will try and run that LWP on the same CPU each time it gets its
timeslice to maximise the amount of data that might already be in the
CPU cache, but if the system is busy then there won't be much in the
cache and the process may run on different CPUs each time it is
scheduled.

What tends to happen is that if you have one large process then it will
tend to only run onone processor and the other system processes will
get spread across the remainiing CPUs.

With a multi-threaded process it will have more than 1 LWP and each of
these LWPs can run simultaneously on different CPUs.

The bottom line is that if you run only one main large process and the
remainder are system peripherals you are better off with fewer faster
CPUs.

As for the second check out mpstat (included with Solaris) which shows
how each CPU is doing. You can give it a numeric arguemnt and it will
loop printing statistics every 'n' seconds.

regards,

--
Glenn Satchell   glenn@uniq.com.au    www.uniq.com.au  | Windows:
Uniq Professional Services Pty Ltd    ACN 056 279 335  | 
PO Box 70, Paddington,  NSW 2021,  (Sydney) Australia  | Just another pane
Phone 02 9380 6360 Pager 016 287 000 Fax 02 9380 6416  | in the glass...
      VISIT OUR WEB SITE http://www.uniq.com.au

============================================================================= >From mstier@hotmail.com Tue May 6 23:25:31 1997

>1) In a multi-processor System (Ultra 3000, Solaris 2.5.1), how does the >system handle single threated code? Will it distribute the work among >CPUs? will the system scheduel one CPU to take care of it? How do I >check this? >

Single threaded processes cannot benefit from a multiprocessor system, but a single application may spawn off several processes, and then having a multiprocessor system will benefit.

Note: Unix is multiprocess architecture. There will always be some benefit from having multiple processors. Of course that benefit will diminish rapidly, unless the applications it is running is multiprocess.

>2) On a similar system, how can I check the load on each CPU individually? >When I do 'sar -u' I assume I get an average of all the CPUs, >though I've also read another version (from Summaries posted here) that >indicate that sar will show the data of the 1st CPU only. >

mpstat

-- Matthew Stier mstier@hotmail.com

--------------------------------------------------------- Get Your *Web-Based* Free Email at http://www.hotmail.com ---------------------------------------------------------

=========================================================================== >From s.voss@terradata.de Wed May 7 02:50:57 1997

Hi

An answer for question 2: try mpstat, this is similar to vmstat, but for multiple CPUs.

Regards,

Stefan ,,, (o o) --------------------------------o0Oo-(_)-oO0o---------------------------------

Stefan Voss Phone: # 49 (0) 5139-9908-51 Software & System Support Fax: # 49 (0) 5139-9908-10 TerraData Geophysical Services GmbH e-mail: s.voss@terradata.de Ehlbeck 15 a D - 30938 Burgwedel, Germany

===========================================================================

______________________________________________________ Manuel Gil Network Operations Manager / System Exorcist Reach Networks, Inc. New York, NY Voice : 212-274-0444 Fax : 212-274-0695 Email : mgil@reach.com WWW-mine: http://www.math.jmu.edu/~mgil ____________________________________________ObSig1.2__



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:11:54 CDT