Re: Filehandles

2002-08-31 Thread Joe Schaefer

Stas Bekman [EMAIL PROTECTED] writes:

[...]

 perl 5.8.0 internals are thread-safe, so does mod_perl 2.0-dev.
 
 By saying that perl is thread-safe, I mean that operations like push, =, 
 /, map, chimp, etc. are thread-safe. 
  ^

A thread-safe chimp; amazing!  Try doing *that* in Java.

-- 
Joe Schaefer



Re: Filehandles

2002-08-30 Thread Randy Kobes

On Fri, 30 Aug 2002, Stas Bekman wrote:

  I think he said mod_perl 2 in his inital post. Which I'm not sure really is 
  all that swift with concurrant requests under threaded mpms (Win32 is 
  limited to threaded mpms) ... least nobody seems 100% happy with the 
  threaded mpm performance of mod_perl 2 yet (Stas? Anybody? How's it 
  looking?)
 
 Caution: you are entering unchartered waters.
 
 first of all: you must use 5.8.0 with threaded mpms
[ ... ] 
And, unfortunately for Win32, ActiveState has reportedly decided
not to release a perl-5.8 binary build in the near future, but
rather perhaps wait until a 5.8.1.

-- 
best regards,
randy




Re: Filehandles

2002-08-29 Thread Perrin Harkins

Justin Luster wrote:
 Does anyone know anything about flock and mod_perl?

Yes.  There is no problem with flock and mod_perl.  However, if you were 
to open a filehandle in startup.pl and then use that same filehandle 
after forking, that could be a problem.

Personally I would suspect Windows in this case.  I don't know about XP, 
but Windows 95/98/ME did not have a working flock.  If XP is based on 
the NT code, it may not have that problem.  Even so, I would try testing 
that first, or maybe asking about it on Win32 perl mailing list.

- Perrin





Re: Filehandles

2002-08-29 Thread Justin Luster

Thanks for responding so quickly.

flock does work under Windows 2000 and above.

The load tester that I'm using works fine with my script outside of
mod_perl.  My script works inside of mod_perl with only one concurrent user.
When multiple concurrent users began hitting the script under mod_perl,
using Apache::Registry or Apache::RunPerl all heck breaks loose.  It seems
that the file locking breaks down.  Another thing that is totally bizarre is
that stuff is being written to all kinds of files that I'm not writing to.
Even my scripts themselves will sometimes have text appended to the end of
them.  Another problem is that Apache will give me an error message saying
that it is trying to write to memory that is locked.

Do you have any idea where I can go from here?

What it the address of the Win32 mod_perl mailing list?

Thanks.

- Original Message -
From: Perrin Harkins [EMAIL PROTECTED]
To: Justin Luster [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, August 29, 2002 12:11 PM
Subject: Re: Filehandles


 Justin Luster wrote:
  Does anyone know anything about flock and mod_perl?

 Yes.  There is no problem with flock and mod_perl.  However, if you were
 to open a filehandle in startup.pl and then use that same filehandle
 after forking, that could be a problem.

 Personally I would suspect Windows in this case.  I don't know about XP,
 but Windows 95/98/ME did not have a working flock.  If XP is based on
 the NT code, it may not have that problem.  Even so, I would try testing
 that first, or maybe asking about it on Win32 perl mailing list.

 - Perrin








Re: Filehandles

2002-08-29 Thread Chris

 Personally I would suspect Windows in this case.  I don't know about
 XP,  but Windows 95/98/ME did not have a working flock.  If XP is based
 on  the NT code, it may not have that problem.  Even so, I would try
 testing  that first, or maybe asking about it on Win32 perl mailing
 list.

XP is based on the NT Kernel, and should have a working flock. I believe In 
recent versions of 5.6.1 flock() is emulated on the 9x kernel as well. 
However this doesn't mean mod_perl supports it, but I'm pretty sure (98%?)
Activestate and Win32 perl does. I've never flock-ed in my life (never had 
a need) but I have been tracking Perl and Apache under Win32 for quite a 
while so take all this with a grain of salt.

-Chris




Re: Filehandles

2002-08-29 Thread Chris

 Thanks for responding so quickly.
 
 flock does work under Windows 2000 and above.
 
 The load tester that I'm using works fine with my script outside of
 mod_perl.  My script works inside of mod_perl with only one concurrent
 user. When multiple concurrent users began hitting the script under
 mod_perl, using Apache::Registry or Apache::RunPerl all heck breaks
 loose.  It seems that the file locking breaks down.  Another thing that
 is totally bizarre is that stuff is being written to all kinds of files
 that I'm not writing to. Even my scripts themselves will sometimes have
 text appended to the end of them.  Another problem is that Apache will
 give me an error message saying that it is trying to write to memory
 that is locked.
 

