Improving Perl performance

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Improving Perl performance

Postby jgbrown » 19. April 2006 03:06

Greetings…

I am a new XAMPP user. I've set up XAMPP on an Ubuntu 5.10 "Breezy Badger" server. While overall I am pleased with the end product, I need a little help with a Perl performance issue.

I am attempting to run an Oddmuse wiki on this server. Oddmuse is written in Perl, and I find that it is running quite slowly on my XAMPP instance. Saving a very small page takes more than 20 seconds. There is virtually no other active site being served when this takes place.

Two simple questions to start:

1) What are the basic things I can do to optimize Perl performance on this server?

2) What resources would the brain trust here recommend I use to bring myself up to speed on XAMPP and Apache configuration and management?

Many thanks…

JGB
User avatar
jgbrown
 
Posts: 13
Joined: 19. April 2006 02:38

Postby Oswald » 19. April 2006 13:27

Dear JGB!

There is definitely something going wrong on your system. I just installed Oddmuse wiki on my own machine and it runs fast as expected: Took about 0.1 seconds do serve a page.

Did you use the Perl of your system or the Perl of XAMPP? If the first line of wiki.pl contains #!/usr/bin/perl you're using your system's Perl. If the first line reads like #!/opt/lampp/bin/perl you're using XAMPP's Perl.

Greetings
Oswald
User avatar
Oswald
Apache Friends
 
Posts: 2718
Joined: 26. December 2002 19:51
Location: Berlin, Germany
Operating System: Linux

Postby jgbrown » 20. April 2006 01:33

Hello, Oswald...

Thanks for taking an interest in my little question. There's something utterly cool about finding that the developer of a tool one is using has taken the time to look at a problem. It says good things about the future of XAMPP.

To answer: I've tried both. The oddmuse script ships with #!/usr/bin/perl as the first line, and runs as shipped. I've edited the first line to read #!/opt/lampp/bin/perl. The script still runs, but there is no appreciable difference in performance either way.

I am using the wrapper script suggested in the oddmuse documentation:
Code: Select all
#! /opt/lampp/bin/perl
package OddMuse;
$DataDir = '/home/wikidata';
do 'oddmuse.pl';


My server is an older HP Brio BA400, 40 GB hard drive, 533MHz Celeron CPU, 128MB RAM. Maybe a little underpowered? I don't know. I use a separate system for my desktop, and access the server via ssh and Webmin. I can add an entry to the guestbook-en.pl example script that ships with XAMPP, and the operation completes in under a second.

The OS is, as I said, Ubuntu 5.10 "Breezy Badger". I installed this in server configuration, so X windows is not installed at all. If there are any stats I should provide, I will be happy to oblige.

I will continue to research and experiment. I built this server for learning purposes, after all. Any guidance you can provide will be wildly appreciated.

JGB
User avatar
jgbrown
 
Posts: 13
Joined: 19. April 2006 02:38

Postby Oswald » 20. April 2006 08:29

Dear JGB!

Okay, 533MHz Celeron with 128MB RAM seems indeed a litte less. But anyway 20 seconds seems to be a little bit too long.

Please try using mod_perl. It will extremely speed up Perl, and in your case it may be the solution. To activate mod_perl please edit /opt/lampp/etc/extra/httpd-xampp.conf and add the following lines to the end of this file:

Code: Select all
PerlModule ModPerl::PerlRun
<Files ~ "\.pl$">
      SetHandler perl-script
      PerlResponseHandler ModPerl::PerlRun
      PerlOptions +ParseHeaders
      Options +ExecCGI
</Files>


Now restart XAMPP and try accessing your Wiki again.

Good luck
Oswald
User avatar
Oswald
Apache Friends
 
Posts: 2718
Joined: 26. December 2002 19:51
Location: Berlin, Germany
Operating System: Linux

Postby jgbrown » 20. April 2006 12:08

No joy with mod_perl, I'm afraid. I copied the lines you provided to the end of httpd-xampp.conf. The wiki now displays a blank page -- there isn't even any HTML source being sent to the browser. And the example guest book fails with the following:

Code: Select all
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.


The error.log does not seem to contain any errors relating to odd.pl. I do see these errors for the guestbook:

Code: Select all
[Thu Apr 20 07:03:16 2006] [notice] Apache/2.2.0 (Unix) mod_ssl/2.2.0 OpenSSL/0.9.8a DAV/2 PHP/5.1.1 mod_apreq2-20050712/2.1.3-dev mod_perl/2.0.2 Perl/v5.8.7 configured -- resuming normal operations
[Thu Apr 20 07:03:20 2006] [error] Cannot open guestbook file at /opt/lampp/htdocs/xampp/guestbook-en.pl line 54.\n


Both odd.pl and the guestbook resume normal functioning when I replace httpd-xampp.conf with the original version. What have I done wrong?

