Skip to content

Commit

Permalink
Merge pull request #3089 from BOINC/dpa_job_limit
Browse files Browse the repository at this point in the history
scheduler: check daily job limit on each job, not just when choosing AV
  • Loading branch information
lfield authored Apr 18, 2019
2 parents 1cfc426 + 5867396 commit b4c0616
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 18 deletions.
6 changes: 3 additions & 3 deletions sched/sched_keyword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ double keyword_score(int i) {
USER_KEYWORDS& uk = g_request->user_keywords;
if (uk.empty()) {
if (config.debug_keyword) {
log_messages.printf(MSG_NORMAL, "user has no keywords; returning 0\n");
log_messages.printf(MSG_NORMAL, "[keyword] user has no keywords; returning 0\n");
}
return 0;
}
Expand All @@ -66,15 +66,15 @@ double keyword_score(int i) {
WU_RESULT& wr = ssp->wu_results[i];
if (empty(wr.workunit.keywords)) {
if (config.debug_keyword) {
log_messages.printf(MSG_NORMAL, "job has no keywords; returning 0\n");
log_messages.printf(MSG_NORMAL, "[keyword] job has no keywords; returning 0\n");
}
return 0;
}
jk.parse_str(wr.workunit.keywords);
}
double s = keyword_score_aux(uk, jk);
if (config.debug_keyword) {
log_messages.printf(MSG_NORMAL, "keyword score: %f\n", s);
log_messages.printf(MSG_NORMAL, "[keyword] keyword score: %f\n", s);
}
return s;
}
Expand Down
11 changes: 11 additions & 0 deletions sched/sched_score.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,17 @@ void send_work_score_type(int rt) {
continue;
}

// check daily limit for (host, app version)
//
if (daily_quota_exceeded(job.bavp)) {
if (config.debug_quota) {
log_messages.printf(MSG_NORMAL,
"[quota] daily host/app version quota now exceeded\n"
);
}
break;
}

if (!sema_locked) {
lock_sema();
sema_locked = true;
Expand Down
34 changes: 20 additions & 14 deletions sched/sched_send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ const char* find_user_friendly_name(int appid) {
return "deprecated application";
}

// Called at start of request handling.
// 1) if there's a global jobs/day limit, enforce it using HAV limit
// 2) if last RPC was yesterday or earlier, clear n_jobs_today for HAV
//
static void update_quota(DB_HOST_APP_VERSION& hav) {
if (config.daily_result_quota) {
if (hav.max_jobs_per_day == 0) {
Expand Down Expand Up @@ -776,24 +780,26 @@ bool work_needed(bool locality_sched) {
}
}

// see if we've reached limits on in-progress jobs
// check user-specified project prefs limit on # of jobs in progress
//
int mj = g_wreq->project_prefs.max_jobs_in_progress;
if (mj && config.max_jobs_in_progress.project_limits.total.njobs >= mj) {
if (config.debug_send) {
log_messages.printf(MSG_NORMAL,
"[send] user project preferences job limit exceeded\n"
);
}
g_wreq->max_jobs_on_host_exceeded = true;
return false;
}

// check config.xml limits on in-progress jobs
//
bool some_type_allowed = false;

for (int i=0; i<NPROC_TYPES; i++) {
if (!have_apps(i)) continue;

// enforce project prefs limit on # of jobs in progress
//
bool proj_pref_exceeded = false;
int mj = g_wreq->project_prefs.max_jobs_in_progress;
if (mj) {
if (config.max_jobs_in_progress.project_limits.total.njobs >= mj) {
proj_pref_exceeded = true;
}
}

if (proj_pref_exceeded || config.max_jobs_in_progress.exceeded(NULL, i)) {
if (config.max_jobs_in_progress.exceeded(NULL, i)) {
if (config.debug_quota) {
log_messages.printf(MSG_NORMAL,
"[quota] reached limit on %s jobs in progress\n",
Expand All @@ -811,7 +817,7 @@ bool work_needed(bool locality_sched) {
if (!some_type_allowed) {
if (config.debug_send) {
log_messages.printf(MSG_NORMAL,
"[send] in-progress job limit exceeded\n"
"[send] config.xml max_jobs_in_progress limit exceeded\n"
);
}
g_wreq->max_jobs_on_host_exceeded = true;
Expand Down
9 changes: 8 additions & 1 deletion sched/sched_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ inline int scaled_max_jobs_per_day(DB_HOST_APP_VERSION& hav, HOST_USAGE& hu) {
return n;
}

// are we at the jobs/day limit for this (host, app version)?
// (if so don't use the app version)
//
inline bool daily_quota_exceeded(DB_ID_TYPE gavid, HOST_USAGE& hu) {
DB_HOST_APP_VERSION* havp = lookup_host_app_version(gavid);
if (!havp) return false;
Expand All @@ -147,6 +150,10 @@ inline bool daily_quota_exceeded(DB_ID_TYPE gavid, HOST_USAGE& hu) {
return false;
}

bool daily_quota_exceeded(BEST_APP_VERSION* bavp) {
return daily_quota_exceeded(bavp->avp->id, bavp->host_usage);
}

// scan through client's anonymous apps and pick the best one
//
CLIENT_APP_VERSION* get_app_version_anonymous(
Expand Down Expand Up @@ -804,7 +811,7 @@ BEST_APP_VERSION* get_app_version(
if (daily_quota_exceeded(av.id, host_usage)) {
if (config.debug_version_select) {
log_messages.printf(MSG_NORMAL,
"[version] [AV#%lu] daily quota exceeded\n", av.id
"[version] [AV#%lu] daily HAV quota exceeded\n", av.id
);
}
continue;
Expand Down
1 change: 1 addition & 0 deletions sched/sched_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ extern BEST_APP_VERSION* get_app_version(
const WORKUNIT&, bool check_req, bool reliable_only
);
extern void estimate_flops_anon_platform();
extern bool daily_quota_exceeded(BEST_APP_VERSION*);

0 comments on commit b4c0616

Please sign in to comment.