4 ms·
What if QEMU ends up faster than native? I could imagine a future where programs are built unoptimized or with `-Os` for download size, and optimized by the ope
by FeepingCreature 6y ago
What if QEMU ends up faster than native? I could imagine a future where programs are built unoptimized or with `-Os` for download size, and optimized by the operating system before or during execution, with x86 or arm (or risc-v!) ending up as the default "portable executable instruction format" for a whole bunch of CPU architectures. Where the first thing the OS or even the BIOS loads is qemu...
- jart 6y agoThe GCC Runtime Exception v3 might forbid that. That's one of the reasons why Apple and Google blew a gasket when GNU changed licenses and then poured billions into Clang. They wanted to be able to recompile your app store binaries on their backend to optimize for any hardware changes they made. One workaround for that restriction is to use Cosmopolitan Libc: https://justine.lol/cosmopolitan/index.html https://justine.lol/cosmopolitan/index.html It bundles compiler runtime libraries that are fast and permissively licensed. It lets you keep using GCC without facing restrictions on things like code morphing.
- pm215 6y agoNot gonna happen, so it's a bit irrelevant. QEMU's architecture is fairly generic and it was never built for speed in the first place. Improving the speed of emulation is more about getting better than the current baseline of "10x or worse slower than native, and continuing to gradually get slower if we add features and don't actively try to work on performance". If we got to "3x slower than native" I would be really surprised. Which isn't to say that you can't do better than 3x-slower under any circumstances, just that if you wanted performance you'd probably be better off starting from scratch with an emulator design that cared about performance and which was really clear about its use-cases -- eg "this is user-space only, not system emulation" and "this is only this very small set of host and guest architectures". QEMU does a lot of different things in one codebase, which makes it cumbersome to change anything and hard to put in optimisations or simplifications which might be valid for a specific host/target combination but not more widely.
- jakogut 6y ago> if you wanted performance you'd probably be better off starting from scratch with an emulator design that cared about performance and which was really clear about its use-cases See box86: https://github.com/ptitSeb/box86 https://github.com/ptitSeb/box86
- stsquad 6y agoAIUI that is mainly achieved by running the native library functions.Given how much time you spend in library functions I'm not surprised it has an edge over the full translation of the application.
- saagarjha 6y agoThis sounds much like the pitch behind the JVM.
- saurik 6y agoWhile true of course, this more directly sounds like the OG pitch behind the Low-Level Virtual Machine (aka, LLVM).
- ec109685 6y agoIsn’t that essentially what WASM is? It’d be interesting to see the performance of QEMU if it used WASM as an intermediate representation, and then fed that into WASM engine so it could take advantage of all the browser’s optimizations.
- gaul 6y agoHP Dynamo is similar to what you suggest: https://www.hpl.hp.com/techreports/1999/HPL-1999-78.html https://www.hpl.hp.com/techreports/1999/HPL-1999-78.html Note that CPUs and compiler optimization have improved over the last 20 years and these results may not still hold.