News for hackers. Stuff that matters.
Re:The Evolution of the QEMU Translator by FeepingCreature on Friday January 29, 2021 @05:49AM (#25956027)
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...
Re:The Evolution of the QEMU Translator by pm215 on Friday January 29, 2021 @06:37AM (#25956258)
Not 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.

Re:The Evolution of the QEMU Translator by jakogut on Friday January 29, 2021 @10:15AM (#25958032)
> 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

Re:The Evolution of the QEMU Translator by stsquad on Monday February 01, 2021 @04:29PM (#25994232)
AIUI 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.
Re:The Evolution of the QEMU Translator by jart on Friday January 29, 2021 @06:26AM (#25956211)
The 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 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.

Re:The Evolution of the QEMU Translator by gaul on Saturday January 30, 2021 @08:15AM (#25968787)
HP Dynamo is similar to what you suggest:

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.

Re:The Evolution of the QEMU Translator by saagarjha on Friday January 29, 2021 @06:39AM (#25956274)
This sounds much like the pitch behind the JVM.
Re:The Evolution of the QEMU Translator by saurik on Saturday January 30, 2021 @01:33PM (#25971576)
While true of course, this more directly sounds like the OG pitch behind the Low-Level Virtual Machine (aka, LLVM).
Re:The Evolution of the QEMU Translator by ec109685 on Friday January 29, 2021 @11:10AM (#25958762)
Isn’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.