diff --git a/checkin_notes b/checkin_notes index 2a399b6ce2..0ba89f40a9 100755 --- a/checkin_notes +++ b/checkin_notes @@ -18040,3 +18040,16 @@ David 4 Oct 2004 db/ boinc_db.C,h db_base.C,h + +Lana 4 Oct 2004 + - changed most of the update() statements to update_field() statements + to improve server performance + + sched/ + assimilator.C + feeder.C + file_deleter.C + update_stats.C + validator.C + wu_check.C + diff --git a/client/client_state.C b/client/client_state.C index 8d5fb39eb1..319887ec7d 100644 --- a/client/client_state.C +++ b/client/client_state.C @@ -489,7 +489,8 @@ RESULT* CLIENT_STATE::lookup_result(PROJECT* p, const char* name) { } WORKUNIT* CLIENT_STATE::lookup_workunit(PROJECT* p, const char* name) { - for (unsigned int i=0; iproject == p && !strcmp(name, wup->name)) return wup; } @@ -666,7 +667,6 @@ int CLIENT_STATE::link_result(PROJECT* p, RESULT* rp) { void CLIENT_STATE::print_summary() { unsigned int i; int t; - if (!log_flags.state_debug) return; SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE); scope_messages.printf("CLIENT_STATE::print_summary(): Client state summary:\n"); diff --git a/sched/assimilator.C b/sched/assimilator.C index 079883dc10..98e903d170 100644 --- a/sched/assimilator.C +++ b/sched/assimilator.C @@ -55,7 +55,7 @@ bool do_pass(APP& app) { DB_RESULT canonical_result, result; bool did_something = false; char buf[256]; - // int retval; + int retval; check_stop_daemons(); @@ -79,9 +79,17 @@ bool do_pass(APP& app) { assimilate_handler(wu, results, canonical_result); - wu.assimilate_state = ASSIMILATE_DONE; - wu.transition_time = time(0); - wu.update(); + sprintf( + buf, "assimilate_state=%d, transition_time=%d", + ASSIMILATE_DONE, time(0) + ); + retval = wu.update_field(buf); + if (retval) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, + "[%s] update failed: %d\n", wu.name, retval + ); + exit(1); + } } return did_something; } diff --git a/sched/feeder.C b/sched/feeder.C index 727f8ff83d..4725d02ce5 100644 --- a/sched/feeder.C +++ b/sched/feeder.C @@ -142,6 +142,7 @@ int check_reread_trigger() { #ifdef REMOVE_INFEASIBLE_ENTRIES static int remove_infeasible(int i) { + char buf[256]; int retval; DB_RESULT result; DB_WORKUNIT wu; @@ -159,7 +160,11 @@ static int remove_infeasible(int i) { result.server_state = RESULT_SERVER_STATE_OVER; result.outcome = RESULT_OUTCOME_COULDNT_SEND; - retval = result.update(); + sprintf( + buf, "server_state=%d, outcome=%d", + result.server_state, result.outcome + ); + retval = result.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, @@ -169,7 +174,8 @@ static int remove_infeasible(int i) { return retval; } wu.transition_time = time(0); - retval = wu.update(); + sprintf(buf, "transition_time=%d", wu.transition_time); + retval = wu.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, diff --git a/sched/file_deleter.C b/sched/file_deleter.C index 9ae4725604..f8bde69b31 100644 --- a/sched/file_deleter.C +++ b/sched/file_deleter.C @@ -131,6 +131,7 @@ bool do_pass() { DB_RESULT result; bool did_something = false; char buf[256]; + int retval; check_stop_daemons(); @@ -139,7 +140,14 @@ bool do_pass() { did_something = true; wu_delete_files(wu); wu.file_delete_state = FILE_DELETE_DONE; - wu.update(); + sprintf(buf, "file_delete_state=%d", wu.file_delete_state); + retval= wu.update_field(buf); + if (retval) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, + "[%s] workunit failed to update file_delete_state with %d\n", + wu.name, retval + ); + } } sprintf(buf, "where file_delete_state=%d limit 1000", FILE_DELETE_READY); @@ -147,7 +155,14 @@ bool do_pass() { did_something = true; result_delete_files(result); result.file_delete_state = FILE_DELETE_DONE; - result.update(); + sprintf(buf, "file_delete_state=%d", result.file_delete_state); + retval= result.update_field(buf); + if (retval) { + log_messages.printf(SCHED_MSG_LOG::CRITICAL, + "[%s] result failed to update file_delete_state with %d\n", + result.name, retval + ); + } } return did_something; } diff --git a/sched/sample_trivial_validator.C b/sched/sample_trivial_validator.C index 0248b366c9..1735caf409 100644 --- a/sched/sample_trivial_validator.C +++ b/sched/sample_trivial_validator.C @@ -24,7 +24,7 @@ using std::vector; -static const double MIN_CPU_TIME = 10000; +static const double MIN_CPU_TIME = 0; int init_result_trivial(RESULT const& result, void*& data) { return 0; diff --git a/sched/update_stats.C b/sched/update_stats.C index 28ea00a684..dc37146b07 100644 --- a/sched/update_stats.C +++ b/sched/update_stats.C @@ -48,11 +48,16 @@ double update_time_cutoff; int update_users() { DB_USER user; int retval; + char buf[256]; while (!user.enumerate()) { if (user.expavg_time > update_time_cutoff) continue; update_average(0, 0, CREDIT_HALF_LIFE, user.expavg_credit, user.expavg_time); - retval = user.update(); + sprintf( + buf,"expavg_credit=%f, expavg_time=%f", + user.expavg_credit, user.expavg_time + ); + retval = user.update_field(buf); if (retval) { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "Can't update user %d\n", user.id); return retval; @@ -65,11 +70,16 @@ int update_users() { int update_hosts() { DB_HOST host; int retval; + char buf[256]; while (!host.enumerate()) { if (host.expavg_time > update_time_cutoff) continue; update_average(0, 0, CREDIT_HALF_LIFE, host.expavg_credit, host.expavg_time); - retval = host.update(); + sprintf( + buf,"expavg_credit=%f, expavg_time=%f", + host.expavg_credit, host.expavg_time + ); + retval = host.update_field(buf); if (retval) { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "Can't update host %d\n", host.id); return retval; @@ -103,6 +113,7 @@ int get_team_totals(TEAM& team) { int update_teams() { DB_TEAM team; int retval; + char buf[256]; while (!team.enumerate()) { retval = get_team_totals(team); @@ -118,7 +129,11 @@ int update_teams() { if (team.expavg_time < update_time_cutoff) { update_average(0, 0, CREDIT_HALF_LIFE, team.expavg_credit, team.expavg_time); } - retval = team.update(); + sprintf( + buf, "expavg_credit=%f, expavg_time=%f", + team.expavg_credit, team.expavg_time + ); + retval = team.update_field(buf); if (retval) { log_messages.printf(SCHED_MSG_LOG::CRITICAL, "Can't update team %d\n", team.id); return retval; diff --git a/sched/validator.C b/sched/validator.C index 3b3cba7644..1cfca89afa 100644 --- a/sched/validator.C +++ b/sched/validator.C @@ -63,6 +63,7 @@ int grant_credit(DB_RESULT& result, double credit) { DB_HOST host; DB_TEAM team; int retval; + char buf[256]; retval = host.lookup_id(result.hostid); if (retval) { @@ -85,7 +86,12 @@ int grant_credit(DB_RESULT& result, double credit) { user.total_credit += credit; update_average(result.sent_time, credit, CREDIT_HALF_LIFE, user.expavg_credit, user.expavg_time); - retval = user.update(); + sprintf( + buf, "total_credit=%f, expavg_credit=%f, expavg_time=%f", + user.total_credit, user.expavg_credit, + user.expavg_time + ); + retval = user.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, @@ -96,7 +102,12 @@ int grant_credit(DB_RESULT& result, double credit) { host.total_credit += credit; update_average(result.sent_time, credit, CREDIT_HALF_LIFE, host.expavg_credit, host.expavg_time); - retval = host.update(); + sprintf( + buf, "total_credit=%f, expavg_credit=%f, expavg_time=%f", + host.total_credit, host.expavg_credit, + host.expavg_time + ); + retval = host.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, @@ -117,7 +128,12 @@ int grant_credit(DB_RESULT& result, double credit) { } team.total_credit += credit; update_average(result.sent_time, credit, CREDIT_HALF_LIFE, team.expavg_credit, team.expavg_time); - retval = team.update(); + sprintf( + buf, "total_credit=%f, expavg_credit=%f, expavg_time=%f", + team.total_credit, team.expavg_credit, + team.expavg_time + ); + retval = team.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, @@ -224,7 +240,18 @@ void handle_wu(DB_WORKUNIT& wu) { ); } if (update_result) { - retval = result.update(); + sprintf( + buf, "validate_state=%d, granted_credit=%f", + result.validate_state, + result.granted_credit + ); + log_messages.printf( + SCHED_MSG_LOG::NORMAL, + "[RESULT#%d %s] granted_credit %f", + result.id, result.name, result.granted_credit + ); + + retval = result.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, @@ -332,7 +359,18 @@ void handle_wu(DB_WORKUNIT& wu) { ); } - retval = result.update(); + sprintf(buf, + "validate_state=%d, granted_credit=%f", + result.validate_state, + result.granted_credit + ); + log_messages.printf( + SCHED_MSG_LOG::NORMAL, + "[RESULT#%d %s] granted_credit %f", + result.id, result.name, result.granted_credit + ); + + retval = result.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, @@ -351,7 +389,12 @@ void handle_wu(DB_WORKUNIT& wu) { while (!result.enumerate(buf)) { result.server_state = RESULT_SERVER_STATE_OVER; result.outcome = RESULT_OUTCOME_DIDNT_NEED; - retval = result.update(); + sprintf(buf, + "server_state=%d, outcome=%d", + result.server_state, + result.outcome + ); + retval = result.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, @@ -383,7 +426,13 @@ void handle_wu(DB_WORKUNIT& wu) { // clear WU.need_validate // wu.need_validate = 0; - retval = wu.update(); + sprintf(buf, + "need_validate=%d, transition_time=%d, canonical_resultid=%d, + canonical_credit=%f, assimilate_state=%d", + wu.need_validate, wu.transition_time, wu.canonical_resultid, + wu.canonical_credit, wu.assimilate_state + ); + retval = wu.update_field(buf); if (retval) { log_messages.printf( SCHED_MSG_LOG::CRITICAL, diff --git a/sched/wu_check.C b/sched/wu_check.C index 3e43a78749..5f8238235f 100644 --- a/sched/wu_check.C +++ b/sched/wu_check.C @@ -51,6 +51,7 @@ int handle_result(DB_RESULT& result) { DB_WORKUNIT wu; int retval; char path[256]; + char buf[256]; FILE* f; retval = wu.lookup_id(result.workunitid); @@ -73,7 +74,18 @@ int handle_result(DB_RESULT& result) { if (result.server_state == RESULT_SERVER_STATE_UNSENT) { result.server_state = RESULT_SERVER_STATE_OVER; result.outcome = RESULT_OUTCOME_COULDNT_SEND; - result.update(); + sprintf( + buf,"server_state=%d, outcome=%d", + result.server_state, result.outcome + ); + retval = result.update_field(buf); + if (retval) { + printf( + "ERROR: can't update result %d\n", + result.id + ); + return 1; + } } } return 1;