develooper Front page | perl.perl5.porters | Postings from January 2011

make GvCV rvalue only?

Thread Next
Dave Mitchell
January 3, 2011 06:27
make GvCV rvalue only?
Message ID:
After my fixes a few months ago to sort out all the weak-ref / dangling
pointer issues between stashes, GVs and CVs; we're left with the
situation where in the normal case for a named sub of a GV (via its GP)
holding a pointer to a CV, and that CV pointing back to the same GV (i.e.
CvGV), backref magic has to be attached to that GV.

Although the backref magic is optimised to skip using an array when
there's only one backref, that's still a MG* structure per GV-with_CV.

For comparison, a simple perl -MCPAN creates about 2500 GVs, of which half
point to CVs which point back to the GV (the main case where backref
magic is used).  I see a similar 50% ratio for POSIX.

Use'ing CPAN consumes an extra 30,000Kb on my 64-bit system.

I can see three possibilities.

1. Do nothing.  -MCPAN would add an extra approx 50 Kbyte compared with an
older perl (ie 0.1% increase).

2. Add an extra field to the xpvgv struct to be used instead of backref
magic; assuming the 50% CV to GV ratio, this would save 30K (so now only
20K over original)

3. Make GvCV an rvalue-only macro and introduce a new GvCV_set macro
(as has already been done with CvGV and CvSTASH). This saves the full 50K,
but will break CPAN modules which set it directly.

SCO - a train crash in slow motion

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