>>>>> "DL" == Donald Leslie {74279} <[EMAIL PROTECTED]> writes:

  DL> I have an apache/mod-perl application that can results in large
  DL> xml strings which are then transformed by xslt into html. A
  DL> database query can result in an xml string with a length greater
  DL> than 300,000 . In a normal perl allocation you can pre-extend the
  DL> string to prevent repeated new allocations and copies. Does anyone
  DL> know what happens in a mod-perl application? Does pre-extending
  DL> have any benefit?

i can't tell you about any mod-perl issues but in general pre-extending
in perl doesn't gain you as much as you would think. the reason is that
some storage isn't really truely freed to the main pool when it gets
freed when its ref count goes to 0. perl will keep it around in
anticipation of it be reallocated for this same item in a future call or
loop iteration. so it is effectively doing the usual doubling its size
to grow into the first large string and then it is already prextended
the rest of the time via reusing the previous buffer.

of course this could be totally wrong as i am not nuts enough to get
into perl's guts but that is what i have understood to happen. this is
can be benchmarked by comparing the first time something is allocated
with doubling vs a preextend. you have to be careful to factor out the
virtual ram allocation. one idea would be to preallocate and free a
larger chunk before you run the benchmark so that virtual ram will
likely be cached in real ram.

and on a final note, these days 300k is not even a long string.

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to