LekKit / RVVM

The RISC-V Virtual Machine
GNU General Public License v3.0
921 stars 66 forks source link

Integration with libvirt in the future? #93

Open playXE opened 1 year ago

playXE commented 1 year ago

Hi! Nice work! I am running RISC-V Ubuntu 22.04 on my home server through libvirt/qemu and SSH into it through forwarded ports for developing JIT compiler for RISC-V. But build times on QEMU are just super slow. So I am asking if libvirt integration would be possible in the future so setting up and managing the VM can be done through Cockpit UI or virt-manager

LekKit commented 1 year ago

At some point yes, the RVVM Machine API may be wrapped to provide libvirt support. There been some work done by others, but they shortly ditched it halfway through due to lack of interest, so it doesn't seem complicated.

I would however recommend running qemu-user, or rvvm-user (which isn't usable yet but stay tuned) if the compile speeds matter very much.

The SoftMMU approach used by both QEMU & RVVM for emulating whole machines makes them inevitably slower than the host for some workloads, and compilers are very much affected. There are ways around that (using VMA to accelerate emulated MMU) but it requires a ton of work and existing OSes limit this in one way or another.

TL;DR RVVM might be 50% or whatever faster than QEMU for compiling, but it's not like it's near native speed anyways

playXE commented 1 year ago

Thanks for an answer! 50% is already very good for me! Just running my project with concurrent GC + JIT compiler takes almost an eternity on some tests and if it would be 1.5 times faster that's super great for me

LekKit commented 1 year ago

It's a rough estimation given that RVVM is ~2x faster on cold code translation, ~40% faster on pure integer math but ain't as good at load/stores or very complex logic. GCC falls into this estimation, but your usecase might even be slower, who knows - that's why "benchmark first". FPU/Atomic are currently interpreted only.

You may also submit chunks of code/asm you think are executing too slow on RVVM so I can have a look at optimizing it.

About the issue topic, read a bit about libvirt infrastructure, it seems it will be easy to get initial thing going, but the lack of documentation on adding a new hypervisor is absolutely painful. Upstreaming it seems a necessity, considering there is no way to add a new hypervisor without rebuilding libvirt. If anyone could point out the lacking documentation bits, would be very helpful.