infinite-mac icon indicating copy to clipboard operation
infinite-mac copied to clipboard

See if Emscripten is generating inefficient code for the main emulator switch statement

Open mihaip opened this issue 2 years ago • 3 comments

At least historically this as an issue: https://github.com/emscripten-core/emscripten/issues/1909 and https://bugs.chromium.org/p/v8/issues/detail?id=2275 and https://artemis.sh/2022/08/07/emulating-calculators-fast-in-js.html

mihaip avatar Mar 31 '22 22:03 mihaip

Hello,

I am really enjoying infinite mac, OS9 that give me a way to run some personal software elsewhere than on one of my four power macs. But there is definitely a perfomance issue that ruins the project of demonstrating what was Mac OS 9 and under. If I extrapolate what I can see, infinite mac is about 100 times slower what would have been Mac OS on CPUs of todays. I know that emulating a RISC processor with a CISC one is exactly being on the wrong side of the river, but perhaps some things can be done to reduce the gap. I wrote a lot of assembly code and I noticed large switches in the C code of the emulator : something that almost never occurs in my own code because it means a lot of tests every time it is run. At least reordering the tests to make a dichotomic search could improve the things. But with assembly code the solution is elsewhere : in computed branches. Is it possible to explore this feature that seems to be present in gcc?

Best regards

jllipatz avatar Jan 22 '23 19:01 jllipatz

I haven't had a chance to look at the generated code for the CPU emulator (for either Basilisk II or SheepShaver), so I don't know if this is actually an issue.

What program are you trying to run? Is it doing mostly integer operations or floating point?

mihaip avatar Jan 24 '23 04:01 mihaip

The program is not the issue it is just a benchmark. My program is some LISP code : it involves interpretation of code and it does a very simple computation on short (word) integers) : the value for the 23th fibonacci number. It uses the naïve way (double recursion) to involve a lot of stack frame creations and to test the speed of the interpreter rather than to measure the speed of numeric computations. When I first learned Lisp, 1min was considered as a good time to make that computation with Lisp on professional computers. But it was a long long time ago (the 80's!). Infinite Mac does the computation with my own Lisp in 30 seconds (no additionnal application running on the PC) and with the same conditions the best power Mac I have takes 0.7s although running Classic MacOS under MacOSX and the oldest one 1.8s on a true MacOS 9.2 But what I notice first, using infinite Mac, is the way the Mac refreshes the screen. To get some minimal comfort you absolutely have to hide the Finder and other applications.

jllipatz avatar Jan 30 '23 10:01 jllipatz