mirror of https://github.com/BOINC/boinc.git
Client: don't use sub-second CPU throttling
I forgot that the wrapper has a 1-second poll for suspend and resume, so sub-second throttling won't work properly for wrapper apps. Revert to a variant of the old scheme, in which the min of the suspended and resumed periods is 1 sec. Also, fix task start/suspend/resume log messages.
This commit is contained in:
parent
bd19068600
commit
38e83a3cd7
|
@ -1031,7 +1031,6 @@ void ACTIVE_TASK::set_task_state(int val, const char* where) {
|
|||
|
||||
#ifndef SIM
|
||||
#ifdef NEW_CPU_THROTTLE
|
||||
#define THROTTLE_PERIOD 1.
|
||||
#ifdef _WIN32
|
||||
DWORD WINAPI throttler(LPVOID) {
|
||||
#else
|
||||
|
@ -1049,8 +1048,23 @@ void* throttler(void*) {
|
|||
boinc_sleep(10);
|
||||
continue;
|
||||
}
|
||||
double on = THROTTLE_PERIOD * gstate.global_prefs.cpu_usage_limit / 100;
|
||||
double off = THROTTLE_PERIOD - on;
|
||||
double on, off, on_frac = gstate.global_prefs.cpu_usage_limit / 100;
|
||||
#if 0
|
||||
// sub-second CPU throttling
|
||||
#define THROTTLE_PERIOD 1.
|
||||
on = THROTTLE_PERIOD * on_frac;
|
||||
off = THROTTLE_PERIOD - on;
|
||||
#else
|
||||
// throttling w/ at least 1 sec between suspend/resume
|
||||
if (on_frac > .5) {
|
||||
off = 1;
|
||||
on = on_frac/(1.-on_frac);
|
||||
} else {
|
||||
on = 1;
|
||||
off = (1.-on_frac)/on_frac;
|
||||
}
|
||||
#endif
|
||||
|
||||
gstate.tasks_throttled = true;
|
||||
gstate.active_tasks.suspend_all(SUSPEND_REASON_CPU_THROTTLE);
|
||||
client_mutex.unlock();
|
||||
|
|
|
@ -1129,7 +1129,7 @@ void ACTIVE_TASK_SET::unsuspend_all(int reason) {
|
|||
atp = active_tasks[i];
|
||||
if (atp->scheduler_state != CPU_SCHED_SCHEDULED) continue;
|
||||
if (atp->task_state() == PROCESS_UNINITIALIZED) {
|
||||
if (atp->start()) {
|
||||
if (atp->resume_or_start(false)) {
|
||||
msg_printf(atp->wup->project, MSG_INTERNAL_ERROR,
|
||||
"Couldn't restart task %s", atp->result->name
|
||||
);
|
||||
|
|
|
@ -1143,14 +1143,19 @@ int ACTIVE_TASK::resume_or_start(bool first_time) {
|
|||
);
|
||||
return 0;
|
||||
}
|
||||
if (log_flags.task) {
|
||||
if (log_flags.task && first_time) {
|
||||
msg_printf(result->project, MSG_INFO,
|
||||
"Starting task %s", result->name
|
||||
);
|
||||
}
|
||||
if (log_flags.cpu_sched) {
|
||||
char buf[256];
|
||||
strcpy(buf, "");
|
||||
if (strlen(app_version->plan_class)) {
|
||||
sprintf(buf, " (%s)", app_version->plan_class);
|
||||
}
|
||||
msg_printf(result->project, MSG_INFO,
|
||||
"%s task %s using %s version %d%s in slot %d",
|
||||
"[cpu_sched] %s task %s using %s version %d%s in slot %d",
|
||||
str,
|
||||
result->name,
|
||||
app_version->app->name,
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#define _CLIENT_STATE_
|
||||
|
||||
#define NEW_CPU_THROTTLE
|
||||
// do CPU throttling using a separate thread.
|
||||
// This makes it possible to throttle faster than the client's 1-sec poll period
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <string>
|
||||
|
|
|
@ -444,7 +444,10 @@ RESULT* first_coproc_result(int rsc_type) {
|
|||
for (i=0; i<gstate.results.size(); i++) {
|
||||
RESULT* rp = gstate.results[i];
|
||||
if (rp->resource_type() != rsc_type) continue;
|
||||
if (!rp->runnable()) continue;
|
||||
if (!rp->runnable()) {
|
||||
//msg_printf(rp->project, MSG_INFO, "not runnable: %s", rp->name);
|
||||
continue;
|
||||
}
|
||||
if (rp->non_cpu_intensive()) continue;
|
||||
if (rp->already_selected) continue;
|
||||
prio = rp->project->sched_priority;
|
||||
|
|
|
@ -336,11 +336,7 @@ int CLIENT_STATE::check_suspend_processing() {
|
|||
}
|
||||
|
||||
void CLIENT_STATE::show_suspend_tasks_message(int reason) {
|
||||
if (reason == SUSPEND_REASON_CPU_THROTTLE) {
|
||||
if (log_flags.cpu_sched) {
|
||||
msg_printf(NULL, MSG_INFO, "[cpu_sched] Suspending - CPU throttle");
|
||||
}
|
||||
} else {
|
||||
if (reason != SUSPEND_REASON_CPU_THROTTLE) {
|
||||
if (log_flags.task) {
|
||||
msg_printf(NULL, MSG_INFO,
|
||||
"Suspending computation - %s",
|
||||
|
@ -372,10 +368,7 @@ void CLIENT_STATE::show_suspend_tasks_message(int reason) {
|
|||
|
||||
int CLIENT_STATE::resume_tasks(int reason) {
|
||||
if (reason == SUSPEND_REASON_CPU_THROTTLE) {
|
||||
if (log_flags.cpu_sched) {
|
||||
msg_printf(NULL, MSG_INFO, "[cpu_sched] Resuming - CPU throttle");
|
||||
}
|
||||
active_tasks.unsuspend_all();
|
||||
active_tasks.unsuspend_all(SUSPEND_REASON_CPU_THROTTLE);
|
||||
} else {
|
||||
if (log_flags.task) {
|
||||
msg_printf(NULL, MSG_INFO, "Resuming computation");
|
||||
|
|
Loading…
Reference in New Issue