Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: measure CPU time of VBox apps correctly #5867

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
//
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions lib/procinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 && 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
) {
sum += p.user_time;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/procinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading