- client: code cleanup. Some variable/function/constant names

contained "debt" when they actually refer to REC.
    Change these names to use "rec".
This commit is contained in:
David Anderson 2013-03-24 11:22:01 -07:00
parent 210b0ca39f
commit b93e80c6f5
10 changed files with 72 additions and 69 deletions

View File

@ -84,7 +84,6 @@ Commands:\n\
--read_cc_config\n\
--read_global_prefs_override\n\
--run_benchmarks\n\
--set_debts URL1 std1 ltd1 [URL2 std2 ltd2 ...]\n\
--set_gpu_mode mode duration set GPU run mode for given duration\n\
mode = always | auto | never\n\
--set_network_mode mode duration set network mode for given duration\n\

View File

@ -134,7 +134,7 @@ CLIENT_STATE::CLIENT_STATE()
cant_write_state_file = false;
benchmarks_running = false;
debt_interval_start = 0;
rec_interval_start = 0;
retry_shmem_time = 0;
must_schedule_cpus = true;
no_gui_rpc = false;
@ -571,7 +571,7 @@ int CLIENT_STATE::init() {
request_schedule_cpus("Startup");
request_work_fetch("Startup");
work_fetch.init();
debt_interval_start = now;
rec_interval_start = now;
// set up the project and slot directories
//
@ -1994,7 +1994,7 @@ int CLIENT_STATE::detach_project(PROJECT* project) {
// e.g. flush buffers, but why bother)
//
int CLIENT_STATE::quit_activities() {
// calculate long-term debts (for state file)
// calculate REC (for state file)
//
adjust_rec();

View File

@ -275,14 +275,14 @@ struct CLIENT_STATE {
double potentially_runnable_resource_share();
double nearly_runnable_resource_share();
double fetchable_resource_share();
double debt_interval_start;
double total_cpu_time_this_debt_interval;
double rec_interval_start;
double total_cpu_time_this_rec_interval;
bool must_enforce_cpu_schedule;
bool must_schedule_cpus;
bool must_check_work_fetch;
void assign_results_to_projects();
RESULT* largest_debt_project_best_result();
void reset_debt_accounting();
RESULT* highest_prio_project_best_result();
void reset_rec_accounting();
bool schedule_cpus();
void make_run_list(vector<RESULT*>&);
bool enforce_run_list(vector<RESULT*>&);
@ -561,9 +561,9 @@ extern double calculate_exponential_backoff(
#define CPU_SCHED_PERIOD 60
// do CPU schedule at least this often
#define DEBT_ADJUST_PERIOD CPU_SCHED_PERIOD
// debt is adjusted at least this often,
// since adjust_debts() is called from enforce_schedule()
#define REC_ADJUST_PERIOD CPU_SCHED_PERIOD
// REC is adjusted at least this often,
// since adjust_rec() is called from enforce_schedule()
#define DEADLINE_CUSHION 0
// try to finish jobs this much in advance of their deadline
@ -591,9 +591,6 @@ extern double calculate_exponential_backoff(
#define DAILY_XFER_HISTORY_PERIOD 60
#define MAX_STD (86400)
// maximum short-term debt
#define ACCT_MGR_MIN_BACKOFF 600
#define ACCT_MGR_MAX_BACKOFF 86400
// min/max account manager RPC backoff

View File

@ -376,9 +376,9 @@ void CLIENT_STATE::assign_results_to_projects() {
// find the project P with the largest priority,
// and return its next runnable result
//
RESULT* CLIENT_STATE::largest_debt_project_best_result() {
RESULT* CLIENT_STATE::highest_prio_project_best_result() {
PROJECT *best_project = NULL;
double best_debt = 0;
double best_prio = 0;
bool first = true;
unsigned int i;
@ -386,10 +386,10 @@ RESULT* CLIENT_STATE::largest_debt_project_best_result() {
PROJECT* p = projects[i];
if (!p->next_runnable_result) continue;
if (p->non_cpu_intensive) continue;
if (first || p->sched_priority > best_debt) {
if (first || p->sched_priority > best_prio) {
first = false;
best_project = p;
best_debt = p->sched_priority;
best_prio = p->sched_priority;
}
}
if (!best_project) return NULL;
@ -526,18 +526,18 @@ static RESULT* earliest_deadline_result(int rsc_type) {
return best_result;
}
void CLIENT_STATE::reset_debt_accounting() {
void CLIENT_STATE::reset_rec_accounting() {
unsigned int i;
for (i=0; i<projects.size(); i++) {
PROJECT* p = projects[i];
for (int j=0; j<coprocs.n_rsc; j++) {
p->rsc_pwf[j].reset_debt_accounting();
p->rsc_pwf[j].reset_rec_accounting();
}
}
for (int j=0; j<coprocs.n_rsc; j++) {
rsc_work_fetch[j].reset_debt_accounting();
rsc_work_fetch[j].reset_rec_accounting();
}
debt_interval_start = now;
rec_interval_start = now;
}
// update REC (recent estimated credit)
@ -550,7 +550,7 @@ static void update_rec() {
double x = 0;
for (int j=0; j<coprocs.n_rsc; j++) {
x += p->rsc_pwf[j].secs_this_debt_interval * f * rsc_work_fetch[j].relative_speed;
x += p->rsc_pwf[j].secs_this_rec_interval * f * rsc_work_fetch[j].relative_speed;
}
x *= COBBLESTONE_SCALE;
double old = p->pwf.rec;
@ -558,12 +558,12 @@ static void update_rec() {
// start averages at zero
//
if (p->pwf.rec_time == 0) {
p->pwf.rec_time = gstate.debt_interval_start;
p->pwf.rec_time = gstate.rec_interval_start;
}
update_average(
gstate.now,
gstate.debt_interval_start,
gstate.rec_interval_start,
x,
config.rec_half_life,
p->pwf.rec,
@ -571,7 +571,7 @@ static void update_rec() {
);
if (log_flags.priority_debug) {
double dt = gstate.now - gstate.debt_interval_start;
double dt = gstate.now - gstate.rec_interval_start;
msg_printf(p, MSG_INFO,
"[prio] recent est credit: %.2fG in %.2f sec, %f + %f ->%f",
x, dt, old, p->pwf.rec-old, p->pwf.rec
@ -670,26 +670,28 @@ void adjust_rec_sched(RESULT* rp) {
// make this a variable so simulator can change it
//
double debt_adjust_period = DEBT_ADJUST_PERIOD;
double rec_adjust_period = REC_ADJUST_PERIOD;
// adjust project REC
//
void CLIENT_STATE::adjust_rec() {
unsigned int i;
double elapsed_time = now - debt_interval_start;
double elapsed_time = now - rec_interval_start;
// If the elapsed time is more than 2*DEBT_ADJUST_PERIOD
// it must be because the host was suspended for a long time.
// In this case, ignore the last period
// If the elapsed time is negative or more than 2*REC_ADJUST_PERIOD
// it must be because either
// - the system clock was changed.
// - the host was suspended for a long time.
// In either case, ignore the last period
//
if (elapsed_time > 2*debt_adjust_period || elapsed_time < 0) {
if (elapsed_time > 2*rec_adjust_period || elapsed_time < 0) {
if (log_flags.priority_debug) {
msg_printf(NULL, MSG_INFO,
"[priority] adjust_rec: elapsed time (%d) longer than sched enforce period(%d). Ignoring this period.",
(int)elapsed_time, (int)debt_adjust_period
"[priority] adjust_rec: elapsed time (%.0f) negative or longer than sched enforce period(%.0f). Ignoring this period.",
elapsed_time, rec_adjust_period
);
}
reset_debt_accounting();
reset_rec_accounting();
return;
}
@ -711,7 +713,7 @@ void CLIENT_STATE::adjust_rec() {
update_rec();
reset_debt_accounting();
reset_rec_accounting();
}
@ -915,11 +917,11 @@ void CLIENT_STATE::make_run_list(vector<RESULT*>& run_list) {
}
#endif
// Next, choose CPU jobs from projects with large debt
// Next, choose CPU jobs from highest priority projects
//
while (!proc_rsc.stop_scan_cpu()) {
assign_results_to_projects();
rp = largest_debt_project_best_result();
rp = highest_prio_project_best_result();
if (!rp) break;
atp = lookup_active_task_by_result(rp);
if (!proc_rsc.can_schedule(rp, atp)) continue;

View File

@ -71,7 +71,7 @@ bool CLIENT_STATE::handle_finished_apps() {
}
app_finished(*atp);
if (!action) {
adjust_rec(); // update debts before erasing ACTIVE_TASK
adjust_rec(); // update REC before erasing ACTIVE_TASK
}
iter = active_tasks.active_tasks.erase(iter);
delete atp;
@ -203,7 +203,7 @@ int CLIENT_STATE::app_finished(ACTIVE_TASK& at) {
rp->project->update_duration_correction_factor(&at);
}
double elapsed_time = now - debt_interval_start;
double elapsed_time = now - rec_interval_start;
work_fetch.accumulate_inst_sec(&at, elapsed_time);
return 0;

View File

@ -83,13 +83,13 @@ const char* outfile_prefix = "./";
#define RESULTS_DAT_FNAME "results.dat"
#define RESULTS_TXT_FNAME "results.txt"
#define SUMMARY_FNAME "summary.txt"
#define DEBT_FNAME "debt.dat"
#define REC_FNAME "rec.dat"
bool user_active;
double duration = 86400, delta = 60;
FILE* logfile;
FILE* html_out;
FILE* debt_file;
FILE* rec_file;
FILE* index_file;
FILE* summary_file;
char log_filename[256];
@ -110,7 +110,7 @@ bool active;
bool gpu_active;
bool connected;
extern double debt_adjust_period;
extern double rec_adjust_period;
SIM_RESULTS sim_results;
int njobs;
@ -1004,12 +1004,12 @@ void set_initial_rec() {
}
void write_recs() {
fprintf(debt_file, "%f ", gstate.now);
fprintf(rec_file, "%f ", gstate.now);
for (unsigned int i=0; i<gstate.projects.size(); i++) {
PROJECT* p = gstate.projects[i];
fprintf(debt_file, "%f ", p->pwf.rec);
fprintf(rec_file, "%f ", p->pwf.rec);
}
fprintf(debt_file, "\n");
fprintf(rec_file, "\n");
}
void make_graph(const char* title, const char* fname, int field) {
@ -1026,7 +1026,7 @@ void make_graph(const char* title, const char* fname, int field) {
);
for (unsigned int i=0; i<gstate.projects.size(); i++) {
PROJECT* p = gstate.projects[i];
fprintf(f, "\"%sdebt.dat\" using 1:%d title \"%s\" with lines%s",
fprintf(f, "\"%srec.dat\" using 1:%d title \"%s\" with lines%s",
outfile_prefix, 2+i+field, p->project_name,
(i==gstate.projects.size()-1)?"\n":", \\\n"
);
@ -1289,7 +1289,7 @@ void get_app_params() {
);
}
// zero backoffs and debts.
// zero backoffs and REC
//
void clear_backoff() {
unsigned int i;
@ -1461,7 +1461,7 @@ void do_client_simulation() {
//set_initial_rec();
debt_adjust_period = delta;
rec_adjust_period = delta;
gstate.request_work_fetch("init");
simulate();
@ -1498,7 +1498,7 @@ void do_client_simulation() {
);
print_project_results(summary_file);
fclose(debt_file);
fclose(rec_file);
make_graph("REC", "rec", 0);
}
@ -1558,8 +1558,8 @@ int main(int argc, char** argv) {
}
setbuf(logfile, 0);
sprintf(buf, "%s%s", outfile_prefix, DEBT_FNAME);
debt_file = fopen(buf, "w");
sprintf(buf, "%s%s", outfile_prefix, REC_FNAME);
rec_file = fopen(buf, "w");
sprintf(buf, "%s%s", outfile_prefix, SUMMARY_FNAME);
summary_file = fopen(buf, "w");

View File

@ -698,13 +698,13 @@ void WORK_FETCH::accumulate_inst_sec(ACTIVE_TASK* atp, double dt) {
APP_VERSION* avp = atp->result->avp;
PROJECT* p = atp->result->project;
double x = dt*avp->avg_ncpus;
p->rsc_pwf[0].secs_this_debt_interval += x;
rsc_work_fetch[0].secs_this_debt_interval += x;
p->rsc_pwf[0].secs_this_rec_interval += x;
rsc_work_fetch[0].secs_this_rec_interval += x;
int rt = avp->gpu_usage.rsc_type;
if (rt) {
x = dt*avp->gpu_usage.usage;
p->rsc_pwf[rt].secs_this_debt_interval += x;
rsc_work_fetch[rt].secs_this_debt_interval += x;
p->rsc_pwf[rt].secs_this_rec_interval += x;
rsc_work_fetch[rt].secs_this_rec_interval += x;
}
}

View File

@ -80,10 +80,10 @@ struct RSC_PROJECT_WORK_FETCH {
double backoff_time;
double backoff_interval;
// the following used by debt accounting
double secs_this_debt_interval;
inline void reset_debt_accounting() {
secs_this_debt_interval = 0;
// the following used by REC accounting
double secs_this_rec_interval;
inline void reset_rec_accounting() {
secs_this_rec_interval = 0;
}
double queue_est;
// an estimate of instance-secs of queued work;
@ -111,7 +111,7 @@ struct RSC_PROJECT_WORK_FETCH {
RSC_PROJECT_WORK_FETCH() {
backoff_time = 0;
backoff_interval = 0;
secs_this_debt_interval = 0;
secs_this_rec_interval = 0;
queue_est = 0;
anon_skip = false;
fetchable_share = 0;
@ -233,10 +233,10 @@ struct RSC_WORK_FETCH {
double req_secs;
double req_instances;
// debt accounting
double secs_this_debt_interval;
inline void reset_debt_accounting() {
this->secs_this_debt_interval = 0;
// REC accounting
double secs_this_rec_interval;
inline void reset_rec_accounting() {
this->secs_this_rec_interval = 0;
}
void rr_init();

View File

@ -491,6 +491,12 @@ function get_templates($r) {
$app_name = (string)($r->app_name);
if ($app_name) {
$app = get_app($app_name);
} else {
$job_name = (string)($r->job_name);
$wu = get_wu($job_name);
$app = BoincApp::lookup_id($wu->appid);
}
list($user, $user_submit) = authenticate_user($r, $app);
$in = file_get_contents("../../templates/".$app->name."_in");
$out = file_get_contents("../../templates/".$app->name."_out");

View File

@ -22,9 +22,8 @@
//
// 1) The use of "CUDA" is misleading; it really means "NVIDIA GPU".
// 2) The design treats each resource type as a pool of identical devices;
// for example, there is a single "CUDA long-term debt" per project,
// and a scheduler request contains a request (#instances, instance-seconds)
// for CUDA jobs.
// for example, a scheduler request contains a request
// (#instances, instance-seconds) for CUDA jobs.
// In reality, the instances of a resource type can have different properties:
// In the case of CUDA, "compute capability", driver version, RAM, speed, etc.
// How to resolve this discrepancy?
@ -39,7 +38,7 @@
// the jobs fail, the host is punished, etc.
//
// We could treat each GPU has a separate resource,
// with its own set of debts, backoffs, etc.
// with its own backoffs, etc.
// However, this would imply tying jobs to instances,
// which is undesirable from a scheduling viewpoint.
// It would also be a big code change in both client and server.