Virtual Function Table Look-Up


gosse

Still Fresh
Joined
Feb 12, 2010
Messages
37
Age
41
Location
Montreal, QC
Today, I was looking at the various bottlenecks on the PS3 SPU and we found out that virtual function look-ups ended up taking a lot of processing time we could easily shave off.
So here I am, wondering if it affects the Pandora's CPU as well cause it will affect grandly how I will write my game engine on the Pandora.
Has anyone done benchmarks/tests for that? I have no similar device on hand to test it out myself at the moment.

Thanks!
 
As far as I know, vtable lookups shouldn't be much of a problem. I'd be much more worried about dynamic casts which can take up 200 cycles or something like that.

Someone correct me if I'm wrong ;)
 
Well, dynamic cast is a _runtime_ evaluation so best to be avoided from a type loop, but you knew that :) A tight loop should have all the 'variables' taken out; pre-evaluate stuff like that, go to lookup tables, etc, depending how tight your constraints are :)

(And remember one of Knuth's rules .. premature optimization is just obfuscation!)

jeff
 
It depends how predictable they are. If your lookup goes to the same method every time and the branch stays in the BTB then it'll be fast. If it changes you'll get mispredicts which are 13 cycles.
 
Back
Top