From f3366ec5bacd3bc38b9b66a6a835b6d9707cf812 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 1 May 2014 13:05:30 -0700 Subject: [PATCH] client: track and report network, disk, and memory usage - store final network usage in RESULT; write/parse in state file - final disk and memory usage weren't being written to state file; do so. - add --network_usage option to example app, to test this stuff --- client/app_control.cpp | 10 ++++++-- client/result.cpp | 50 +++++++++++++++++++++++++++++++------ client/result.h | 2 ++ samples/example_app/uc2.cpp | 7 ++++++ 4 files changed, 59 insertions(+), 10 deletions(-) diff --git a/client/app_control.cpp b/client/app_control.cpp index 7c04a0be4c..e5dbab7a5d 100644 --- a/client/app_control.cpp +++ b/client/app_control.cpp @@ -385,6 +385,8 @@ void ACTIVE_TASK::copy_final_info() { result->final_peak_working_set_size = peak_working_set_size; result->final_peak_swap_size = peak_swap_size; result->final_peak_disk_usage = peak_disk_usage; + result->final_bytes_sent = bytes_sent; + result->final_bytes_received = bytes_received; } // deal with a process that has exited, for whatever reason: @@ -1332,13 +1334,17 @@ bool ACTIVE_TASK::get_app_status_msg() { parse_double(msg_buf, "", result->intops_cumulative); if (parse_double(msg_buf, "", dtemp)) { if (dtemp > bytes_sent_episode) { - daily_xfer_history.add(dtemp - bytes_sent_episode, true); + double nbytes = dtemp - bytes_sent_episode; + daily_xfer_history.add(nbytes, true); + bytes_sent += nbytes; } bytes_sent_episode = dtemp; } if (parse_double(msg_buf, "", dtemp)) { if (dtemp > bytes_received_episode) { - daily_xfer_history.add(dtemp - bytes_received_episode, false); + double nbytes = dtemp - bytes_received_episode; + daily_xfer_history.add(nbytes, false); + bytes_received += nbytes; } bytes_received_episode = dtemp; } diff --git a/client/result.cpp b/client/result.cpp index 8a4629aed9..0f223ad246 100644 --- a/client/result.cpp +++ b/client/result.cpp @@ -54,6 +54,11 @@ void RESULT::clear() { got_server_ack = false; final_cpu_time = 0; final_elapsed_time = 0; + final_peak_working_set_size = 0; + final_peak_swap_size = 0; + final_peak_disk_usage = 0; + final_bytes_sent = 0; + final_bytes_received = 0; #ifdef SIM peak_flop_count = 0; #endif @@ -145,6 +150,11 @@ int RESULT::parse_state(XML_PARSER& xp) { } if (xp.parse_double("final_cpu_time", final_cpu_time)) continue; if (xp.parse_double("final_elapsed_time", final_elapsed_time)) continue; + if (xp.parse_double("final_peak_working_set_size", final_peak_working_set_size)) continue; + if (xp.parse_double("final_peak_swap_size", final_peak_swap_size)) continue; + if (xp.parse_double("final_peak_disk_usage", final_peak_disk_usage)) continue; + if (xp.parse_double("final_bytes_sent", final_bytes_sent)) continue; + if (xp.parse_double("final_bytes_received", final_bytes_received)) continue; if (xp.parse_int("exit_status", exit_status)) continue; if (xp.parse_bool("got_server_ack", got_server_ack)) continue; if (xp.parse_bool("ready_to_report", ready_to_report)) continue; @@ -208,16 +218,40 @@ int RESULT::write(MIOFILE& out, bool to_server) { if (intops_cumulative) { out.printf(" %f\n", intops_cumulative); } + if (final_peak_working_set_size) { + out.printf( + " %.0f\n", + final_peak_working_set_size + ); + } + if (final_peak_swap_size) { + out.printf( + " %.0f\n", + final_peak_swap_size + ); + } + if (final_peak_disk_usage) { + out.printf( + " %.0f\n", + final_peak_disk_usage + ); + } + if (final_bytes_sent) { + out.printf( + " %.0f\n", + final_bytes_sent + ); + } + if (final_bytes_received) { + out.printf( + " %.0f\n", + final_bytes_received + ); + } if (to_server) { out.printf( - " %d\n" - " %.0f\n" - " %.0f\n" - " %.0f\n", - wup->version_num, - final_peak_working_set_size, - final_peak_swap_size, - final_peak_disk_usage + " %d\n", + wup->version_num ); } n = (int)stderr_out.length(); diff --git a/client/result.h b/client/result.h index 9d21f3f416..0a9c91d659 100644 --- a/client/result.h +++ b/client/result.h @@ -43,6 +43,8 @@ struct RESULT { double final_peak_working_set_size; double final_peak_swap_size; double final_peak_disk_usage; + double final_bytes_sent; + double final_bytes_received; #ifdef SIM double peak_flop_count; double sim_flops_left; diff --git a/samples/example_app/uc2.cpp b/samples/example_app/uc2.cpp index a87dc2731e..486bd1a6c2 100644 --- a/samples/example_app/uc2.cpp +++ b/samples/example_app/uc2.cpp @@ -36,6 +36,7 @@ // --run_slow: sleep 1 second after each character // --trickle_up: sent a trickle-up message // --trickle_down: receive a trickle-up message +// --network_usage: tell the client we used some network // #ifdef _WIN32 @@ -77,6 +78,7 @@ bool trickle_up = false; bool trickle_down = false; bool critical_section = false; // run most of the time in a critical section bool report_fraction_done = true; +bool network_usage = false; double cpu_time = 20, comp_result; // do about .5 seconds of computing @@ -151,6 +153,7 @@ int main(int argc, char **argv) { if (strstr(argv[i], "early_sleep")) early_sleep = true; if (strstr(argv[i], "run_slow")) run_slow = true; if (strstr(argv[i], "critical_section")) critical_section = true; + if (strstr(argv[i], "network_usage")) network_usage = true; if (strstr(argv[i], "cpu_time")) { cpu_time = atof(argv[++i]); } @@ -235,6 +238,10 @@ int main(int argc, char **argv) { boinc_register_timer_callback(update_shmem); #endif + if (network_usage) { + boinc_network_usage(5., 17.); + } + // main loop - read characters, convert to UC, write // for (i=0; ; i++) {