Can we make PCem much faster?

Support and general discussion.
Post Reply
szadycbr
Posts: 295
Joined: Mon 21 Nov, 2016 6:23 pm

Can we make PCem much faster?

Post by szadycbr »

Hi everyone, finally i can ask question which is bothering me for a couple of years.
Dont get me wrong, PCem is by far the fastest and the best emulator ever written, and i do not saying that to lick your ass, only cos i have tested everyone over the years and PCem outperform every single one like 10 to 1.
I might be very wrong , but as far as i understand emulator emualte every instruction, wchich takes a loot of power of course, and we can only dream of emulating PIII500Mhz on our hardware. My question is , do we need emulate every instruction? even if the newest Cpus have backward compatibility with x86 instruction set?
I m not talking about virtualization, but wht if the program will make simple call for emulated instruction ,straight to Host CPU? like i said i might be wrong , but after all i think this instruction is in the Host cpu, so why to emulate? maybe we could just use basic set , without mmx, sse, etc. and send every request with delay, or make the delay in other way, to achieve desired speed? i think it might be difficult asking cpu directely for anything , but maybe asking indirectely? which itself will cause the delay? i really would like to know if any of this make any sense.

Also emulating graphics cards, of course there is no compatibility between chips of different brands and models, but what about vesa? my poor HD3000 still have it, and i m convinced that every other card still have it, after all on hp6360b i did install dos, then win98 with patched VMM for 4Gb memory and Vesa display driver still works, so maybe vesa instructions dont have to be emulated in conventional way as well?
In cpu emulation, maybe do not try to call for X86 set but only for extensions? like MMX or so? even this should make an impact.
Any way as a humans we get things, and after exploring our nature makes us want more, but still PCem is a miracle. Tom and Sarah deserve all the best from life, for this wonderfull project, not forgeting every other developer who contributed.
Thank You, and i hope to get answer for my, maybe stupid questions.
User avatar
dreamer
Posts: 40
Joined: Wed 28 Dec, 2016 11:56 am

Re: Can we make PCem much faster?

Post by dreamer »

Regarding offloading instructions - not emulating every instruction would be against what PCem is going for and it wouldn't really work, and newer versions of PCem do offload some of the work to processor directly with the recompiler, right?

I'm taking a guess here, but it would be extremely hard and system-specific to offload specific display instructions directly to the graphics card? PCem would have to kick off Windows and other applications to run in some exclusive mode that controls the whole graphics card and then legacy software would get all bamboozled since it's something it was never designed to do. It's way better to translate to DirectX/OpenGL and leave it at that since that means, that there is a middle layer that keeps compatibility high and doesn't rely on legacy calls that are being deprecated :)

It's interesting for me to hear the actual answers too, I am talking only from what I know about PCem!
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Can we make PCem much faster?

Post by SarahWalker »

szadycbr wrote:I m not talking about virtualization, but wht if the program will make simple call for emulated instruction ,straight to Host CPU? like i said i might be wrong , but after all i think this instruction is in the Host cpu, so why to emulate? maybe we could just use basic set , without mmx, sse, etc. and send every request with delay, or make the delay in other way, to achieve desired speed? i think it might be difficult asking cpu directely for anything , but maybe asking indirectely? which itself will cause the delay? i really would like to know if any of this make any sense.
No, not really. I can only assume you're not a programmer, as this is a fairly major misunderstanding of how a CPU actually works.
Also emulating graphics cards, of course there is no compatibility between chips of different brands and models, but what about vesa?
Even if it was possible to use VESA on the host machine (which it isn't from Windows), this would gain you essentially nothing in performance.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Can we make PCem much faster?

Post by SarahWalker »

dreamer wrote:It's way better to translate to DirectX/OpenGL and leave it at that since that means, that there is a middle layer that keeps compatibility high and doesn't rely on legacy calls that are being deprecated :)
It would be possible to offload most of the 3DFX emulation to DX/OpenGL, but it's not something I'm keen on. Performing all the rendering on software gives graphical output that actually looks like a 3DFX board, rather than a modern graphics card.
User avatar
omarsis81
Posts: 945
Joined: Thu 17 Dec, 2015 6:20 pm

Re: Can we make PCem much faster?

Post by omarsis81 »

I agree with "dreamer" in that all instructions must be emulated! Currently only MMX are working. No SSE as Pentium III is very far from being true. Many games requiere those instructions to work. If you want PCem to run faster, then... emulate a Pentium with no MMX instructions... Like a Pentium 200
Many games explicitly requiere MMX to run.
I believe a Pentium II is in the project of Sarah, but she said more optimization need to be done before, so it can run well on most modern computers.
I´m very satisfied on how thing are being done so far. You can see work done every week. I´m sure PCem will get faster and faster, and your PIII 500 will be a reality someday ;)
User avatar
omarsis81
Posts: 945
Joined: Thu 17 Dec, 2015 6:20 pm

