4 ms·
FWIW: in my 8-bit emulators I'm closer to the 10% performance difference for code compiled in clang with -O3 (the native version uses latest Xcode's clang, the
by flohofwoe 7y ago
FWIW: in my 8-bit emulators I'm closer to the 10% performance difference for code compiled in clang with -O3 (the native version uses latest Xcode's clang, the WASM the latest LLVM WASM backend via emscripten):
https://floooh.github.io/tiny8bit/cpc-ui.html https://floooh.github.io/tiny8bit/cpc-ui.html
The time in the top-right is the time spent per frame in the emulator, in the WASM version that's somewhere around 2.5 to 2.8ms on my laptop.
The native version is somewhere between 2.0 and 2.2ms.
From my experiments, it's quite easy to accidentally hit a "slow path" on the WASM side, for instance registers are spilling earlier (AFAIK because WASM has one or two registers set aside). Things are getting better though. About a year ago, the same emulator code seemed to have triggered some specific slow-path and the WASM version was nearly 4x slower.
Of course it's always possible to put more time into optimizing the native version of a piece of code when targeting a specific compiler version, compiler-specific intrinsics and a specific CPU model. This is where WASM will always lag behind, with a portable ISA you'll always hit a wall where further optimization simply isn't possible.
So from my experience: somewhere between 10% slower and 3x slower is all within the "expected" range, the more important part is that performance is predictable for a given piece of code compiled with a given compiler version (e.g. you won't have the GC come in and do its thing for a few hundred milliseconds). And at least the emscripten team is very responsive and interested in such pathological cases.
- hinkley 7y agoBut 10% is something I can easily sell to my boss. I only need one or two compensating qualities for that argument to succeed. If I'm getting work done faster, prioritizing a couple more perf stories is a reasonable tax to pay.
- tracker1 7y agoIt depends on what you are trying to do... you can only spend so much CPU time on a blinking cursor waiting for a user to click/type something.