develooper Front page | perl.perl5.porters | Postings from February 2013

Re: PL_sv_objcount

Thread Previous | Thread Next
Nicholas Clark
February 28, 2013 10:37
Re: PL_sv_objcount
Message ID:
On Thu, Feb 28, 2013 at 02:21:23AM -0500, bulk88 wrote:
> Steffen Mueller wrote:
> > On 02/27/2013 08:11 PM, Nicholas Clark wrote:
> >> So yes, good catch. It's going to be non-zero for any meaningful program.
> > 
> > Alas, removing it (see branch smueller smueller/killsvobjcount2), makes 
> > the following test in t/op/stash.t fail. My hunch is that it's 
> > uncovering another bug?
> I did some tests, and one liners, print()s and system()s do not use the 
> "    if (PL_sv_objcount) {" code path. I would leave it it alone for 
> performance reasons.

That's the wrong trade off.

For one liners, runtime speed is not going to be as important as start up
time. For longer running programs, runtime is what matters.

Removing PL_sv_objcount eliminates a small cost for every object creation
and destruction. This will scale (roughly) linearly with program runtime.
So longer programs are really going to feel the benefit. Whereas for
*trivial* one liners (the only things that will never create objects), the
extra cost of always calling sv_clean_objs() is

a) going to be swamped by the startup and parsing time anyway
b) isn't going to be large because there simply aren't going to be that many
   scalars allocated at all.

So retaining it is optimising the wrong thing.

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About