From 54311606e3918314d48173ec179a235129ab4fe2 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 18 Oct 2011 04:23:03 +0000 Subject: [PATCH] - client: associate a PROJECT with HTTP_OP where applicable, so that if you use and filter by project you don't see other projects' HTTP stuff - client simulator: cc_config.xml is part of the scenario; log flags are part of the simulation svn path=/trunk/boinc/; revision=24410 --- checkin_notes | 15 +++++++++++++++ client/file_xfer.cpp | 9 ++++++--- client/gui_http.cpp | 6 +++--- client/http_curl.cpp | 16 +++++++++------- client/http_curl.h | 15 ++++++++++++--- client/scheduler_op.cpp | 4 ++-- client/sim.cpp | 23 +++++++++++++++-------- client/work_fetch.cpp | 2 +- doc/sim/sim_util.inc | 5 ++--- doc/sim/sim_web.php | 36 +++++++++++++++++++++++++++++------- 10 files changed, 94 insertions(+), 37 deletions(-) diff --git a/checkin_notes b/checkin_notes index fc630a1e71..37bd8c58ef 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7348,3 +7348,18 @@ David 17 Oct 2011 sim.cpp,h work_fetch.cpp sim_util.cpp + +David 17 Oct 2011 + - client: associate a PROJECT with HTTP_OP where applicable, + so that if you use and filter by project + you don't see other projects' HTTP stuff + - client simulator: cc_config.xml is part of the scenario; + log flags are part of the simulation + + client/ + http_curl.cpp,h + sim.cpp + work_fetch.cpp + file_xfer.cpp + gui_http.cpp + scheduler_op.cpp diff --git a/client/file_xfer.cpp b/client/file_xfer.cpp index ea8f9d3324..9a5d8aa719 100644 --- a/client/file_xfer.cpp +++ b/client/file_xfer.cpp @@ -65,7 +65,7 @@ int FILE_XFER::init_download(FILE_INFO& file_info) { const char* url = fip->download_urls.get_current_url(file_info); if (!url) return ERR_INVALID_URL; return HTTP_OP::init_get( - url, pathname, false, (int)starting_size + file_info.project, url, pathname, false, (int)starting_size ); } @@ -108,7 +108,9 @@ int FILE_XFER::init_upload(FILE_INFO& file_info) { file_size_query = true; const char* url = fip->upload_urls.get_current_url(file_info); if (!url) return ERR_INVALID_URL; - return HTTP_OP::init_post2(url, header, sizeof(header), NULL, 0); + return HTTP_OP::init_post2( + file_info.project, url, header, sizeof(header), NULL, 0 + ); } else { bytes_xferred = file_info.upload_offset; sprintf(header, @@ -140,7 +142,8 @@ int FILE_XFER::init_upload(FILE_INFO& file_info) { const char* url = fip->upload_urls.get_current_url(file_info); if (!url) return ERR_INVALID_URL; return HTTP_OP::init_post2( - url, header, sizeof(header), pathname, fip->upload_offset + file_info.project, url, header, sizeof(header), + pathname, fip->upload_offset ); } } diff --git a/client/gui_http.cpp b/client/gui_http.cpp index 677dc5d83f..e66591baa5 100644 --- a/client/gui_http.cpp +++ b/client/gui_http.cpp @@ -43,7 +43,7 @@ int GUI_HTTP::do_rpc( } boinc_delete_file(output_file); - retval = http_op.init_get(url, output_file, true); + retval = http_op.init_get(0, url, output_file, true); if (retval) return retval; gstate.http_ops->insert(&http_op); gui_http_op = op; @@ -64,7 +64,7 @@ int GUI_HTTP::do_rpc_post( } boinc_delete_file(output_file); - retval = http_op.init_post(url, input_file, output_file); + retval = http_op.init_post(0, url, input_file, output_file); if (retval) return retval; gstate.http_ops->insert(&http_op); gui_http_op = op; @@ -77,7 +77,7 @@ int GUI_HTTP::do_rpc_post_str(GUI_HTTP_OP* op, char* url, char* req_buf, int len if (gui_http_state != GUI_HTTP_STATE_IDLE) { return ERR_RETRY; } - int retval = http_op.init_post2(url, req_buf, len, NULL, 0); + int retval = http_op.init_post2(0, url, req_buf, len, NULL, 0); if (retval) return retval; gstate.http_ops->insert(&http_op); gui_http_op = op; diff --git a/client/http_curl.cpp b/client/http_curl.cpp index 8591e09daa..d061bda437 100644 --- a/client/http_curl.cpp +++ b/client/http_curl.cpp @@ -217,10 +217,11 @@ int libcurl_debugfunction( return 0; } -void HTTP_OP::init() { +void HTTP_OP::init(PROJECT* p) { reset(); start_time = gstate.now; start_bytes_xferred = 0; + project = p; } void HTTP_OP::reset() { @@ -237,6 +238,7 @@ void HTTP_OP::reset() { connect_error = 0; bytes_xferred = 0; bSentHeader = false; + project = 0; close_socket(); } @@ -271,14 +273,14 @@ HTTP_OP::~HTTP_OP() { // output goes to the given file, starting at given offset // int HTTP_OP::init_get( - const char* url, const char* out, bool del_old_file, double off + PROJECT* p, const char* url, const char* out, bool del_old_file, double off ) { if (del_old_file) { unlink(out); } req1 = NULL; // not using req1, but init_post2 uses it file_offset = off; - HTTP_OP::init(); + HTTP_OP::init(p); // usually have an outfile on a get if (off != 0) { bytes_xferred = off; @@ -298,7 +300,7 @@ int HTTP_OP::init_get( // This is used for scheduler requests and account mgr RPCs. // int HTTP_OP::init_post( - const char* url, const char* in, const char* out + PROJECT* p, const char* url, const char* in, const char* out ) { int retval; double size; @@ -311,7 +313,7 @@ int HTTP_OP::init_post( if (retval) return retval; // this will return 0 or ERR_NOT_FOUND content_length = (int)size; } - HTTP_OP::init(); + HTTP_OP::init(p); http_op_type = HTTP_OP_POST; http_op_state = HTTP_STATE_CONNECTING; if (log_flags.http_debug) { @@ -327,12 +329,12 @@ int HTTP_OP::init_post( // This is used for file upload (both get_file_size and file_upload) // int HTTP_OP::init_post2( - const char* url, char* r1, int r1_len, const char* in, double offset + PROJECT* p, const char* url, char* r1, int r1_len, const char* in, double offset ) { int retval; double size; - init(); + init(p); req1 = r1; req1_len = r1_len; content_length = 0; diff --git a/client/http_curl.h b/client/http_curl.h index 9e4e52262b..1f3c1a485f 100644 --- a/client/http_curl.h +++ b/client/http_curl.h @@ -47,12 +47,15 @@ extern int curl_cleanup(); #define HTTP_STATE_CONNECTING 1 #define HTTP_STATE_DONE 2 +struct PROJECT; + class HTTP_OP { public: HTTP_OP(); ~HTTP_OP(); PROXY_INFO pi; + PROJECT* project; // associated project, if any char m_url[256]; char m_curl_ca_bundle_location[256]; @@ -144,7 +147,7 @@ public: // For example: notice RSS feed fetches void reset(); - void init(); + void init(PROJECT*); int get_ip_addr(int &ip_addr); void close_socket(); void close_file(); @@ -153,9 +156,15 @@ public: void handle_messages(CURLMsg*); //int init_head(const char* url); - int init_get(const char* url, const char* outfile, bool del_old_file, double offset=0); - int init_post(const char* url, const char* infile, const char* outfile); + int init_get( + PROJECT*, const char* url, const char* outfile, + bool del_old_file, double offset=0 + ); + int init_post( + PROJECT*, const char* url, const char* infile, const char* outfile + ); int init_post2( + PROJECT*, const char* url, char* req1, // first part of request. ALSO USED FOR REPLY int req1_len, diff --git a/client/scheduler_op.cpp b/client/scheduler_op.cpp index b4052d7adb..1853255f8a 100644 --- a/client/scheduler_op.cpp +++ b/client/scheduler_op.cpp @@ -275,7 +275,7 @@ int SCHEDULER_OP::start_rpc(PROJECT* p) { get_sched_reply_filename(*p, reply_file, sizeof(reply_file)); cur_proj = p; - retval = http_op.init_post(scheduler_url, request_file, reply_file); + retval = http_op.init_post(p, scheduler_url, request_file, reply_file); if (retval) { if (log_flags.sched_ops) { msg_printf(p, MSG_INFO, @@ -303,7 +303,7 @@ int SCHEDULER_OP::init_master_fetch(PROJECT* p) { msg_printf(p, MSG_INFO, "[sched_op] Fetching master file"); } cur_proj = p; - retval = http_op.init_get(p->master_url, master_filename, true); + retval = http_op.init_get(p, p->master_url, master_filename, true); if (retval) { if (log_flags.sched_ops) { msg_printf(p, MSG_INFO, diff --git a/client/sim.cpp b/client/sim.cpp index dab1438872..54a8cd41ea 100644 --- a/client/sim.cpp +++ b/client/sim.cpp @@ -25,8 +25,6 @@ // client_state.xml // global_prefs.xml // global_prefs_override.xml -// [--config_prefix dir/] -// Prefix of cc_config.xml // [--outfile_prefix X] // Prefix of output filenames; default is blank. // Output files are: @@ -73,7 +71,6 @@ #define SCHED_RETRY_DELAY_MAX (60*60*4) // 4 hours const char* infile_prefix = "./"; -const char* config_prefix = "./"; const char* outfile_prefix = "./"; #define TIMELINE_FNAME "timeline.html" @@ -115,7 +112,6 @@ int njobs; void usage(char* prog) { fprintf(stderr, "usage: %s\n" "[--infile_prefix F]\n" - "[--config_prefix F]\n" "[--outfile_prefix F]\n" "[--existing_jobs_only]\n" "[--duration X]\n" @@ -1314,11 +1310,24 @@ void cull_projects() { void do_client_simulation() { char buf[256], buf2[256]; int retval; + FILE* f; - sprintf(buf, "%s%s", config_prefix, CONFIG_FILE); + sprintf(buf, "%s%s", infile_prefix, CONFIG_FILE); config.defaults(); read_config_file(true, buf); + log_flags.init(); + sprintf(buf, "%s%s", outfile_prefix, "log_flags.xml"); + f = fopen(buf, "r"); + if (f) { + MIOFILE mf; + mf.init_file(f); + XML_PARSER xp(&mf); + xp.get_tag(); // skip open tag + log_flags.parse(xp); + fclose(f); + } + gstate.add_platform("client simulator"); sprintf(buf, "%s%s", infile_prefix, STATE_FILE_NAME); if (!boinc_file_exists(buf)) { @@ -1378,7 +1387,7 @@ void do_client_simulation() { sim_results.compute_figures_of_merit(); sprintf(buf, "%s%s", outfile_prefix, RESULTS_DAT_FNAME); - FILE* f = fopen(buf, "w"); + f = fopen(buf, "w"); sim_results.print(f); fclose(f); sprintf(buf, "%s%s", outfile_prefix, RESULTS_TXT_FNAME); @@ -1422,8 +1431,6 @@ int main(int argc, char** argv) { char* opt = argv[i++]; if (!strcmp(opt, "--infile_prefix")) { infile_prefix = argv[i++]; - } else if (!strcmp(opt, "--config_prefix")) { - config_prefix = argv[i++]; } else if (!strcmp(opt, "--outfile_prefix")) { outfile_prefix = argv[i++]; } else if (!strcmp(opt, "--existing_jobs_only")) { diff --git a/client/work_fetch.cpp b/client/work_fetch.cpp index e096326238..59f64f15ce 100644 --- a/client/work_fetch.cpp +++ b/client/work_fetch.cpp @@ -625,7 +625,7 @@ PROJECT* WORK_FETCH::choose_project() { } for (unsigned int i=0; iproject; + p = rp->project; p->sched_priority -= CURRENT_QUEUE_WEIGHT * rp->estimated_flops_remaining()/total_flops_remaining; } } diff --git a/doc/sim/sim_util.inc b/doc/sim/sim_util.inc index 4076e01de5..d49c312e49 100644 --- a/doc/sim/sim_util.inc +++ b/doc/sim/sim_util.inc @@ -74,7 +74,7 @@ class RESULT { // do a simulation // -function do_sim($in, $out, $policy, $config_prefix=null) { +function do_sim($in, $out, $policy) { $args = ""; if ($policy->existing_jobs_only) $args .= " --existing_jobs_only"; if ($policy->use_hyst_fetch) $args .= " --use_hyst_fetch"; @@ -84,8 +84,7 @@ function do_sim($in, $out, $policy, $config_prefix=null) { $args .= " --delta $policy->delta"; $args .= " --rec_half_life $policy->rec_half_life"; - $c = $config_prefix?"--config_prefix $config_prefix/":""; - $cmd = "./sim $args --infile_prefix $in/ --outfile_prefix $out/ $c"; + $cmd = "./sim $args --infile_prefix $in/ --outfile_prefix $out/"; //echo "cmd: $cmd\n"; die; system($cmd, $ret); if ($ret) { diff --git a/doc/sim/sim_web.php b/doc/sim/sim_web.php index 20a7dbf7ee..a497a8d386 100644 --- a/doc/sim/sim_web.php +++ b/doc/sim/sim_web.php @@ -116,7 +116,7 @@ function show_scenarios() {
  • Whether to use Hysteresis-based work fetch (the proposed policy for the 6.14 client) -
  • cc_config.xml: client configuration (optional). +
  • log flags The outputs of a simulation include
      @@ -194,6 +194,7 @@ function create_scenario_form() { row2("* client_state.xml", ""); row2("global_prefs.xml", ""); row2("global_prefs_override.xml", ""); + row2("cc_config.xml", ""); row2("* Description", ""); row2("", ""); echo " @@ -250,6 +251,10 @@ function create_scenario() { if (is_uploaded_file($gpo)) { move_uploaded_file($gpo, "$d/global_prefs_override.xml"); } + $ccc = $_FILES['cc_config']['tmp_name']; + if (is_uploaded_file($ccc)) { + move_uploaded_file($ccc, "$d/cc_config.xml"); + } file_put_contents("$d/userid", "$user->id"); file_put_contents("$d/description", $desc); mkdir("$d/simulations"); @@ -330,6 +335,14 @@ function show_scenario() { page_tail(); } +function log_flag_boxes() { + return " + CPU scheduling debug +
      Round-robin simulation info +
      Work fetch debug + "; +} + function simulation_form_short() { $scen = get_str("scen"); page_head("Do simulation"); @@ -346,7 +359,7 @@ function simulation_form_short() { "; row2("Duration", " seconds"); row2("Time step", " seconds"); - row2("cc_config.xml", ""); + row2("Log flags", log_flag_boxes()); row2("", ""); echo "\n"; end_table(); @@ -419,12 +432,21 @@ function simulation_action() { $policy->cpu_sched_rr_only = post_str("cpu_sched_rr_only", true); $policy->server_uses_workload = post_str("server_uses_workload", true); file_put_contents("$sim_path/userid", "$user->id"); - $cc = $_FILES['cc_config']['tmp_name']; - if (is_uploaded_file($cc)) { - move_uploaded_file($cc, "$sim_path/cc_config.xml"); - } - do_sim("scenarios/$scen", $sim_path, $policy, $sim_path); + $x = "\n"; + if (post_str("cpu_sched_debug", true)) { + $x .= "\n"; + } + if (post_str("rr_simulation", true)) { + $x .= "\n"; + } + if (post_str("work_fetch_debug", true)) { + $x .= "\n"; + } + $x .= "\n"; + file_put_contents("$sim_path/log_flags.xml", $x); + + do_sim("scenarios/$scen", $sim_path, $policy); header("Location: sim_web.php?action=show_simulation&scen=$scen&sim=$sim_name"); }