develooper Front page | perl.perl5.porters | Postings from August 2014

pad_reset

Thread Next
From:
Father Chrysostomos
Date:
August 28, 2014 04:58
Subject:
pad_reset
Message ID:
20140828045810.19174.qmail@lists-nntp.develooper.com
I have managed to get pad_reset working.  See the
sprout/pad_reset branch.

For those who do not know what pad_reset does, pad_reset allows oper-
ators from different statements to share targets, saving memory.  When
it was originally added, it never fully worked properly, so it was disabled, since it caused bugs.

For those who do not know what operator targets are:  Many operators
use the same scalar every time they return a value, to avoid having to
create a new one each time.  This is known as the target.

To keep t/re/uniprops.t running in a reasonable amount of time (unfor-
tunate coincidences slowed it down signficantly), I had to add two
optimisations (applying PadnamelistMAXNAMED to the 'our' hack and add-
ing PL_constpadix).  Those optimisations apply even when pad_reset
is disabled.

I tried benchmarking this with mktables, and I see barely any dif-
ference in speed.  Disabling pad_reset on that branch seems to
make mktables consistently faster (probably due to those two opti-
misations).

t/re/uniprops.t seems to be about the same speed, regardless of con-
figuration.  The generated script that it runs, TestProp.pl, is 'writ-
ten' in such a way that it is very sensitive to changes in pad algor-
ithms.  If I add 'my $x' to the end of it, the run time increases many
times.  This is also where disabling pad_reset but keeping the two
optimisations helps the most.

In the end, pad_reset saves memory, but it doesn't make for the fast-
est runs, it seems.  So is it worth it?

In would be interesting to know *why* pad_reset is slightly slower, if
it's possible to find out.  Maybe it's because an undefined target is
faster to write to than one previously used.

My benchmarking results follow.

User times from

    time ./perl -Ilib lib/unicore/mktables -C lib/unicore -P pod -maketest -makelist -p -w

follow, with two runs in each configuration.  All configurations
are threaded.

pad_reset = sprout/pad_reset branch (pad_reset enabled)
NO_PAD_RESET = -Accflags=-DNO_PAD_RESET on the sprout/pad_reset branch
before = before this branch; i.e., at 272ce8bbdf

pad_reset    NO_PAD_RESET    before

0m23.186s    0m23.117s       0m23.289s
0m23.358s    0m23.080s       0m23.548s

And times from

    cd t; time ../perl -I../lib ../lib/unicore/TestProp.pl

(i.e., what t/re/uniprops.t runs)

pad_reset    NO_PAD_RESET    before

0m13.475s    0m13.393s       0m13.309s
0m13.516s    0m13.387s       0m13.471s

And TestProp.pl with 'my $x' added at the end:

pad_reset    NO_PAD_RESET    before

2m33.957s    2m22.350s       2m50.440s
2m33.854s    2m22.318s       2m49.417s


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About