Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   Memory: measuring 5 limitations (http://www.velocityreviews.com/forums/t884111-memory-measuring-5-limitations.html)

Bart Van der Donck 12-10-2003 09:24 AM

Memory: measuring 5 limitations
 
Hello,

My hosting provider uses these limitations for perl programs:

Size of Core Files - 0 MB
CPU Time Used - 30 seconds
Memory Size - 16 MB
Number of Open Files - 32
Number of Simultaneous Processes - 8

Now I am gonna make a more advanced perl script and I want to make
sure that it will be OK with these requirements. I am looking for a
way to easily display these things for my script. The script will get
data out of a db table (prices) and then calculate them according to
valuta, rate, markup dealers, etc. and then it starts comparing each
one to get the cheapest. I believe it will use heavy memory, because
it is about a lot of prices.

I did some research at Perldoc and Google.

/usr/bin/top: no permission (can't change that)

Use of perl's $ENV{PERL_DEBUG_MSTATS}: unknown $ENV variable (can't
change that either)

`` use Devel::Peek; mstat(); 创
Devel::Peek = ok
but mstat() apparantly requires that perl was built in a non-standard
way. I can't change this either.

Then I try to call perl with the -dl flag: this seems to work.
And then I write
`` do 'lib/auto/POSIX/autosplit.ix'; 创
But then I come in some kind of other shell I think... Toink :-)
I played around with it, but all seems very complex. Moreover I get
the impression that it is only about the memory size (=the 16 MB that
is maximum) and not about the other limits.

Quotation from
http://www.perldoc.com/perl5.8.0/pod/perldebguts.html:
"
There are two Perl-specific ways to analyze memory usage:
$ENV{PERL_DEBUG_MSTATS} and -DL command-line switch. The first is
available only if Perl is compiled with Perl's malloc(); the second
only if Perl was built with -DDEBUGGING. See the instructions for how
to do this in the INSTALL podpage at the top level of the Perl source
tree.
"

So, 1 basic question: is there a command like:
`` memory myscript.pl 创
that would display the memory of my script?

I don't want to code an entire program and then find out that I can't
use it because of memory restrictions.

Thanks,
Bart

Gregory Toomey 12-10-2003 09:31 AM

Re: Memory: measuring 5 limitations
 
It was a dark and stormy night, and Bart Van der Donck managed to scribble:

> Hello,
>
> My hosting provider uses these limitations for perl programs:
>
> Size of Core Files - 0 MB
> CPU Time Used - 30 seconds
> Memory Size - 16 MB
> Number of Open Files - 32
> Number of Simultaneous Processes - 8
>


Do like I did - change ISPs - and look at www.linode.com or other UML linux provider

gtoomey

James Willmore 12-10-2003 08:28 PM

Re: Memory: measuring 5 limitations
 
On 10 Dec 2003 01:24:14 -0800
bart@nijlen.com (Bart Van der Donck) wrote:
> So, 1 basic question: is there a command like:
> `` memory myscript.pl 创
> that would display the memory of my script?
>
> I don't want to code an entire program and then find out that I
> can't use it because of memory restrictions.


*If* you have shell access, you *may* be able to use
'time "name of script here"'.
This will give you information about the execution of the script. Not
Perl, but it will give you more information than what you're getting
now.

If you wanted to do it in Perl, best start with a simple
'perl -V'
at the command line to see what your host has. Some of the neat
debugging stuff you may not be able to do with you host's build of
Perl. In fact, if theu use a canned distro of Linux, *most* distros
don't build Perl with debugging enabled. Why? I don't know.

As a last resort, look for another host :-)

Just my $0.02

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Gnagloot, n.: A person who leaves all his ski passes on his
<jacket just to impress people. -- Rich Hall, "Sniglets"

Bart Van der Donck 12-11-2003 10:44 AM

Re: Memory: measuring 5 limitations
 
James Willmore wrote:

> *If* you have shell access, you *may* be able to use
> 'time "name of script here"'.
> This will give you information about the execution of the script. Not
> Perl, but it will give you more information than what you're getting
> now.


Yeah I have shell access and I can execute the time command.

The output of 'time "script.cgi"' is:
script.cgi: command not found

So I played a little around, my best shot was something like this:
'time "perl -e script.cgi"'
But whatever I do, it always says that it can't find the command
between the quotation marks.

However the output format looks great and I believe that it is what I
need:
0.000u 0.000s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
Am I missing something?

Regards
Bart

Malte Ubl 12-11-2003 01:10 PM

Re: Memory: measuring 5 limitations
 
> 'time "perl -e script.cgi"'

time perl script.cgi

???


James Willmore 12-11-2003 04:50 PM

Re: Memory: measuring 5 limitations
 
On 11 Dec 2003 02:44:38 -0800
bart@nijlen.com (Bart Van der Donck) wrote:
> James Willmore wrote:
>
> > *If* you have shell access, you *may* be able to use
> > 'time "name of script here"'.
> > This will give you information about the execution of the script.
> > Not Perl, but it will give you more information than what you're
> > getting now.

>
> Yeah I have shell access and I can execute the time command.
>
> The output of 'time "script.cgi"' is:
> script.cgi: command not found


[Sigh}

I hate trying to type in what a command should look like - because it
always seems to be mis-interpreted.

You don't need the double quotes around the command you're trying to
execute. For example:

jim@maxine:~> time ls
[lots of output from the ls command]

real 0m0.564s
user 0m0.010s
sys 0m0.000s
jim@maxine:~>

If you can execute your script *without* typing in perl at the
beginning, then you have a script that can be executed. If not, then
you have your permissions set wrong - which looks like the case here.

> However the output format looks great and I believe that it is what
> I need:
> 0.000u 0.000s 0:00.00 0.0% 0+0k 0+0io 0pf+0w
> Am I missing something?


I haven't seen output like that from 'time' before. At least, not on
a Linux system. What OS is your host using?

The "workaround" I gave was for a *INX system - I should have been
specific about that. Sorry :-(

I'm thinking you may want to contact your host to see what solutions
they may have. We're starting to get away from Perl on this issue.

Last resort - shop around for a host that has the functionality you're
looking for - and read up a little more on using Perl through CGI.
Google is an excellent place to start - because there have been *many*
questions asked about using Perl through CGI asked and answered in
this and other newsgroups.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
You should emulate your heros, but don't carry it too far.
Especially if they are dead.

Bart Van der Donck 12-12-2003 04:32 PM

Re: Memory: measuring 5 limitations
 
Oops! What a blunder about the quotes. I thought it were only the
single quotes. Yes it seems to work now with this command:

me@myserver% time perl myscript.pl
0.113u 0.034s 0:00.17 82.3% 918+2014k 0+0io 0pf+0w
me@myserver%

I will study the docs to find out what this output exactly means.

Thanks again,
Bart

PS: I also tried:
``time "\/path\/to\/perl" -e -"[options]" '/path/to/"myscript\.pl"'创
but that didn't work.
(joke :-))


All times are GMT. The time now is 08:19 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.