klange / toaruos

A completely-from-scratch hobby operating system: bootloader, kernel, drivers, C library, and userspace including a composited graphical UI, dynamic linker, syntax-highlighting text editor, network stack, etc.
https://toaruos.org/
University of Illinois/NCSA Open Source License
6.13k stars 487 forks source link

Very slow graphics #271

Open mxlgv opened 1 year ago

mxlgv commented 1 year ago

Recently I ran the latest release in VirtualBox and noticed that the graphics are running unbearably slow. Although it seemed to me that it was faster before. I allocated a lot of resources to the virtual machine, but this did not give positive results. Maybe this is due to the incorrect configuration of the virtual machine. But I'm wondering if you are using the WC (write combined) flag for the Framebuffer memory area. I didn't really understand the source code. According to some developers, this mechanism allows you to speed up vesa graphics in KolibriOS. However, KolibriOS uses MTRR for this, but it seems there is a way to do this via PAT.

klange commented 1 year ago

This is very likely a misconfiguration in VirtualBox.

There should be an icon in the VirtualBox statusbar that shows the CPU utilization of the VM. Hovering over this icon should provide details of the execution environment, including the virtualization interface being used and whether functionality like nested paging is enabled. Can you try to get a screenshot of that tooltip?

Screenshot_2023-04-08_07-55-40

ToaruOS does use PAT to provide write-combining and this is enabled for graphics framebuffers. MTRRs are an older method. You can view the configuration for the page attribute table via procfs, though there's no easy way to check the table index for any given page.

toaru_screen_2023-04-08_07_51_38

klange commented 1 year ago

By the way, if the icon in the tray with the CPU meter has a turtle icon, you know you're in for a bad time - that's an indicator that some critical piece of the virtualization stack is not functioning. VirtualBox used to be pretty loud in the 5.x and 6.x days about missing functionality and would usually refuse to launch VMs at all under those conditions, but I've found 7 will happily give you a horribly broken experience instead - with that turtle as your only confirmation that something is wrong.

If you're on a Windows host, this usually means Hyper-V is mucking things up - running VirtualBox alongside WSL2, for example, is prone to issues. For macOS, VirtualBox does not work correctly with HVF (and I strongly recommend QEMU, which does fully support HVF virtualization - and I worked with the team to fix an issue with the memory mapping for some of the virtual graphics devices ToaruOS supports). For Linux hosts, VirtualBox does not play well with other KVM users.

mxlgv commented 1 year ago

Yes, apparently the problem is really in my VirtualBox configuration. I don't have access to this computer right now to check. However, on my other computer, the graphics are relatively fast. Please don't close this yet. I'll try to test on another PC soon.