From b40050c42ae8b914ce7525f9cccc15c712f361b5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 7 Oct 2024 17:42:02 -0700 Subject: [PATCH 1/2] client: measure CPU time of VBox apps correctly We were checking for VBoxSVC.exe and, if a VBox app is running, counting its CPU time as BOINC-related. Should be 'VBoxHeadless.exe' on Win. May be different on Mac/Linux, so use '*vbox*', case-insensitive --- client/app.cpp | 6 +++--- lib/procinfo.cpp | 7 +++++-- lib/procinfo.h | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/client/app.cpp b/client/app.cpp index eda742eb22b..d3bd0193722 100644 --- a/client/app.cpp +++ b/client/app.cpp @@ -363,7 +363,7 @@ void ACTIVE_TASK_SET::get_memory_usage() { int retval; static bool first = true; double diff=0; - bool using_vbox = false; + bool vbox_app_running = false; if (!first) { diff = gstate.now - last_mem_time; @@ -415,7 +415,7 @@ void ACTIVE_TASK_SET::get_memory_usage() { } procinfo_app(pi, v, pm, atp->app_version->graphics_exec_file); if (atp->app_version->is_vm_app) { - using_vbox = true; + vbox_app_running = true; // the memory of virtual machine apps is not reported correctly, // at least on Windows. Use the VM size instead. // @@ -540,7 +540,7 @@ void ACTIVE_TASK_SET::get_memory_usage() { static double last_nbrc=0; double total_cpu_time_now = total_cpu_time(); if (total_cpu_time_now != 0.0) { // total_cpu_time() returns 0.0 on error - double nbrc = total_cpu_time_now - boinc_related_cpu_time(pm, using_vbox); + double nbrc = total_cpu_time_now - boinc_related_cpu_time(pm, vbox_app_running); double delta_nbrc = nbrc - last_nbrc; if (delta_nbrc < 0) delta_nbrc = 0; last_nbrc = nbrc; diff --git a/lib/procinfo.cpp b/lib/procinfo.cpp index df87edcf813..2c91f0288ed 100644 --- a/lib/procinfo.cpp +++ b/lib/procinfo.cpp @@ -165,7 +165,7 @@ void procinfo_non_boinc(PROCINFO& procinfo, PROC_MAP& pm) { // get CPU time of BOINC-related processes, low-priority processes, // and (if we're using Vbox) the Vbox daemon. // -double boinc_related_cpu_time(PROC_MAP& pm, bool using_vbox) { +double boinc_related_cpu_time(PROC_MAP& pm, bool vbox_app_running) { double sum = 0; PROC_MAP::iterator i; for (i=pm.begin(); i!=pm.end(); ++i) { @@ -176,7 +176,10 @@ double boinc_related_cpu_time(PROC_MAP& pm, bool using_vbox) { if ( p.is_boinc_app || p.is_low_priority - || (using_vbox && strstr(p.command, "VBoxSVC")) + || (vbox_app_running && strcasestr(p.command, "vbox")) + // if a VBox app is running, + // count VBox processes as BOINC-related + // e.g. VBoxHeadless.exe and VBoxSVC.exe on Win ) { sum += p.user_time; } diff --git a/lib/procinfo.h b/lib/procinfo.h index d283c7cb553..2af80795814 100644 --- a/lib/procinfo.h +++ b/lib/procinfo.h @@ -87,7 +87,7 @@ extern double process_tree_cpu_time(int pid); extern double total_cpu_time(); // total user-mode CPU time, as reported by OS -extern double boinc_related_cpu_time(PROC_MAP&, bool using_vbox); +extern double boinc_related_cpu_time(PROC_MAP&, bool vbox_app_running); // total CPU of current BOINC processes, low-priority processes, - // and (if using vbox) the Vbox daemon + // and (if a VBox app is running) VBox-related processes #endif From b9eb3c6721ef03cde1b336ca9d6506a0524f11ac Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Wed, 30 Oct 2024 12:22:27 -0700 Subject: [PATCH 2/2] Win build fix --- lib/procinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/procinfo.cpp b/lib/procinfo.cpp index 2c91f0288ed..27b2f3f4b42 100644 --- a/lib/procinfo.cpp +++ b/lib/procinfo.cpp @@ -176,7 +176,7 @@ double boinc_related_cpu_time(PROC_MAP& pm, bool vbox_app_running) { if ( p.is_boinc_app || p.is_low_priority - || (vbox_app_running && strcasestr(p.command, "vbox")) + || (vbox_app_running && strstr(p.command, "VBox")) // if a VBox app is running, // count VBox processes as BOINC-related // e.g. VBoxHeadless.exe and VBoxSVC.exe on Win