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

Re: Confusion about SvANY and Devel::Peek output

Thread Previous
Reini Urban
March 22, 2013 18:54
Re: Confusion about SvANY and Devel::Peek output
Message ID:
On Fri, Mar 22, 2013 at 11:42 AM, Dave Mitchell <> wrote:
> On Wed, Mar 20, 2013 at 04:11:51PM +0100, demerphq wrote:
>> Ok, thanks for the explanation.
>> >> Another question this raises for me: why is SvANY _before_ the
>> >> refcount and flags? Id have expected the flags to be first, then the
>> >> refcount then the sv_any member.
>> >
>> > Why?
>> Well id expect the flags to be first because I would assume they are
>> used the most.
> Here's a perlbench of unthreaded blead. Columns A nd B are vanilla,
> columns C & D are with the SV reordered to sv_flags/sv_refcnt/sv_any.
> Possibly 1% faster. Maybe 2% faster. Probably just noise!

Most perl data is blessed or a string, which means you need to favor
sv_any over sv_flags, because of the cost of the indirect memory
access via sv_any to the xpv fields.
If you access a XPV field via sv_any at the 2nd or third field the
cost will be much higher.
The sv_flags access is always needed but cheaper since you only need
to access the word.
Reini Urban

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