diff --git a/checkin_notes b/checkin_notes index bb7bcdc5c3..2293ea3d86 100755 --- a/checkin_notes +++ b/checkin_notes @@ -25153,3 +25153,13 @@ David 22 Feb 2005 create_account_action.php edit_user_info_action.php team_edit_form.php + +David 22 Feb 2005 + - Validator: added a "-mod n i" cmdline option. + Processes only WUs with ID mod n == i. + Lets you run multiple copies of validators for greater throughput. + + db/ + boinc_db.C,h + sched/ + validator.C diff --git a/db/boinc_db.C b/db/boinc_db.C index 0e1e692c33..f4602841c9 100644 --- a/db/boinc_db.C +++ b/db/boinc_db.C @@ -853,10 +853,11 @@ void VALIDATOR_ITEM::parse(MYSQL_ROW& r) { int DB_VALIDATOR_ITEM_SET::enumerate( int appid, int nresult_limit, + int wu_id_modulus, int wu_id_remainder, std::vector& items ) { int x; - char query[MAX_QUERY_LEN]; + char query[MAX_QUERY_LEN], mod_clause[256]; char priority[256]; MYSQL_ROW row; VALIDATOR_ITEM new_item; @@ -865,6 +866,15 @@ int DB_VALIDATOR_ITEM_SET::enumerate( strcpy(priority, ""); if (db->mysql) strcpy(priority, "HIGH_PRIORITY"); + if (wu_id_modulus) { + sprintf(mod_clause, + " and id %% %d = %d ", + wu_id_modulus, wu_id_remainder + ); + } else { + strcpy(mod_clause, ""); + } + sprintf(query, "SELECT %s " " wu.id, " @@ -899,10 +909,10 @@ int DB_VALIDATOR_ITEM_SET::enumerate( " workunit AS wu " " LEFT JOIN result AS res ON wu.id = res.workunitid " "WHERE " - " wu.appid = %d and wu.need_validate > 0 " + " wu.appid = %d and wu.need_validate > 0 %s " "LIMIT " " %d ", - priority, appid, nresult_limit + priority, appid, mod_clause, nresult_limit ); x = db->do_query(query); diff --git a/db/boinc_db.h b/db/boinc_db.h index 6296ae3b09..92d1190428 100755 --- a/db/boinc_db.h +++ b/db/boinc_db.h @@ -615,6 +615,8 @@ public: int enumerate( int appid, int nresult_limit, + int wu_id_modulus, + int wu_id_remainder, std::vector& items ); int update_result(RESULT&); diff --git a/sched/validator.C b/sched/validator.C index dd7f4fc461..0123aa076d 100644 --- a/sched/validator.C +++ b/sched/validator.C @@ -17,13 +17,13 @@ // or write to the Free Software Foundation, Inc., // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// validator - check and validate new results, and grant credit +// validator - check and validate results, and grant credit // -app appname // [-d debug_level] -// [-one_pass_N_WU N] // Validate only N WU in one pass, then exit -// [-one_pass] // make one pass through WU table, then exit -// [-asynch] // fork, run in separate process +// [-one_pass_N_WU N] // Validate only N WU in one pass, then exit +// [-one_pass] // make one pass through WU table, then exit +// [-asynch] // fork, run in separate process +// [-mod n i] // process only WUs with (id mod n) == i // // This program must be linked with two project-specific functions: // check_set() and check_pair(). @@ -58,6 +58,10 @@ extern int check_pair( SCHED_CONFIG config; char app_name[256]; +int wu_id_modulus=0; +int wu_id_remainder=0; +int one_pass_N_WU=0; + // here when a result has been validated; // grant credit to host, user and team @@ -466,8 +470,6 @@ void handle_wu( } } -int one_pass_N_WU=0; - // make one pass through the workunits with need_validate set. // return true if there were any // @@ -475,10 +477,17 @@ bool do_validate_scan(APP& app) { DB_VALIDATOR_ITEM_SET validator; std::vector items; bool found=false; + int retval; // loop over entries that need to be checked // - while (!validator.enumerate(app.id, one_pass_N_WU?one_pass_N_WU:SELECT_LIMIT, items)) { + while (1) { + retval = validator.enumerate( + app.id, one_pass_N_WU?one_pass_N_WU:SELECT_LIMIT, + wu_id_modulus, wu_id_remainder, + items + ); + if (retval) break; handle_wu(validator, items); found = true; } @@ -538,6 +547,9 @@ int main(int argc, char** argv) { } else if (!strcmp(argv[i], "-d")) { boinc_validator_debuglevel=atoi(argv[++i]); log_messages.set_debug_level(boinc_validator_debuglevel); + } else if (!strcmp(argv[i], "-mod")) { + wu_id_modulus = atoi(argv[++i]); + wu_id_remainder = atoi(argv[++i]); } else { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "unrecognized arg: %s\n", argv[i]); exit(1); @@ -558,13 +570,12 @@ int main(int argc, char** argv) { } } - // // Call lock_file after fork(), because file locks are not always inherited - // if (lock_file(LOCKFILE)) { - // log_messages.printf(SCHED_MSG_LOG::NORMAL, "Another copy of validate is already running\n"); - // exit(1); - // } - // write_pid_file(PIDFILE); log_messages.printf(SCHED_MSG_LOG::NORMAL, "Starting validator\n"); + if (wu_id_modulus) { + log_messages.printf(SCHED_MSG_LOG::NORMAL, + "Modulus %d, remainder %d\n", wu_id_modulus, wu_id_remainder + ); + } install_stop_signal_handler();