Could this be a threading issue? Are you using 5.6.1 or 5.8 with mod_perl 
2? I know that mod_perl 2 is far from ready for primetime especially under 
the threaded mpm's (which is what Win32 is forced to use). I use XP to 
develop for a Linux mod_perl 1 architecture so I'm raipdly getting out of 
my depth, but this sounds like the place to look. 


I've never heard of a Win32 specific mod_perl list ...  :(

-Chris





Re: Filehandles

2002-08-29 Thread Perrin Harkins

Chris wrote:
 XP is based on the NT Kernel, and should have a working flock. I believe In 
 recent versions of 5.6.1 flock() is emulated on the 9x kernel as well. 
 However this doesn't mean mod_perl supports it

It does actually, since mod_perl is Perl.  Thanks for the flock 
clarification.

- Perrin




Re: Filehandles

2002-08-29 Thread Perrin Harkins

Justin Luster wrote:
 The load tester that I'm using works fine with my script outside of
 mod_perl.

Does it work when running them concurrently under CGI?

 When multiple concurrent users began hitting the script under mod_perl,
 using Apache::Registry or Apache::RunPerl all heck breaks loose.

Hmmm, which version of mod_perl are you using?  If you're using 2.x, I 
can't help you there since I've never tried it on Win32.  Maybe Randy 
will have some ideas.  If you have 1.x, there is no concurreny under 
mod_perl -- requests are serialized.

- Perrin




Re: Filehandles

2002-08-29 Thread Justin Luster

The stress tool that I'm using is from Microsoft and is a free download.  It
is called Web Application Stress.  There is a setting in this tool called
Concurrent Connections (threads).  As I mentioned before I am able to do
this no problem under regular CGI with 10 concurrent users but when I run
mod_perl all heck breaks loose.

- Original Message -
From: Perrin Harkins [EMAIL PROTECTED]
To: Justin Luster [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Thursday, August 29, 2002 1:44 PM
Subject: Re: Filehandles


 Justin Luster wrote:
  The load tester that I'm using works fine with my script outside of
  mod_perl.

 Does it work when running them concurrently under CGI?

  When multiple concurrent users began hitting the script under mod_perl,
  using Apache::Registry or Apache::RunPerl all heck breaks loose.

 Hmmm, which version of mod_perl are you using?  If you're using 2.x, I
 can't help you there since I've never tried it on Win32.  Maybe Randy
 will have some ideas.  If you have 1.x, there is no concurreny under
 mod_perl -- requests are serialized.

 - Perrin







Re: Filehandles

2002-08-29 Thread Chris

Didn't mean to take this off list if I had. Heh.

 I'm using Perl 5.6
 
Unless someone with better knowledge pipes up, to the best of my knoweledge 
there are threading/concurrancy issues with mod_perl 2 and 5.6.1 ... I know 
that Randy has said in places that eventually the officiall recomdendation 
for Win32 Apache/mod_perl 2 will be 5.8 because it's theoretically more 
thread safe.

I've never used either 5.8 (Activestate hasn't moved to it yet) nor 
mod_perl 2 (isn't finished yet, and I have a hard enough time supporting 
mod_perl 1) so all of this is based off hersay and rumor.


-Chris


 - Original Message -
 From: Chris [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Thursday, August 29, 2002 1:21 PM
 Subject: Re: Filehandles
 
 
  Thanks for responding so quickly.
 
  flock does work under Windows 2000 and above.
 
  The load tester that I'm using works fine with my script outside of
  mod_perl.  My script works inside of mod_perl with only one
  concurrent user. When multiple concurrent users began hitting the
  script under mod_perl, using Apache::Registry or Apache::RunPerl all
  heck breaks loose.  It seems that the file locking breaks down. 
  Another thing that is totally bizarre is that stuff is being written
  to all kinds of files that I'm not writing to. Even my scripts
  themselves will sometimes have text appended to the end of them. 
  Another problem is that Apache will give me an error message saying
  that it is trying to write to memory that is locked.
 

 Could this be a threading issue? Are you using 5.6.1 or 5.8 with
 mod_perl 2? I know that mod_perl 2 is far from ready for primetime
 especially under the threaded mpm's (which is what Win32 is forced to
 use). I use XP to develop for a Linux mod_perl 1 architecture so I'm
 raipdly getting out of my depth, but this sounds like the place to
 look.


 I've never heard of a Win32 specific mod_perl list ...  :(

 -Chris


-Chris





Re: Filehandles

2002-08-29 Thread Perrin Harkins

Justin Luster wrote:
 The stress tool that I'm using is from Microsoft and is a free download.

That isn't quite what I asked.  Which version of mod_perl are you using?

 There is a setting in this tool called
 Concurrent Connections (threads).

Regardless, mod_perl 1.x does not support multiple concurrent users on 
Windows.  It will serialize those requests.

- Perrin




Re: Filehandles

