develooper Front page | perl.perl5.porters | Postings from May 2017

Re: DAVEM TPF Grant#2 April 2017 report

Thread Previous | Thread Next
Dave Mitchell
May 15, 2017 07:49
Re: DAVEM TPF Grant#2 April 2017 report
Message ID:
On Sat, May 13, 2017 at 07:26:37PM +0100, Marcus Holland-Moritz wrote:
> On 2017-05-09, at 09:13:35 +0100, Dave Mitchell wrote:
> > The main things I did last month were:
> > 
> > * Fixd require's "Can't locate" error message so that it only mentions
> >   @INC if @INC was actually searched, and only gives the "you may need to
> >   install" hint if the filename maps to a valid module name.
> > 
> > * fixed up the usage of 'do' in core and made tests run without '.' in
> >   @INC.  It turns out that all core tests were being run with '.' in @INC
> >   even when that was no longer set by default by the perl interpreter. I
> >   removed that, and then fixed up the issues it revealed.
> > 
> > * I made a start on a proof-of-concept branch which stores short strings
> >   directly in the body of an SV.
> Cool, how long of a string can we store inline? It seems we could
> use all of xpvlenu_len, xpv_cur and xmg_u, which should give about
> 24 bytes. Not sure if you're aware of this,

If you want to discuss this further, I suggest you head over to the thread
starting at and
contribute there, to avoid discussion being split among multiple threads;
but in short:

It's 16 bytes (including trailing \0) on a 64-bit platform.
A basic xpv struct may *appear* to have all of (xmg_stash, xmg_u, xpv_cur,
xpv_len_u), but in fact it only has (xpv_cur, xpv_len_u) - the first two
fields are not allocated due to structure offset tricks.

My proposal adds an extra pointer-sized field to xpv and all its
derivatives, so the basic xpv is now (xpv_cur, xpv_len_u, extra),
and uses (xpv_len_u, extra) as a 16-byte buffer with length still stored
in xpv_cur. This means that the SvPVX() and SvCUR() macros don't need to
become complex conditionals (SvSHORTPV(sv) ? .... : sv->av_any-> xpv_cur),
only the less-frequently used SvLEN().

Because the xmg_stash, xmg_u flags aren't hijacked, a short string can be
blessed and have magic attached, e.g. //g pos magic.

For non-short strings, the intention is to use the 'extra' field to make
COW more efficient and have wider applicability.

Counsellor Troi states something other than the blindingly obvious.
    -- Things That Never Happen in "Star Trek" #16

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