PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: mpeppler at itf dot ch (Michael Peppler)
Subject: Re: Syperl startup performance.
Date: Feb 8 1996 10:30AM

> From: "Bass, John" 
>      1)   If I run a perl script which just has following line in it
> 
>                print "Hello World\n";
> 
>           The script will take just under 1second to execute.
> 
>      2)   But if I add the following line before the print line
> 
>                use Sybperl::CTlib;
> 
>           The script  takes about 4-5 seconds to run. I am aware CTlib has
>           a large overhead when starting up, but this still seems too long.
> 
>      3)   If I replace the CTlib line with the following
> 
>                use Sybperl::DBlib;
> 
>           The script takes between 2-3 seconds to run.
> 
>      Why is there such an overhead in starting Sybperl, be it CT or DB lib?
> 
>      Is there a way of speeding up the startup times?

I ran the test below here (SS20/50MHz), perl 5.002b2, sybperl 2.04
(nope, that version is not available to you yet :-)


kiruna (11:04am):527 > time perl -I./blib/sun4-sunos -I./blib -e 'print "Hello World\n";'
Hello World
0.020s u 0.070s s 0.177s t 504kb (592) 0pf 0s 3i 6o

Yes, that's fast :-)

kiruna (11:13am):528 > time perl -I./blib/sun4-sunos -I./blib -e 'use Sybase::CTlib;print "Hello World\n";'
Hello World
0.960s u 0.340s s 4.955s t 2644kb (2740) 111pf 0s 31i 6o

Ugggh - 5 seconds!

So I re-ran it several times:

kiruna (11:13am):529 > time perl -I./blib/sun4-sunos -I./blib -e 'use Sybase::CTlib;print "Hello World\n";'
Hello World
0.810s u 0.360s s 1.315s t 2532kb (2648) 1pf 0s 0i 4o
kiruna (11:13am):529 > time perl -I./blib/sun4-sunos -I./blib -e 'use Sybase::CTlib;print "Hello World\n";'
Hello World
0.800s u 0.330s s 1.488s t 2520kb (2648) 0pf 0s 0i 4o
kiruna (11:13am):529 > time perl -I./blib/sun4-sunos -I./blib -e 'use Sybase::CTlib;print "Hello World\n";'
Hello World
0.850s u 0.300s s 1.405s t 2584kb (2648) 0pf 0s 0i 4o
kiruna (11:13am):529 > 

Right, now we're down to approximately 1.5 seconds. So caching can help
a lot.

Basically, there are two things that take time: one, when starting a
script with a dynamically loadable module that module has to be read in
to memory, and all the address fixups have to be done. In the case of
CTlib, there are 5 or six (!) shared libraries that have to be opened
and loaded if they aren't already cached by the OS. All of this takes
time.

The second issue is the number of symbols that are exported by the
module. CTlib exports a fairly large number of objects. This issue can
be improved by not importing any symbols into the current name space:

#!/usr/local/bin/perl

use Sybase::CTlib ();

The disadvantage is that all the CS_* symbols (CS_SUCCEED, etc) now
have to be qualified with the package name:
Sybase::CTlib::CS_SUCCEED).

Just to be complete, I include a message I sent out some time ago where
I tested the effect of different linking strategies (static/dynamic) on
the startup time of CTlib and DBlib. I did not measure elapsed time,
but only system+user.


Hope this helps a bit...

Michael


----- Begin Included Message -----

>From owner-sybperl-l@trln.lib.unc.edu  Wed Dec 27 15:38:09 1995
>From: mpeppler@itf.ch (Michael Peppler)
Subject: Re: Efficiency of Sybperl 2.0 packages

> We're looking at the effects of using Sybperl in our web scripts, and would be
> grateful if anyone has an idea of the CPU and security issues that are
> associated with using Sybase::DBlib, Sybase::Sybperl, or Sybase::CTlib
> packages.

I just did some testing of different versions of Sybperl to measure the
overhea of starting the process. The idea was to measure the cost of
loading both the perl binary, but also of loading any shared libraries
that are required.

The script I tested did this
=========
#!/usr/local/bin/perl

use Sybase::CTlib;   # Or Sybase::DBlib

require 'ctutil.pl';

$dbh = new Sybase::CTlib mpeppler;
=========

I tested this on a Sun SS20/50, running SunOS 4.1.4

1) Linktype = dynamic

   CTlib:	1.00 user + 0.33 sys.
   DBlib:	0.33 user + 0.20 sys.

2) Static

   CTlib:	0.94 user + 0.41 sys.
   DBlib:	0.45 user + 0.20 sys.

It is obvious from this that the multiple shared libraries that the
CTlib extension must load has a cost. So I tried building a copy of
perl with all the Sybase stuff statically linked in:

3) FULL static (both libraries are linked in to one perl binary)

   CTlib:	0.78 + 0.33
   DBlib:	0.29 + 0.15
   
And just to be complete, I built a dynamic load version using the
static libraries:

4) dynamic static :-)

   CTlib:	1.05 + 0.42
   DBlib:	0.50 + 0.25

Interesting results...

Basically, my interpretation is that the startup of the CTlib module is
inherently slower than the DBlib module in the current implementation
(10.0.2). This appears to be due both to the loading of multiple shared
objects, but also apparently to a more complex initialisation
sequence.

I'm going to look at this some more to see if there is something that
can be done from the perl point of vue, but at this point it would seem
that the Sybase::DBlib module is the better one to choose for Web-type
development.

Michael


----- End Included Message -----