Re: Can we make PCem much faster?

Post by omarsis81 »

SarahWalker wrote:
dreamer wrote:It's way better to translate to DirectX/OpenGL and leave it at that since that means, that there is a middle layer that keeps compatibility high and doesn't rely on legacy calls that are being deprecated :)
It would be possible to offload most of the 3DFX emulation to DX/OpenGL, but it's not something I'm keen on. Performing all the rendering on software gives graphical output that actually looks like a 3DFX board, rather than a modern graphics card.
Also, rendering on software gives more compatibility and portability
It looks really great
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Can we make PCem much faster?

Post by SarahWalker »

The majority of PCem's performance issues are related to the CPU emulation and the surrounding support code. There are a couple of other areas that have a noticeable impact - hard drive and CD-ROM emulation, and interfacing between the CPU emulation and 3DFX code. But the vast majority is the CPU.

The CPU dynamic recompiler can be split into two issues - the generated code, which actually performs the CPU emulation, and all the other crap that supports it, eg the code generator, interfacing with the memory system, handling self-modifying code, actually deciding what generated code blocks to run, etc...

The generated code isn't very good - the code generator is an extremely basic design and the results are a bit suboptimal. So far the improvements here have been mainly in the area of recompiling more instructions; the code isn't any better, there's just more of it! But I've run out of low hanging fruit here, the existing recompiler design simply isn't up to the job. I do have plans to write a new recompiler to remedy this, which should (hopefully!) give a decent speed increase, but it will be a LOT of work and won't happen for a while. Probably v14 at the earliest.

The support code has more scope for improvements, and I've been trying to deliver on this for the last couple of releases. There are a number of improvements in v12, and I have some ideas for some more improvements in v13. But, again, I'm running out of low hanging fruit here - improvements beyond this will also require a lot of work and a lot of redesign.

Even with these improvements though, I think there is an upper limit on how much performance we can get - my rough estimation would be around 500-600 MHz on current hardware. To go beyond that would mean going down the virtualisation route; this would mean loosing the ability to control emulated CPU speed, and would require such drastic code changes that the resulting emulator wouldn't be PCem anymore.
szadycbr
Posts: 295
Joined: Mon 21 Nov, 2016 6:23 pm

Re: Can we make PCem much faster?

Post by szadycbr »

Thank You Sarah and Dreamer , you did straighten me up. And Your explanaition is quite clear, also now i know that it is much better to translate dx/openGl for graphics (why i have not thought that? stupid).
Anyway, PCem performance is still exceptional, and i m extremally surprised how well and fast 3Dfx emulation is working.
I hope soon i will be able to help you somehow. In the future , the linux version ,you could build it for android and put into Android Market that will definitely give you nice cash boost for your work. Android have Limbo PC emulator and is build on qemu source, as far as my tests goes PCem outperforming qemu significantly on every level, and i did run limbo on First tegra device at 1.7 ghz and DSL linux was working quite ok. There is a posibillity that PCem on android will be able to boot win9x at nice workable speed, which Limbo cant do.
Just a thought, all the best.
User avatar
dreamer
Posts: 40
Joined: Wed 28 Dec, 2016 11:56 am

Re: Can we make PCem much faster?

Post by dreamer »

Android version is interesting, since there have been efforts to make a Linux version that runs on Allegro, and Allegro technically works on Android, but I higly doubt the performance on most Android devices (save for the high-end ones) will be sufficient enough for it even if it works at all!

I really hope this project has led You, Sarah, to learn new things and I truly believe that the next time around You will show us something even more cool and even more performing! I'm glad to see the project moving forward over such long years, and I can only dream what it will be capable of in the future while staying true to its formula :3
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: Can we make PCem much faster?

Post by leilei »

I prefer software voodoo emulation over GL/D3D myself. Dunno about Vulkan though, and frankly if you can emulate a Pentium at nice speeds at 100% you can emulate a Voodoo2 in software. ;)

The biggest thing you'd lose when moving Voodoo into GL/D3D is timing. It would be as realistic as adding Bitchin' Fast3D 2000 support to an emulator

The next tier of emulated speed I can see happening from this point is maybe Voodoo2 SLI. I'm seeing the classic old V2 bottleneck in a few 2000/2001 games (at 100% PMMX300) so there's plenty of that area to expand.
Orchidsworn
Posts: 65
Joined: Sun 22 Mar, 2015 10:16 pm

Re: Can we make PCem much faster?

Post by Orchidsworn »

I am excited to hear that 500-600 Mhz could be reach on modern hardware. That is about as far as you really need to go beyond that I find Virtualization picks up the rest of the slack for Windows games at least. Hell a 450 Pentium II should really be fine.

And I am thinking I am waiting till PCI-E 4.0 becomes a thing to get a new computer so maybe this program will be ready for me when I am ready for it.
ecksemmess
Posts: 183
Joined: Wed 18 Mar, 2015 5:27 am

