develooper Front page | perl.perl5.porters | Postings from July 2010

MG slabs?

Thread Next
Dave Mitchell
July 18, 2010 14:47
MG slabs?
Message ID:
Here's a bit of idle speculation:

It's well known that linked lists are very bad for modern cachey CPUs:
following through a linked list may involve a CPU stall with each
foo = foo->next step.

Now then, magic is currently attached to SVs using linked lists, and magic
is attached to lots of SVs for lots of trivial reasons: taint, pos, etc.
So a lot of processing of SVs involves lots of running through the MG
linked list, eg

    $ grep mg_find *.c | wc -l

Which may be slow (although I haven't instrumented this with cachegrind or
anything yet).

So... maybe SvMAGIC should point to a singe array (in the C sense, not the
AV sense) of MG structures. If we need to add more magic, we realloc the

Even more radically, given that mg_type is only 8 bits, we could split the
MG array into two halves - an array of types, and an array of everything
else. Then an mg_find() or similar would be sooper fast.

I have no immediate plans to look into this further.

Now is the discount of our winter tent -- sign seen outside camping

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