mirror of https://github.com/BOINC/boinc.git
Client: debug sub-second CPU throttling
This commit is contained in:
parent
ebde7809ce
commit
35f489d36f
|
@ -995,7 +995,13 @@ void ACTIVE_TASK::set_task_state(int val, const char* where) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef NEW_CPU_THROTTLE
|
||||
#define THROTTLE_PERIOD 1.
|
||||
#ifdef _WIN32
|
||||
DWORD WINAPI throttler(LPVOID) {
|
||||
#else
|
||||
void* throttler(void*) {
|
||||
#endif
|
||||
while (1) {
|
||||
client_mutex.lock();
|
||||
if (gstate.tasks_suspended || gstate.global_prefs.cpu_usage_limit > 99) {
|
||||
|
@ -1003,18 +1009,20 @@ void* throttler(void*) {
|
|||
boinc_sleep(10);
|
||||
continue;
|
||||
}
|
||||
double on = gstate.global_prefs.cpu_usage_limit / 100;
|
||||
double off = 1 - on;
|
||||
gstate.tasks_suspended = true;
|
||||
double on = THROTTLE_PERIOD * gstate.global_prefs.cpu_usage_limit / 100;
|
||||
double off = THROTTLE_PERIOD - on;
|
||||
gstate.tasks_throttled = true;
|
||||
gstate.active_tasks.suspend_all(SUSPEND_REASON_CPU_THROTTLE);
|
||||
client_mutex.unlock();
|
||||
boinc_sleep(off);
|
||||
client_mutex.lock();
|
||||
if (gstate.tasks_suspended && !gstate.suspend_reason) {
|
||||
if (!gstate.tasks_suspended) {
|
||||
gstate.resume_tasks(SUSPEND_REASON_CPU_THROTTLE);
|
||||
}
|
||||
gstate.tasks_throttled = false;
|
||||
client_mutex.unlock();
|
||||
boinc_sleep(on);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -318,5 +318,10 @@ extern double non_boinc_cpu_usage;
|
|||
|
||||
extern void run_test_app();
|
||||
|
||||
#ifdef _WIN32
|
||||
extern DWORD WINAPI throttler(void*);
|
||||
#else
|
||||
extern void* throttler(void*);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -96,6 +96,7 @@ CLIENT_STATE::CLIENT_STATE()
|
|||
file_xfer_giveup_period = PERS_GIVEUP;
|
||||
had_or_requested_work = false;
|
||||
tasks_suspended = false;
|
||||
tasks_throttled = false;
|
||||
network_suspended = false;
|
||||
suspend_reason = 0;
|
||||
network_suspend_reason = 0;
|
||||
|
@ -861,11 +862,13 @@ bool CLIENT_STATE::poll_slow_events() {
|
|||
if (suspend_reason) {
|
||||
if (!tasks_suspended) {
|
||||
show_suspend_tasks_message(suspend_reason);
|
||||
active_tasks.suspend_all(suspend_reason);
|
||||
if (!tasks_throttled) {
|
||||
active_tasks.suspend_all(suspend_reason);
|
||||
}
|
||||
}
|
||||
last_suspend_reason = suspend_reason;
|
||||
} else {
|
||||
if (tasks_suspended) {
|
||||
if (tasks_suspended && !tasks_throttled) {
|
||||
resume_tasks(last_suspend_reason);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef _CLIENT_STATE_
|
||||
#define _CLIENT_STATE_
|
||||
|
||||
//#define NEW_CPU_THROTTLE
|
||||
#define NEW_CPU_THROTTLE
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <string>
|
||||
|
@ -179,8 +179,10 @@ struct CLIENT_STATE {
|
|||
int pers_giveup;
|
||||
|
||||
bool tasks_suspended;
|
||||
// Don't run apps.
|
||||
// Computing suspended for reason other than throttling
|
||||
int suspend_reason;
|
||||
bool tasks_throttled;
|
||||
// Computing suspended because of throttling
|
||||
|
||||
bool network_suspended;
|
||||
// Don't use network.
|
||||
|
|
Loading…
Reference in New Issue