2002-08-29 Thread Chris

 Justin Luster wrote:
 The stress tool that I'm using is from Microsoft and is a free
 download.
 
 That isn't quite what I asked.  Which version of mod_perl are you
 using?
 
 There is a setting in this tool called
 Concurrent Connections (threads).
 
 Regardless, mod_perl 1.x does not support multiple concurrent users on 
 Windows.  It will serialize those requests.
 
 - Perrin

I think he said mod_perl 2 in his inital post. Which I'm not sure really is 
all that swift with concurrant requests under threaded mpms (Win32 is 
limited to threaded mpms) ... least nobody seems 100% happy with the 
threaded mpm performance of mod_perl 2 yet (Stas? Anybody? How's it 
looking?)

-Chris





Re: Filehandles

2002-08-29 Thread Perrin Harkins

Chris wrote:
 I think he said mod_perl 2 in his inital post.

Oops, you're right, I totally missed that.  Sorry Justin.

- Perrin




Re: Filehandles

2002-08-29 Thread Randy Kobes

On Thu, 29 Aug 2002, Justin Luster wrote:

 The stress tool that I'm using is from Microsoft and is a free download.  It
 is called Web Application Stress.  There is a setting in this tool called
 Concurrent Connections (threads).  As I mentioned before I am able to do
 this no problem under regular CGI with 10 concurrent users but when I run
 mod_perl all heck breaks loose.

I've tried a simple registry script that uses flock() (on WinXP),
as well as one that just prints out the environment variables,
using apache-2.0.40 and a recent cvs mod_perl-2 build. Using
ApacheBench as
   ab -n ddd http://localhost/perl/script_name
(where 'ddd' is the number of requests to do), on my system, when
ddd exceeds about 1500 with perl-5.6.1, the tests hang, but
things are OK in this realm with perl-5.8. So this problem may
not have so much to do with flock(), but perhaps more to do with
threading under perl-5.6.1 on Win32.

If you're interested in comparing for your particular script, 
there's a perl-5.8/Apache/mod_perl binary, perl-5.8-win32-bin.tar.gz,
at ftp://theoryx5.uwinnipeg.ca/pub/other/ - installation
instructions are in the associated .readme file. 

-- 
best regards,
randy kobes




Re: Filehandles

2002-08-29 Thread Stas Bekman

 I think he said mod_perl 2 in his inital post. Which I'm not sure really is 
 all that swift with concurrant requests under threaded mpms (Win32 is 
 limited to threaded mpms) ... least nobody seems 100% happy with the 
 threaded mpm performance of mod_perl 2 yet (Stas? Anybody? How's it 
 looking?)

Caution: you are entering unchartered waters.

first of all: you must use 5.8.0 with threaded mpms

perl 5.8.0 internals are thread-safe, so does mod_perl 2.0-dev.

By saying that perl is thread-safe, I mean that operations like push, =, 
/, map, chimp, etc. are thread-safe. Operations that involve system 
calls, may or may not be thread-safe. This varies from OS to OS, and 
even varies for various versions of the same OS.

e.g. localtime() is not thread-safe on platforms where asctime(3) is not 
thread-safe. other problematic ones are readdir(), srand(), ...

there is another important issue. what some people are referring to as: 
thread-locality. Certain functions executed in a single thread affect 
the whole process e.g. if you chdir() in one thread, all other thread 
now see the cwd of that thread that chdir'ed. Other problematic 
functions are umask(), chroot(), %ENV...

Getting back to the Justin's question, it's quite possible that 
thread-safety problems kick in. It could be that flock is not 
thread-safe. But I think the real problem is with chdir(), because 
Apache::Registry chdir()s to the dir of the script. Stop using 
Apache::Registry and start using ModPerl::Registry, which doesn't 
chdir(). Of course you cannot do any operations with relative path 
anymore. Arthur Bergman is working on some solutions for chdir(), but 
nothing was released so far. So you will have to wait or help Arthur to 
finish his work.

So first try using ModPerl:Registry, which I expect will resolve the 
issue. If that doesn't help, please supply a *short* script that 
reproduces the problem. Which of course may not exhibit the same 
behavior on a different platform, but at least we can do some sanity check.

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com




Re: Filehandles

2002-08-29 Thread Stas Bekman

I'm using Perl 5.6
 
  
 Unless someone with better knowledge pipes up, to the best of my knoweledge 
 there are threading/concurrancy issues with mod_perl 2 and 5.6.1 ... I know 
 that Randy has said in places that eventually the officiall recomdendation 
 for Win32 Apache/mod_perl 2 will be 5.8 because it's theoretically more 
 thread safe.

It's not threoretical, it's practical. There are thread-safety problems 
with perl interpreters in 5.6. It's possible that your code doesn't hit 
them, so 5.6 may work for you, but why taking the risk, use 5.8.0. 
expect mod_perl 2.0 *requiring* 5.8.0 for threaded mpms when it gets 
released.

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com