develooper Front page | perl.perl5.porters | Postings from April 2003

Re: COW in CORE and SvFAKE in older Perl

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
April 29, 2003 13:15
Subject:
Re: COW in CORE and SvFAKE in older Perl
Message ID:
20030429201226.GA273@Bagpuss.unfortu.net
On Tue, Apr 29, 2003 at 11:07:29AM -0400, Aaron Sherman wrote:
> I came across this message:
> 
> http://archive.develooper.com/perl5-porters@perl.org/msg85292.html

I think that this message is more informative: :-)

http://archive.develooper.com/perl5-porters@perl.org/msg85362.html

given that most of the patch first surfaced in the days of 5.7.3 but wasn't
finished enough to apply. There's more been done since then - $& is now
copy on write.

> Much to my chagrin, I have not been following p5p (even though I'm on
> the list), and wanted to ask about the copy-on-write changes.

You can compile 5.9.0 with -DPERL_COPY_ON_WRITE and apart from a minor bug
if you try to copy $^OPEN while under a utf8 locale with -C which I've not
yet tracked down it all seems to work.

The good news: I can't measure any slowdown
The bad news: I can't measure any speedup

> I'm in the middle of writing a module that I thought would address some
> SpamAssassin performance problems (or at least provide me with the
> platform to address them) by creating SvFAKE values based on a substring
> of original string (a "shard" as I've been referring to it) without
> allocating new memory and/or copying.

Have you profiled spamassassin to death yet and addressed everything else
that can be addressed by conventional means?

> However, support for SvFAKE in 5.6.1 seems to be very limited (in fact,
> it's really only working if you are SvFAKEing an SVt_PVGV, and even then
> I'm not sure how general-purpose it is). This is unfortunate because it
> seems to mean that I have to resort to MAGIC in order to prevent Perl
> from trying to free my data (I've already marked it as SvREADONLY).

Can you take advantage of the same magic as lvalue substr already uses?
Or does magic give you sufficient speed hit that you are not going to gain
anything?

I don't know the answers to the questions I snipped.

> Is there any way (say, back to 5.6.0) that this sort of thing is
> generally done without invoking magic, and I've just missed it, or am I
> going to have to bite that bullet?

I'd suggest testing with a current blead compiled with and without
-DPERL_COPY_ON_WRITE but otherwise identical everything. You can jig the
architecture in config.sh so that you can install both in parallel, and it's
worth also tweaking perlpath to be the name you give perl, given that some
things trust $Config{perlpath} in preference to $^X

If you're testing on x86 with gcc I'd suggest adding something like

-falign-loops=16 -falign-jumps=16 -falign-functions=16 -mpreferred-stack-boundary=3

to prevent the gcc defaults from causing random fluctuations when functions
change size slightly. There's also

http://groups.google.com/groups?as_umsgid=20030218221734.GF278%40Bagpuss.unfortu.net

which no-one seems to refer to enough :-)

Nicholas Clark

Thread Previous | 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