How other people should write their software

Archived bsnes development news, feature requests and bug reports. Forum is now located at http://board.byuu.org/
Mystiq

Post by Mystiq »

I agree with the example on uTorrent. I'll also agree with Visual Studio being a wonderful piece of bloatware; you only have to use it to see how sluggish it can be, especially for what it does -- and what it does that it certainly has no need of.

I have a tendency to write in an accusatory manner, so you'll have to excuse me on that, but I'm taking both sides here.

At once, I have a border line OCD tendency to write "correct" code, so that it does what it's supposed to do in the most correct fashion (it works against me a lot) and then go about optimizing it. Each processor in the SNES being a separate thread certainly seems to be the most correct way to emulate the system, but I wasn't aware of the huge problem of thread synchronization (I read the other thread about save states).

Tthere are still the "classic" emulators, ZSNES and Snes9x, both of which
are already incredibly fast. Like someone else said, you've got a choice. There's no point writing another ZSNES/Snes9x, because they're already there. I haven't looked at the BSNES code but if he optimized as aggressively as some suggest, he might as well drop the project. It has a different goal, so let it be.

On the other hand, I also have a huge tendency to want code to be fast, no matter the application, and violated my own principles at my last job due to the fact that they didn't care about speed nearly at all. Stuff like:

Code: Select all

int a = 0;
a += 10;
for(int i; i < a; i++)
should certainly be changed, but I'm assuming the optimizations in BSNES aren't on the order of that kind of silliness. Besides, there are other kinds of optimizations: BSNES should scale well on multi-core processors. That said, the thing is pretty slow even given modern processors. PCSX2, an emulator for a much more powerful machine, can run nearly full speed on top of the line PCs. I was looking at task manager and watching none of my 4 cores top out above maybe 25% usage, and still the emulation was slow.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

Mystiq wrote:Stuff like:

Code: Select all

int a = 0;
a += 10;
for(int i; i < a; i++)
should certainly be changed
But only for the aesthetics. A compiler worth its usage optimizes it by its own.
Mystiq wrote:PCSX2, an emulator for a much more powerful machine, can run nearly full speed on top of the line PCs.
The power of the emulated machine is only one part of the equation.
Mystiq wrote:I was looking at task manager and watching none of my 4 cores top out above maybe 25% usage, and still the emulation was slow.
Setting the thread affinity to one core might be better for the caches.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

Mystiq wrote:BSNES should scale well on multi-core processors.
bsnes uses libco for multithreading due to the amount of context (thread) switches it needs to do every second. Switching between and synchronizing to a different physical processor core is a relatively slow process, which would negate the advantages of libco even if the library -was- designed to access more than one core, and so the core emulation cannot currently take advantage of multicore processors.
Verdauga Greeneyes
Regular
Posts: 347
Joined: Tue Mar 07, 2006 10:32 am
Location: The Netherlands

Post by Verdauga Greeneyes »

Oh, right. No edits.

This may or may not change in future processor architectures, however the current mindset seems to be that if you need that many context switches per second, 'you're doing it wrong' (ignoring bsnes' admittedly niche situation) so don't hold your breath.
h4tred

Post by h4tred »

Oh god.....I thought this discussion was done and dusted. :( Why did it have to be brought up again? Basically, I thought byuu and I now agree on things, and now the issue has been brought up, again after a period of silence and zero arguments?

Plus: byuu and I both know BSNES is slow :P (no offense byuu, I recall you saying it is on occasions). IMHO, if you though want a nice, accurate emu with a nice degree of speed also, SNESGT is a good bet :). Though ZSNES v2 if you are willing to wait might have some surprises also.
byuu

Post by byuu »

Oh god.....I thought this discussion was done and dusted. Sad Why did it have to be brought up again?
Yet another thing we agree on ;)
BSNES should scale well on multi-core processors.
As it stands, it gets 60fps on the fastest single cores out there. Only the cheapest dual cores have trouble maintaining full speed (even an E2180 can manage.)

We would also need at least four cores, five if you want SuperFX / SA-1 support. Once even low end systems have this, it may well be worth considering. It would also require really fast, highly portable primitives for thread synchronization, eg InterlockedExchange, etc.

It also won't scale linearly. You'll be taxing more cores for smaller gain. The net effect will be more power wasted.
PCSX2, an emulator for a much more powerful machine, can run nearly full speed on top of the line PCs.
UltraHLE can run N64 games on a 300MHz system, faster than even ZSNES runs "10MHz" SA-1 games. And how precise do you think they are? :)

A better question is how precise do they need to be / can be realistically attained?
I was looking at task manager and watching none of my 4 cores top out above maybe 25% usage, and still the emulation was slow.
One of your cores was at 100%, three were idle. That's the way task manager reports CPU usage. By slow, do you mean less than full speed? If so, something else is probably wrong.
adventure_of_link
Locksmith of Hyrule
Posts: 3634
Joined: Sun Aug 08, 2004 7:49 am
Location: 255.255.255.255
Contact:

Post by adventure_of_link »

h4tred wrote:Oh god.....I thought this discussion was done and dusted. :( Why did it have to be brought up again? Basically, I thought byuu and I now agree on things, and now the issue has been brought up, again after a period of silence and zero arguments?
I concur.

*crush*
<Nach> so why don't the two of you get your own room and leave us alone with this stupidity of yours?
NSRT here.
FitzRoy
Veteran
Posts: 861
Joined: Wed Aug 04, 2004 5:43 pm
Location: Sloop

Post by FitzRoy »

I mostly watched this thread from the sidelines, and I just want to add a simple observation before it dies. 100% playback accuracy is incredibly more demanding than 98%. With range-tested IRQs, random ass games were breaking. With an opcode sound core, random ass games were breaking. If it was only stupid golf games that were breaking, maybe it would be worth the speed advantage. But it wasn't. R-Type III was breaking, Secret of Mana was breaking. A lot of people making criticisms weren't here for that. They weren't here to see byuu going mad trying to find a way to get every edge case in a 3000 game library pass simultaneously. It's not style and little snippets of code that makes bsnes 50% slower than it used to be, it is much more fundamental than that. As if any of this is even going to matter in a few years, computers are always getting faster and cheaper.
Locked