Re: perl eating up memory slowly until program stops - any ideas ?
From: Purl Gurl (purlgurl_at_purlgurl.net)
Date: 07/07/04
- Next message: Bob: "Regular expression to match surrounding parenthesis"
- Previous message: Joe Smith: "Re: problem with a script in perl."
- In reply to: Tassilo v. Parseval: "Re: perl eating up memory slowly until program stops - any ideas ?"
- Next in thread: Tassilo v. Parseval: "Re: perl eating up memory slowly until program stops - any ideas ?"
- Reply: Tassilo v. Parseval: "Re: perl eating up memory slowly until program stops - any ideas ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 07 Jul 2004 11:09:26 -0700
Tassilo v. Parseval wrote:
> Purl Gurl wrote:
> > Tassilo v. Parseval wrote:
> >> Purl Gurl wrote:
> >> > Purl Gurl wrote:
> >> >> Jasper wrote:
(snipped)
> >> [ benchmark snipped ]
> > Actually, my benchmark does a bit more to closer reflect
> > a simple script. Arrays are created, variables are set,
> > arrays are set to null.
> You don't show how long it takes to access single elements, for
> instance.
That is unrelated. The point of my test is to exemplify
identical code takes longer to run when lexical scoping
is employed.
> I don't understand anything of the above. What is a '"single" malloc'
> which is 'flagged for reuse'? Furthermore, what are those 'private
> blocks'?
My hunch is you already know and are testing my knowledge.
For lexical scoping, a single chunk of memory, reserved by
perl core, can be reused many times. That is a single "malloc"
serving memory needs multiple times.
Simple example, you can push an array into that "malloc" then
later destroy it via lexical scoping, followed by another array
being pushed into that same "malloc" memory chunk.
Another here used a very good expression of calling those
memory chunks an "arena" which is more understandable;
blocks of reserved memory for use.
Private blocks, you have discussed this a number of times
and well understand lexical scoping / private blocks.
> > Inherently, there are lots of exceptions, oddities and other
> > externalities effecting efficiency. For my benchmark, difference
> > in efficiency is so small it is basically insignificant.
> > For large programs, efficiency difference is significant.
> Yes, but not in the sense that you would expect:
> Rate pkg lex
> pkg 89.6/s -- -41%
> lex 151/s 68% --
>
> Is that what you meant with 'significant'? ;-)
"Inherently, there are lots of exceptions, oddities and other...."
> 'reuse of memory may prove to be more efficient than not using lexical
> scoping'? Another one I don't understand.
In general, use of global variables lends to a faster
running script. Lexical scoping, slower. Use of "my"
declarations within private blocks increases activity
by perl core, hence, slower script completion.
As pointed out previously, it is very possible better
use of memory may actually lend to better efficiency.
I am thinking in terms of high RAM usage creating a
greater degree of paging / swap file usage, which
is slower because of hard drive access.
As I write this, a squirrel is digging holes in my
strawberry patch. Grrr... They never eat my strawberries,
just dig holes all over.
Purl Gurl
- Next message: Bob: "Regular expression to match surrounding parenthesis"
- Previous message: Joe Smith: "Re: problem with a script in perl."
- In reply to: Tassilo v. Parseval: "Re: perl eating up memory slowly until program stops - any ideas ?"
- Next in thread: Tassilo v. Parseval: "Re: perl eating up memory slowly until program stops - any ideas ?"
- Reply: Tassilo v. Parseval: "Re: perl eating up memory slowly until program stops - any ideas ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|