From 2385c00b6743df9ee18d3a6acbb74c4398602ff4 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 6 May 2011 12:33:12 +0000 Subject: [PATCH] - wrapper: tell the client when we checkpoint (else checkpoint_elapsed_time etc. don't get set) - make_project: enable update_stats by default - update_stats: add --min_age option svn path=/trunk/boinc/; revision=23509 --- checkin_notes | 13 +++++++ html/ops/bossa_example4_make_jobs.php | 6 ++-- samples/wrapper/wrapper.cpp | 2 ++ sched/update_stats.cpp | 49 +++++++++++++++++---------- tools/make_project | 6 ++-- 5 files changed, 54 insertions(+), 22 deletions(-) diff --git a/checkin_notes b/checkin_notes index a5e08d5a69..49b9582f14 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2806,3 +2806,16 @@ David 5 May 2011 html/user/ team_search.php + +David 6 May 2011 + - wrapper: tell the client when we checkpoint + (else checkpoint_elapsed_time etc. don't get set) + - make_project: enable update_stats by default + - update_stats: add --min_age option + + sched/ + update_stats.cpp + tools/ + make_project + samples/wrapper/ + wrapper.cpp diff --git a/html/ops/bossa_example4_make_jobs.php b/html/ops/bossa_example4_make_jobs.php index 0bd7828216..3cec12a050 100644 --- a/html/ops/bossa_example4_make_jobs.php +++ b/html/ops/bossa_example4_make_jobs.php @@ -21,6 +21,8 @@ // bossa_example4_make_jobs.php // --dir dir +$app_name = "bossa_example4"; + $cli_only = true; require_once("../inc/bossa.inc"); require_once("../inc/util_ops.inc"); @@ -64,7 +66,7 @@ if (!is_dir("../user/$dir")) { exit("../user/$dir is not a directory\n"); } -$appid = bossa_app_lookup("bossa_example4"); -if (!$appid) exit("No application 'bossa_example4'\n"); +$appid = bossa_app_lookup($app_name); +if (!$appid) exit("No application $app_name\n"); make_jobs($dir, $appid); diff --git a/samples/wrapper/wrapper.cpp b/samples/wrapper/wrapper.cpp index 5272636cde..afecf1b6fd 100644 --- a/samples/wrapper/wrapper.cpp +++ b/samples/wrapper/wrapper.cpp @@ -652,10 +652,12 @@ void send_status_message( // and how much CPU time has been used so far // void write_checkpoint(int ntasks_completed, double cpu) { + boinc_begin_critical_section(); FILE* f = fopen(CHECKPOINT_FILENAME, "w"); if (!f) return; fprintf(f, "%d %f\n", ntasks_completed, cpu); fclose(f); + boinc_checkpoint_completed(); } void read_checkpoint(int& ntasks_completed, double& cpu) { diff --git a/sched/update_stats.cpp b/sched/update_stats.cpp index 4f884f164e..9b806b353a 100644 --- a/sched/update_stats.cpp +++ b/sched/update_stats.cpp @@ -20,11 +20,17 @@ // These fields are updates as new credit is granted; // the purpose of this program is to decay credit of entities // that are inactive for long periods. -// Hence it should be run about once a day at most. +// Run it about once a day. // // Also updates the nusers field of teams // -// usage: update_stats [--update_teams] [--update_users] [--update_hosts] +// usage: update_stats args +// [--update_teams] +// [--update_users] +// [--update_hosts] +// [--min_age nsec] don't update items updated more recently than this + + #include "config.h" #include #include @@ -42,13 +48,12 @@ #include "sched_util.h" #include "sched_msgs.h" -#ifdef EINSTEIN_AT_HOME -#define UPDATE_INTERVAL 3600*24; -#else -#define UPDATE_INTERVAL 3600*24*4; -#endif +// If the item's average credit has been updated more recently than this, +// don't update it (optimizes performance). -double update_time_cutoff; +#define MIN_AGE 86400 + +double max_update_time; int update_users() { DB_USER user; @@ -57,7 +62,8 @@ int update_users() { double now = dtime(); while (1) { - retval = user.enumerate("where expavg_credit>0.1"); + sprintf(buf, "where expavg_credit>0.1 and expavg_time < %f", max_update_time); + retval = user.enumerate(buf); if (retval) { if (retval != ERR_DB_NOT_FOUND) { log_messages.printf(MSG_CRITICAL, "lost DB conn\n"); @@ -65,8 +71,6 @@ int update_users() { } break; } - - if (user.expavg_time > update_time_cutoff) continue; update_average( now, 0, 0, CREDIT_HALF_LIFE, user.expavg_credit, user.expavg_time ); @@ -90,7 +94,8 @@ int update_hosts() { double now = dtime(); while (1) { - retval = host.enumerate("where expavg_credit>0.1"); + sprintf(buf, "where expavg_credit>0.1 and expavg_time < %f", max_update_time); + retval = host.enumerate(buf); if (retval) { if (retval != ERR_DB_NOT_FOUND) { log_messages.printf(MSG_CRITICAL, "lost DB conn\n"); @@ -98,8 +103,6 @@ int update_hosts() { } break; } - - if (host.expavg_time > update_time_cutoff) continue; update_average( now, 0, 0, CREDIT_HALF_LIFE, host.expavg_credit, host.expavg_time ); @@ -169,7 +172,7 @@ int update_teams() { ); continue; } - if (team.expavg_time < update_time_cutoff) { + if (team.expavg_time < max_update_time) { update_average( now, 0, 0, CREDIT_HALF_LIFE, team.expavg_credit, team.expavg_time @@ -210,10 +213,11 @@ void usage(char *name) { int main(int argc, char** argv) { int retval, i; - bool do_update_teams = false, do_update_users = false; + bool do_update_teams = false; + bool do_update_users = false; bool do_update_hosts = false; - update_time_cutoff = time(0) - UPDATE_INTERVAL; + max_update_time = time(0) - MIN_AGE; check_stop_daemons(); @@ -224,6 +228,9 @@ int main(int argc, char** argv) { do_update_users = true; } else if (is_arg(argv[i], "update_hosts")) { do_update_hosts = true; + } else if (is_arg(argv[i], "min_age")) { + double x = atof(argv[++i]); + max_update_time = time(0) - x; } else if (!strcmp(argv[i], "-d")) { if (!argv[++i]) { log_messages.printf(MSG_CRITICAL, "%s requires an argument\n\n", argv[--i]); @@ -246,6 +253,14 @@ int main(int argc, char** argv) { } } + // if no do_update flags set, set them all + // + if (!do_update_teams && !do_update_users && !do_update_hosts) { + do_update_teams = true; + do_update_users = true; + do_update_hosts = true; + } + log_messages.printf(MSG_NORMAL, "Starting\n"); retval = config.parse_file(); diff --git a/tools/make_project b/tools/make_project index c180824cc4..a8f9f7358e 100755 --- a/tools/make_project +++ b/tools/make_project @@ -256,10 +256,10 @@ t.cmd = 'run_in_ops ./update_forum_activities.php' t.disabled = 1 t = project.config.tasks.make_node_and_append("task") -t.period = '7 days' +t.period = '1 days' t.output = 'update_stats.out' -t.cmd = 'update_stats --update_users --update_teams --update_hosts' -t.disabled = 1 +t.cmd = 'update_stats' +t.disabled = 0 t = project.config.tasks.make_node_and_append("task") t.period = '24 hours'