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

MG slabs?

Thread Next
From:
Dave Mitchell
Date:
July 18, 2010 14:47
Subject:
MG slabs?
Message ID:
20100718214750.GL8078@iabyn.com
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
    87

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
array.

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
shop

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