Hi there,
The code below is executed on a Solaris 8 machine, with 4 CPUs
I would "expect" with values >4 for $MaxSem, that all the CPUs would be utilized
for the parsing. The parsing is quite CPU intensive, running ~20minutes for the 24files
on all four CPUs.
However, according to top/vmstat/iostat/etc. the max usage for $MaxSem set to 5 or 4
is <70%, without any real disk activity not blocking for disk IO (it's a 4GB RAM
machine,
and the files are allready cached/buffered when it hit the foreach loop)
Thus I'm missing the utilization of more than 1CPU for this :(
Please advise
Hendrik
---code.pl----
use threads;
use Thread::Queue;
use Thread::Semaphore;
#The Semaphore that dictates the max concurrent threads...
my $MaxSem = Thread::Semaphore->new(5);
#The semaphore that keeps the output serialized
my $OutputLock = Thread::Semaphore->new(1);
foreach $File (@FList){
async {
$MaxSem->down(1); #Locking to prevent too many threads simultaneously..
%Output=&Parse($File);
$MaxSem->up(1);
$OutputLock->down(1);
print {$OFile} $Output;
$OutputLock->up(1);
};
} #FList
#Make sure none is still running:
foreach $thr (threads->list) {
print "Thread id: ".$thr->tid."\n"
if $DEBUG >1;
$thr->join; }
-----code.pl------
# psrinfo -v
Status of processor 0 as of: 09/28/03 11:16:39
Processor has been on-line since 09/26/03 10:44:08.
The sparcv9 processor operates at 440 MHz,
and has a sparcv9 floating point processor.
Status of processor 1 as of: 09/28/03 11:16:39
Processor has been on-line since 09/26/03 10:44:09.
The sparcv9 processor operates at 440 MHz,
and has a sparcv9 floating point processor.
Status of processor 2 as of: 09/28/03 11:16:39
Processor has been on-line since 09/26/03 10:44:09.
The sparcv9 processor operates at 440 MHz,
and has a sparcv9 floating point processor.
Status of processor 3 as of: 09/28/03 11:16:39
Processor has been on-line since 09/26/03 10:44:09.
The sparcv9 processor operates at 440 MHz,
and has a sparcv9 floating point processor.
# uname -a
SunOS server 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-80
% perl -V
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi
uname='sunos niv-svr-03 5.8 generic_108528-13 sun4u sparc sunw,ultra-80 '
config_args='-D'
hint=previous, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O',
cppflags='-D_REENTRANT -fno-strict-aliasing -I/usr/local/include -D_REENTRANT
-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
ccversion='', gccversion='2.95.3 20010315 (release)', gccosandvers='solaris2.8'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib '
libpth=/usr/local/lib /usr/lib /usr/ccs/lib
libs=-lsocket -lnsl -ldl -lm -lrt -lpthread -lc
perllibs=-lsocket -lnsl -ldl -lm -lrt -lpthread -lc
libc=/lib/libc.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' -Wl,-E -R
/usr/local/lib/5.8.0/sun4-solaris-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags=' -Wl,-E -G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
Built under solaris
Compiled at Aug 4 2003 22:33:45
@INC:
/usr/local/lib/5.8.0/sun4-solaris-thread-multi
/usr/local/lib/5.8.0
/usr/local/lib/site_perl/5.8.0/sun4-solaris-thread-multi
/usr/local/lib/site_perl/5.8.0
/usr/local/lib/site_perl
.
%
Running at "peak" load:
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
0 0 0 810 871 300 5754 545 202 3949 0 8780 75 15 0 10
1 0 0 527 568 101 6082 538 240 3905 0 8849 72 12 0 16
2 0 0 485 594 127 5997 523 224 3903 0 8969 72 13 0 15
3 0 0 460 675 100 6053 664 202 3939 0 8854 71 11 0 18
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
0 0 0 754 901 300 5282 568 182 3271 0 7620 70 12 0 18
1 0 0 450 528 101 5394 479 199 3531 0 8109 67 12 0 20
2 0 0 462 517 100 5281 477 194 3644 0 8494 75 12 0 12
3 0 0 436 556 100 5530 511 180 3512 0 8339 76 10 0 14
CPU minf mjf xcal intr ithr csw icsw migr smtx srw syscl usr sys wt idl
0 0 0 718 868 300 5572 548 196 3521 0 8265 76 13 0 11
1 0 0 443 467 104 5141 412 178 3637 0 8036 78 11 0 11
2 0 0 414 501 102 5104 446 189 3442 0 7738 66 13 0 21
3 2 0 411 527 100 5239 486 178 3442 0 8002 73 12 0 15