RE: Help with my perl script



I believe you *are* missing something. You're going to have to
understand how processes and forking work in Unix. The fork() call
invokes a new process. In effect it is a new script on its own.
Stephen's Parallel::ForkManager is just syntactic sugaring around the
same thing.

Semaphores have no meaning unless you have separate tasks running. A
process is a kind of task. You do not need the semaphore for your test
as I understand it. The operating system's scheduler is going to
allocate time slices to each process as it sees fit.

Each forked child process is a real process of its own, and each will
open a connection to the database, independent of the other child
processes. The time statements are actually executed relative to one
another is essentially random, which is I believe what you want.

I suggest you read the description of fork() in the perlfunc man page
*very* carefully, as it does a lot more than you may have realised the
first time through. Also you should try reading up on Unix process
semantics.

Again, I recommend simply using fork(), in a loop.

-Will


-----Original Message-----
From: Kevin Carothers [mailto:kevindotcar@xxxxxxxxx]
Sent: Wednesday 23 August 2006 16:48
To: Stephen Carville
Cc: dbi-users@xxxxxxxx; joe bayer
Subject: Re: Help with my perl script


On 8/23/06, Stephen Carville <stephen@xxxxxxxxxxxxxx> wrote:

joe bayer wrote:
Group,

I am trying to write a load testing script.

The script goes like this:
++++++++++++++++++++++++++++++++++ my $j =
0; while ($j < 300) { $dbh[$j] = DBI->connect (
"dbi:Oracle:$instance[$i]", "$username[$i]", "$passwd[$i]", {
PrintError => 1, RaiseError => 1, AutoCommit => 1 } ) || die
"Database Connection not made $DBI::errstr" ;# Create a
Database #do
some random, endless select statement here. $j++; }
++++++++++++++++++++++++++++++++++++++++++

What I want is 300 session do the select statement simultaneously.
But this script will do one session after another.

Do I REALLY have to start 300 perl script in order to
this testing,
or there is some way in perl that one script can start up 300
session and do their invidual select simultaneously?

Check out Parallel::ForkManager.

Thanks for your help.

Joe

--------------------------------- All-new Yahoo! Mail - Fire up a
more powerful email and get things done faster.



Hi Stephen,

Unless I'm missing something (I'm no expert in this arena)
It seems like a script will ecxecute one stmt at a time anyway-
so how about cranking up 300 separate Perl scripts that
synchoronize (ie,
soak up all available system resources simultaneously) with a named
semaphore?

(Win)
$sem = Win32::Semaphore->new($initial,$maximum,$name);

(Unix)
$sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | IPC_CREAT);

I would envision you building a 300-line script to start up
each individual
DB connect, and a single Perl script to "lower the flag" -
causing the 300
perl scripts to pounce.

It seems like this is a much better test anyway- because I
very much doubt
as *single* perl script will have 300 separate DB
connections... but then
again... I don't know what your environment needs.

HTH

KC



- - - - - Appended by Scientific Atlanta, a Cisco company - - - - -
This e-mail and any attachments may contain information which is confidential, proprietary, privileged or otherwise protected by law. The information is solely intended for the named addressee (or a person responsible for delivering it to the addressee). If you are not the intended recipient of this message, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer.

.



Relevant Pages

  • Re: Quick Perl question
    ... > Is there an easy way to write a Perl script for UNIX that returns the ... perldoc -f fork ... Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org ...
    (comp.lang.perl.misc)
  • Re: CGI script: release browser after spawning new process
    ... > filled form and pass them along as command line parameters to another ... > perl script that should run the computation in the background. ... You have to close STDOUT and STDERR, ... You need a fork to protect from this. ...
    (comp.lang.perl.misc)
  • Re: system command on Win98
    ... a fork to execute the file, but maybe I am wrong about that. ... It is a programing language that I create with the ... Perl script and then execute immediately. ...
    (comp.lang.perl.misc)
  • Re: forking an independent process
    ... > From my perl script I need to be able to launch (fork?) an editor ... > I close the parent with a Ctrl+C, it also kills the nedit window. ... from which you execute the perl script. ...
    (comp.lang.perl.misc)
  • Re: Kill forked process on Windows 2000
    ... >> I am writing a perl script using fork. ... >> Unable to register TclNotifier window class ... Problems with Perl/Tk and fork() are discussed in the Perl/Tk FAQ. ...
    (comp.lang.perl.misc)