Thanks...

JGB
User avatar
jgbrown
 
Posts: 13
Joined: 19. April 2006 02:38

Postby Oswald » 20. April 2006 13:00

Dear JGB!

guestbook example and mod_perl

Not all Perl programs will run with mod_perl. That's the reason why I turned it off by default. For example: Using relative pathes in your Perl program will not work any more. That's why the guestbook example doesn't work. In line 54 it opens the data file:

Code: Select all
open (FILE, "<guestbook.dat") ...


If you change the line like this:

Code: Select all
open (FILE, "</opt/lampp/htdocs/xampp/guestbook.dat") ...


the guestbook will work again.

Oddmuse and mod_perl

But to get back to the Oddmuse problem: I don't know why it's not working. I encounter the same problem like you, so it's not your error. There is a documentation how to get Oddmuse working with mod_perl, but it's far away from being easy: http://www.oddmuse.org/cgi-bin/oddmuse/Using_mod_perl

Original problem

And now back to your original performance problem:

If you call Oddmuse by command line:

/opt/lampp/bin/perl wiki.pl

(where wiki.pl is the filename of your oddmuse file). How fast is this?

And how fast is it if you use your system's Perl:

/usr/bin/perl wiki.pl

Greetings
Oswald
User avatar
Oswald
Apache Friends
 
Posts: 2718
Joined: 26. December 2002 19:51
Location: Berlin, Germany
Operating System: Linux

Postby jgbrown » 21. April 2006 13:15

Oswald...

Another learning experience! Now I know how to use the time command.

The following values are averages of five runs of each command:

time /opt/lampp/bin/perl oddmuse.pl

real 0m0.669s
user 0m0.626s
sys 0m0.040s

time /usr/bin/perl oddmuse.pl

real 0m0.727s
user 0m0.683s
sys 0m0.040s

XAMMP Perl is faster than native Perl. Note that this is the oddmuse.pl script alone, and does not include the wrapper script. I did do a few timed runs of the wrapper script under both Perls; the difference is less, but XAMPP Perl is still slightly faster.

I see at least three methods of using Oddmuse with mod_perl on the page you referenced. Which one would you recommend for XAMPP on an Ubuntu (Debian-based) server?

Thanks...

JGB
User avatar
jgbrown
 
Posts: 13
Joined: 19. April 2006 02:38

Postby dob80z » 10. May 2006 13:51

Oswald wrote:Dear JGB!

Please try using mod_perl. It will extremely speed up Perl, and in your case it may be the solution. To activate mod_perl please edit /opt/lampp/etc/extra/httpd-xampp.conf and add the following lines to the end of this file:


Hi Oswald,

I too would like to try this solution, as I am running a perl-based calendar which seems to be running a bit slow for my (limited number) users.

However, I cannot locate any file httpd-xampp.conf, not even a subdirectory of extra.

I am using 1.5.0 (due to 1.5.1 not working with a recipe script I have for some reason) -- is this the reason for me not having this file to edit ? If so, is there any other way I can either verify whether mod_perl is active, or enable it in any way ?

(for what it's worth, I have checked one of the scripts, and it does seem to be calling the system perl)
dob80z
 
Posts: 2
Joined: 10. May 2006 13:35

Postby Oswald » 10. May 2006 14:45

Dear dob80z!

XAMPP 1.5.0 uses Apache 2.0 and not Apache 2.2. The extra directory was included with Apache 2.2 and that's the reason why you don't find the directory.

Please use httpd.conf instead.

mod_perl is "loaded" in XAMPP by default, but it is not used. One way to use mod_perl is to add the lines I mentioned above.

Greetings
Oswald
User avatar
Oswald
Apache Friends
 
Posts: 2718
Joined: 26. December 2002 19:51
Location: Berlin, Germany
Operating System: Linux

Postby dob80z » 10. May 2006 16:42

Oswald wrote:Dear dob80z!

XAMPP 1.5.0 uses Apache 2.0 and not Apache 2.2. The extra directory was included with Apache 2.2 and that's the reason why you don't find the directory.


Greetings
Oswald


Thankyou for your reply Oswald,

I did discover there is a version 1.5.2 out, so I installed it on a test server, and yes - those options became available.

Still, the app does run slowly.

But, I am in the process of testing all my other 'pages' to make sure they work (and currently they do) in order to perhaps bring my production webserver up to the new version.

Thankyou for your reply !! :D
dob80z
 
Posts: 2
Joined: 10. May 2006 13:35

Postby jgbrown » 10. May 2006 23:11

Since this thread has come back to life, Oswald, can you tell me if my benchmarks of XAMPP Perl versus Ubuntu native Perl told you anything?
User avatar
jgbrown
 
Posts: 13
Joined: 19. April 2006 02:38


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 10 guests