From 6e73fe56caf7e87a1f3e4dad646e6ba1dcbbe8bf Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 27 Jan 2006 19:50:43 +0000 Subject: [PATCH] debt calculation svn path=/trunk/boinc/; revision=9329 --- checkin_notes | 6 ++++++ client/client_state.h | 5 +++++ client/client_types.h | 20 +++++++++++++------- client/cs_apps.C | 19 ++++++++++++------- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/checkin_notes b/checkin_notes index f3a0dca5a8..57a42990b6 100755 --- a/checkin_notes +++ b/checkin_notes @@ -1085,3 +1085,9 @@ David 27 Jan 2006 AccountManagerPropertiesPage.cpp CompletionRemovePage.cpp CompletionUpdatePage.cpp + +David 27 Jan 2006 + - core client: fix calculation of STD/LTD + + client/ + cs_apps.C diff --git a/client/client_state.h b/client/client_state.h index 2f4e9dc723..e1f34ab493 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -448,4 +448,9 @@ extern double calculate_exponential_backoff( int n, double MIN, double MAX ); +#ifdef NEW_CPU_SCHED +class CPU_SCHEDULER { +}; +#endif + #endif diff --git a/client/client_types.h b/client/client_types.h index be63938215..cf543e005c 100644 --- a/client/client_types.h +++ b/client/client_types.h @@ -295,6 +295,9 @@ public: bool checked; // temporary used when scanning projects +#ifdef NEW_CPU_SCHED + void compute_cpu_share_needed(); +#endif // vars related to file-transfer backoff // file_xfer_failures_up: count of consecutive upload failures @@ -435,13 +438,6 @@ struct RESULT { // this may be NULL after result is finished PROJECT* project; - // temporaries used in CLIENT_STATE::rr_misses_deadline(): - double rrsim_cpu_left; - double rrsim_finish_delay; - - bool already_selected; - // used to keep cpu scheduler from scheduling a result twice - // transient; used only within schedule_cpus() void clear(); int parse_server(MIOFILE&); int parse_state(MIOFILE&); @@ -452,6 +448,9 @@ struct RESULT { void reset_files(); FILE_REF* lookup_file(FILE_INFO*); FILE_INFO* lookup_file_logical(const char*); + + // stuff related to CPU scheduling + double estimated_cpu_time(); double estimated_cpu_time_uncorrected(); double estimated_cpu_time_remaining(); @@ -461,6 +460,13 @@ struct RESULT { bool runnable_soon(); // downloading or downloaded, // not finished, suspended, project not suspended + // temporaries used in CLIENT_STATE::rr_misses_deadline(): + double rrsim_cpu_left; + double rrsim_finish_delay; + bool already_selected; + // used to keep cpu scheduler from scheduling a result twice + // transient; used only within schedule_cpus() + }; #endif diff --git a/client/cs_apps.C b/client/cs_apps.C index b17ff7178e..369129b631 100644 --- a/client/cs_apps.C +++ b/client/cs_apps.C @@ -420,7 +420,7 @@ void CLIENT_STATE::adjust_debts() { double total_long_term_debt = 0; double total_short_term_debt = 0; double prrs, rrs; - int nprojects = 0; + int nprojects=0, nrprojects=0; PROJECT *p; double share_frac; double wall_cpu_time = gstate.now - cpu_sched_last_time; @@ -459,21 +459,21 @@ void CLIENT_STATE::adjust_debts() { for (i=0; inon_cpu_intensive) continue; - nprojects++; // adjust long-term debts // if (p->potentially_runnable()) { + nprojects++; share_frac = p->resource_share/prrs; p->long_term_debt += share_frac*total_wall_cpu_time_this_period - - p->wall_cpu_time_this_period - ; + - p->wall_cpu_time_this_period; + total_long_term_debt += p->long_term_debt; } - total_long_term_debt += p->long_term_debt; // adjust short term debts // if (p->runnable()) { + nrprojects++; share_frac = p->resource_share/rrs; p->short_term_debt += share_frac*total_wall_cpu_time_this_period - p->wall_cpu_time_this_period @@ -497,7 +497,10 @@ void CLIENT_STATE::adjust_debts() { // normalize so mean is zero, and limit abs value at MAX_DEBT // double avg_long_term_debt = total_long_term_debt / nprojects; - double avg_short_term_debt = total_short_term_debt / nprojects; + double avg_short_term_debt = 0; + if (nrprojects) { + total_short_term_debt / nrprojects; + } for (i=0; inon_cpu_intensive) continue; @@ -512,7 +515,9 @@ void CLIENT_STATE::adjust_debts() { p->anticipated_debt = p->short_term_debt; //msg_printf(p, MSG_INFO, "debt %f", p->short_term_debt); } - p->long_term_debt -= avg_long_term_debt; + if (p->potentially_runnable()) { + p->long_term_debt -= avg_long_term_debt; + } } }