From c30bd62227a8708dd97d7d8c297a6ac461902218 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Thu, 29 May 2014 09:46:10 -0400 Subject: [PATCH] VBOX: Report CPU Time instead of elapsed time to boinc_report_app_status() --- samples/vboxwrapper/vbox.cpp | 8 +++++++ samples/vboxwrapper/vbox.h | 2 ++ samples/vboxwrapper/vboxwrapper.cpp | 35 ++++++++++++++++------------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 062843f372..3c8110d27a 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -1979,6 +1979,14 @@ int VBOX_VM::get_vm_exit_code(unsigned long& exit_code) { return 0; } +double VBOX_VM::get_vm_cpu_time() { + double x = process_tree_cpu_time(vm_pid); + if (x > current_cpu_time) { + current_cpu_time = x; + } + return current_cpu_time; +} + int VBOX_VM::get_port_forwarding_port() { sockaddr_in addr; BOINC_SOCKLEN_T addrsize; diff --git a/samples/vboxwrapper/vbox.h b/samples/vboxwrapper/vbox.h index b99f562ee8..2f74bae667 100644 --- a/samples/vboxwrapper/vbox.h +++ b/samples/vboxwrapper/vbox.h @@ -98,6 +98,7 @@ public: // maximum amount of wall-clock time this VM is allowed to run before // considering itself done. double job_duration; + double current_cpu_time; // name of file where app will write its fraction done std::string fraction_done_filename; // is the VM suspended? @@ -193,6 +194,7 @@ public: int get_vm_network_bytes_received(double& received); int get_vm_process_id(); int get_vm_exit_code(unsigned long& exit_code); + double get_vm_cpu_time(); int get_system_log(std::string& log, bool tail_only = true); int get_vm_log(std::string& log, bool tail_only = true); diff --git a/samples/vboxwrapper/vboxwrapper.cpp b/samples/vboxwrapper/vboxwrapper.cpp index 5814d8239a..1b35907520 100644 --- a/samples/vboxwrapper/vboxwrapper.cpp +++ b/samples/vboxwrapper/vboxwrapper.cpp @@ -378,6 +378,7 @@ int main(int argc, char** argv) { double trickle_period = 0; double fraction_done = 0; double checkpoint_cpu_time = 0; + double current_cpu_time = 0; double last_status_report_time = 0; double last_trickle_report_time = 0; double stopwatch_starttime = 0; @@ -1000,6 +1001,25 @@ int main(int argc, char** argv) { } } + // Basic bookkeeping + // + if ((int)elapsed_time % 10) { + current_cpu_time = vm.get_vm_cpu_time(); + } + if (vm.job_duration) { + fraction_done = elapsed_time / vm.job_duration; + } else if (vm.fraction_done_filename.size() > 0) { + read_fraction_done(fraction_done, vm); + } + if (fraction_done > 1.0) { + fraction_done = 1.0; + } + boinc_report_app_status( + current_cpu_time, + checkpoint_cpu_time, + fraction_done + ); + if (boinc_time_to_checkpoint()) { // Only peform a VM checkpoint every ten minutes or so. // @@ -1009,16 +1029,6 @@ int main(int argc, char** argv) { random_checkpoint_factor = 0.0; } - // Basic bookkeeping - if (vm.job_duration) { - fraction_done = elapsed_time / vm.job_duration; - } else if (vm.fraction_done_filename.size() > 0) { - read_fraction_done(fraction_done, vm); - } - if (fraction_done > 1.0) { - fraction_done = 1.0; - } - if ((elapsed_time - last_status_report_time) >= 6000.0) { last_status_report_time = elapsed_time; if (vm.job_duration) { @@ -1078,11 +1088,6 @@ int main(int argc, char** argv) { // checkpoint_cpu_time = elapsed_time; write_checkpoint(checkpoint_cpu_time, vm); - boinc_report_app_status( - elapsed_time, - checkpoint_cpu_time, - fraction_done - ); boinc_checkpoint_completed(); } }