Re: Can we make PCem much faster?

Post by ecksemmess »

SarahWalker wrote:Even with these improvements though, I think there is an upper limit on how much performance we can get - my rough estimation would be around 500-600 MHz on current hardware. To go beyond that would mean going down the virtualisation route; this would mean loosing the ability to control emulated CPU speed, and would require such drastic code changes that the resulting emulator wouldn't be PCem anymore.
This touches upon an idea I've been toying with. Given that fast, modern CPUs are the only major thing PCem will never be able to emulate, it's very tempting to imagine adding a third mode for the guest CPU: in addition to the interpreter and recompiler, and entirely separate from those two and not affecting them, there could be a virtualized pass-through mode with a throttle for roughly targeting different performance levels. There would be a lot of new code involved in this, of course (and to be clear, I'm not asking anyone in particular to write it), but I can't imagine why much existing code would have to be changed, per se. Theoretically, the interpreter, recompiler, and virtualizer could all just happily co-exist without any of them interfering too much with the others.

I realize this is stretching the "purity" and philosophy of PCem, but I don't think it would be a pointless addition, given all of the power and flexibility we have that none of the other virtualization solutions seem to want to bother with. Indeed, with its extensive advantages, I could see PCem one day taking over much of the virtualization market, becoming an incredibly widely used all-in-one emulation/virtualization solution. If I or anyone else ever wants to take a crack at adding a CPU pass-through option, making sure to do it in a way that doesn't interfere with the interpreter or recompiler, would this potentially be acceptable for mainline or would it have to exist only as a fork?
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Can we make PCem much faster?

Post by SarahWalker »

That would be so far out of the scope of PCem that I don't think I'd ever accept that for mainline.
ecksemmess
Posts: 183
Joined: Wed 18 Mar, 2015 5:27 am

Re: Can we make PCem much faster?

Post by ecksemmess »

Fair enough. Mainline or not, it's something that might be fun to mess around with way down the road, but if the goal is to keep PCem-proper focused squarely on emulation, that's perfectly understandable.
User avatar
dreamer
Posts: 40
Joined: Wed 28 Dec, 2016 11:56 am

Re: Can we make PCem much faster?

Post by dreamer »

If we'd want virtualization there's VirtualBox, there's Win3mu (still in the works I hope) and there's of course VMWare, a huge company, Qemu, Bochs... PCem is its own thing, and that's what makes it what it is - unique!
szadycbr
Posts: 295
Joined: Mon 21 Nov, 2016 6:23 pm

Re: Can we make PCem much faster?

Post by szadycbr »

For those with weak CPU, who's striving for PCem performance , there is a info.
Omarsi81 , told me that PCem works better without hyper threading, so i switched from 4 thread to 2 threads on my dual core CPU, and it got better. then i checked whats about voodoo2, if i set only one thread on voodoo2, emulation, would it be running sparately from PCem? it appears that YES it does run separately on the second thread, cos pcem alone on 2 threads uses up to 50% of cpu and while voodoo2 is working it goes upto 98%, and only one voodoo thread is set , so obviously it runs on second thread and i could see way better performance in games, finally NFSIII, quake 3 etc. runs 100% with p120mmx up to 150mmxand on 2.7ghz two cores/threads. It performs no so well when i use 2 threads for voodoo2.
Attachments
pcem nfs III p150mmx.jpg
pcem nfs III p150mmx.jpg (154.6 KiB) Viewed 20450 times
Last edited by szadycbr on Sat 25 Feb, 2017 9:47 pm, edited 1 time in total.
User avatar
omarsis81
Posts: 945
Joined: Thu 17 Dec, 2015 6:20 pm

Re: Can we make PCem much faster?

Post by omarsis81 »

How does Thief run now?
szadycbr
Posts: 295
Joined: Mon 21 Nov, 2016 6:23 pm

Re: Can we make PCem much faster?

Post by szadycbr »

not much have changed for thief, still horrible. i can run game at 100% only on p100 but on menu it drops down to 40%. have you tryed checking menu slowdown during gameplay?
User avatar
Fusion
Posts: 11
Joined: Sun 05 Feb, 2017 10:14 pm
Location: Ontario, Canada

Re: Can we make PCem much faster?

Post by Fusion »

szadycbr, I'm not sure what the problem is? If gameplay is fine why are you so concerned about the menu? Can you still use it?
szadycbr
Posts: 295
Joined: Mon 21 Nov, 2016 6:23 pm

Re: Can we make PCem much faster?

Post by szadycbr »

basically there is no problem, just Wonder why it does slow down. is it b cos emulating software cant manage? or game engine is badly written? maybe there is some strange loop? Wonder , does it do same in real hardware? on real p200 with voodoo?
But generally there is no problem, game runs fine.
Post Reply