MAME's dynarec, UML, and you (4)

1 Name: trap15 !!qCLy6s9S : 2010-05-21 01:44 [Del]

So, one of the questions I had going into starting UberMAME was: why are Psikyo SH2 games so damn slow on 135, but perfectly fine on 124?
Today, in my usual boredom, I decided to finally take a look. I fired up Instruments.app and starting doing a CPU profiling while I (slowly) played Gunbird 2. After running it for a bit, I exited MAME and looked at the logs. I was appalled. A single sub was taking 88% of the total execution time. Yes, that's right, 88 fucking percent.
I dove into this unknown sub, drcbec_execute and examined it. What I saw made me laugh my ass off. drcbec_execute is the main sub for MAME's UML, Universal Machine Language. UML was meant to simplify dynarec, so it wouldn't be platform specific. You would expect that their UML core would, you know, actually be dynarec. It's not. It's slow, takes huge amounts of UML code to do anything useful, and most of all, is slow.
This is why Psikyo SH2 is so slow. And it doesn't just apply to Psikyo SH2, it's every single dynarec core.
So... questions about it? Comments?
We do plan on doing something to fix this mess. Maybe not now, but in the future, this will change.

2 Name: austere!!yh2Gb4CD : 2010-05-21 02:07 [Del]

Don't forget to check out line 446, 476 onwards of that same file ... :p

3 Name: trap15 !!qCLy6s9S : 2010-05-21 21:04 [Del]

Alright, I have (hackily) fixed the SH-2 core by making it use the interpreter again. Haze says there's an actual dynarec version of UML in there, it just isn't enabled for us for some reason. I've pushed the interpreter version of the SH-2 for now, I'll fix the UML stuff soon.

4 Name: trap15 !!qCLy6s9S : 2010-05-23 06:13 [Del]

Alright, party time! I fixed the UML garbage. It seems anyone who isn't building with MAME OS X had the UML working fine, since the problem arises in the build-system. I added a nice little kludge into the code that makes it not rely on the build-system for that info. Also, I made it so that if the SH-2 core can't find a dynarec UML core, it will go ahead and use it's own interpreter, to speed it up a good amount. The native interpreter still isn't nearly as fast as the dynarec though (SH-2 interpreter gets 150% for me, whereas the dynarec core gets 600%)
Go ahead and build the latest commit if you want to try it out :)

Name: Link:
Leave these fields empty (spam trap):
More options...