At 09:23 PM 9/19/2001 -0400, Gregor N. Purdy wrote:

> > >Dan? Does this fly in the face of your overall design, or is this
> > >a good thing?
> >
> > Cool, but not a good thing. The problem with it is there's a lot of
> > extraneous stuff scattered in the function table structure. That's 
> going to
> > reduce the L1 cache hit rate, and I'd rather not do that.
> >
> > Separate arrays would be fine, but just not unified like that.
>
>("This may be free software, but them ain't free cycles!" :-)

Damn straight. :) Making more work for us is fine if it makes the ultimate 
interpreter faster.

>Suppose I put back the function-pointers-only array and remove the
>function pointers from the new one (partway back to the way it was).
>Do you see other problems with this?

I want the table we look function pointers up in to be *just* function 
pointers and nothing but. (I'm also considering analyzing the code the 
compiler spits out and ordering the opcodes such that ones commonly 
executed together are next to one another in the table)

The big reason here is cache coherency, and here's a (simplified) 
explanation of why it's important.

When the CPU fetches data from memory into its cache, it usually fetches a 
good-sized chunk, (called a cache line) anywhere from 8 to 64 bytes at once 
depending on the CPU architecture. Getting that data in is reasonably slow, 
especially if it has to come in from main memory. (We're talking 10 to 100 
cycles) Once it's in the cache, though, accessing it takes a cycle or two.

Generally speaking a single function table entry will take less than a 
whole cache line. That means we get the rest of the data in that cache line 
loaded free, and we don't have to pay to fault it in later. If we have 
other stuff in the table, though, we're loading in useless data. (Useless 
in the sense that we're not going to use it)

Basically we're getting a free load on most architectures, so we ought to 
use it where we can. (And it doesn't hurt us on those architectures where 
we don't have it)

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to