BOINC / boinc

Open-source software for volunteer computing and grid computing.
https://boinc.berkeley.edu
GNU Lesser General Public License v3.0
2.01k stars 445 forks source link

"Suspend when non-BOINC CPU usage is above" setting fails with VirtualBox tasks #5841

Open JonathanBush opened 1 day ago

JonathanBush commented 1 day ago

Describe the bug BOINC client detects VirtualBox Headless Frontend as non-BOINC CPU usage and pauses computation based on the "Suspend when non-BOINC CPU usage is above" setting.

Steps To Reproduce

  1. Attach a project that uses VirtualBox (e.g. LHC@home). VirtualBox must be installed. Project should be set to utilize all available cores.
  2. In Advanced View, open Computing Preferences. Enable the "Suspend when non-BOINC CPU usage is above" and enter 90 in the text field. Save the new computing preferences.
  3. Ensure that "Run based on preferences" is selected in the Activity menu.
  4. Observe CPU usage in Task Manager. Ensure that no other user processes have high CPU utilization.
  5. Wait for a VBox task to initialize and start heavy computation. If this bug is reproducible, you should see the task status switch to "Suspended - CPU is busy" and see "Suspending computation - CPU is busy" in the event log.

Expected behavior BOINC should continue running until non-BOINC CPU load exceeds the set threshold.

System Information

Additional context I enabled this setting with a non-BOINC utilization percentage of 90% so that BOINC would pause when I run workloads that need full use of the CPU cache. Recently noticed this issue with LHC@home tasks. I also noticed that the VM keeps running in the background when BOINC is suspended.

davidpanderson commented 1 day ago

The BOINC client looks for a program called 'VBoxSVC.exe' (case sensitive) and, if any VM apps are running, counts its CPU time as due to BOINC.

To check this, can you please (while a BOINC VM app is running)

Let me know if this is what you see. Also let me know what version of VBox you have installed (run VirtualBox Manager, click Help / About Virtualbox)

Thanks -- David

JonathanBush commented 1 day ago

I see 'VBoxSVC.exe' running, but its CPU utilization is 0%. The high CPU utilization is coming from one instance of 'VBoxHeadless.exe'. This was running VirtualBox 6.1.50. I also upgraded to VirtualBox 7.0.20 and observed the same behavior

davidpanderson commented 1 day ago

Aha. That's the culprit. We'll fix it ASAP. Thanks.

computezrmle commented 1 day ago

VBoxSVC typically maintains the command queue sent by VBoxManage or the Vbox GUI. It's CPU usage is very low with small peaks when a VM is created, modified or shut down. Nonetheless those cycles should be counted for BOINC to avoid the total non-BOINC value goes right above the limit.

There may be more than one VBoxSVC instance on the same computer, 1 per user account running Vbox VMs. Example: VBoxSVC_1: related to a VM started by a service at boot time VBoxSVC_2: related to an account running BOINC

Here, VBoxSVC_1 doesn't count for BOINC.

JonathanBush commented 10 hours ago

It looks like BOINC already has access to the PID of the VBoxHeadless.exe instance (PID shown in stderr.txt in the slots dir matches PID shown in Task Manger), so would it be possible to include only the CPU utilization from the known BOINC VM PID(s)? This would address @computezrmle's concern about non-BOINC VMs.

davidpanderson commented 9 hours ago

It would be possible but I doubt that happens in practice (running BOINC/LHC and running another CPU-intensive VBox VM) so let's hold off.

BTW, looking at the vboxwrapper code (vbox_common.cpp) I see a function VBOX_BASE::launch_vboxvm() that's never called. Should we remove it?

computezrmle commented 2 hours ago

What people run inside separate VMs:

There are also people running multiple BOINC clients concurrently on the host and each of them may run VirtualBox VMs.

As for VBOX_BASE::launch_vboxvm(): Yes, it is never called. I'll prepare a PR to remove it.