- server code cleanup

svn path=/trunk/boinc/; revision=18830
This commit is contained in:
David Anderson 2009-08-12 16:01:46 +00:00
parent f6d3e8a477
commit 3eeefc0048
2 changed files with 63 additions and 55 deletions

View File

@ -259,7 +259,9 @@ function is_dev($v) {
//$url_base = "http://boincdl.ssl.berkeley.edu/dl/";
//$url_base = "http://mirror.worldcommunitygrid.org/mirror/";
switch(rand(0,3)) {
// note: rand() is inclusive
switch(rand(0,2)) {
case 0: $url_base = "http://einstein.ligo.caltech.edu/download/boinc/dl/"; break;
case 1: $url_base = "http://boincdl3.ssl.berkeley.edu/mirror/"; break;
case 2: $url_base = "http://einstein.aei.mpg.de/download/boinc/dl/"; break;

View File

@ -50,7 +50,7 @@ static void modify_credit_rating(HOST& host) {
double percent_difference = 0;
// The percent difference between claim and history
double difference_weight = 1;
// The weight to be applied based on the difference between claim and
// The weight to be applied based on the difference between claim and
// history
double credit_weight = 1;
// The weight to be applied based on how much credit the host has earned
@ -60,83 +60,89 @@ static void modify_credit_rating(HOST& host) {
// Only modify if the credit_per_cpu_sec is established
// and the option is enabled
if ( host.credit_per_cpu_sec > 0
&& config.granted_credit_weight > 0.0
&& config.granted_credit_weight <= 1.0 ) {
//
if (host.credit_per_cpu_sec > 0
&& config.granted_credit_weight > 0.0
&& config.granted_credit_weight <= 1.0
) {
// Calculate the difference between claimed credit and the hosts
// historical granted credit history
percent_difference=host.claimed_credit_per_cpu_sec-host.credit_per_cpu_sec;
percent_difference = fabs(percent_difference/host.credit_per_cpu_sec);
// A study on World Community Grid determined that 50% of hosts
// claimed within 10% of their historical credit per cpu sec.
// claimed within 10% of their historical credit per cpu sec.
// These hosts should not have their credit modified.
if ( percent_difference < 0.1000 ) {
log_messages.printf(MSG_DEBUG, "[HOSTID:%d] Claimed credit %.1lf not "
"modified. Percent Difference %.4lf\n", host.id,
host.claimed_credit_per_cpu_sec*86400, percent_difference
);
//
if (percent_difference < 0.1) {
log_messages.printf(MSG_DEBUG,
"[HOSTID:%d] Claimed credit %.1lf not "
"modified. Percent Difference %.4lf\n", host.id,
host.claimed_credit_per_cpu_sec*86400, percent_difference
);
return;
}
}
// The study also determined that 95% of hosts claim within
// The study also determined that 95% of hosts claim within
// 50% of their historical credit per cpu sec.
// Computers claiming above 10% but below 50% should have their
// Computers claiming above 10% but below 50% should have their
// credit adjusted based on their history
// Computers claiming more than 50% above should use their
// Computers claiming more than 50% above should use their
// historical value.
if ( percent_difference < .5 ) {
if (percent_difference < .5) {
// weight based on variance from historical credit
difference_weight=1-(0.5-percent_difference)/0.4;
} else {
difference_weight=1;
}
difference_weight = 1-(0.5-percent_difference)/0.4;
} else {
difference_weight = 1;
}
// A weight also needs to be calculated based upon the amount of
// credit awarded to a host. This is becuase hosts without much
// credit awarded do not yet have an accurate history so the weight
// should be limited for these hosts.
if ( config.granted_credit_ramp_up ) {
credit_weight=config.granted_credit_ramp_up - host.total_credit;
credit_weight=credit_weight/config.granted_credit_ramp_up;
if ( credit_weight < 0) credit_weight = 0;
credit_weight = 1 - credit_weight;
if (config.granted_credit_ramp_up) {
credit_weight=config.granted_credit_ramp_up - host.total_credit;
credit_weight=credit_weight/config.granted_credit_ramp_up;
if (credit_weight < 0) credit_weight = 0;
credit_weight = 1 - credit_weight;
}
// Compute the combined weight
combined_weight=credit_weight*difference_weight*config.granted_credit_weight;
log_messages.printf(MSG_DEBUG, "[HOSTID:%d] Weight details: "
"diff_weight=%.4lf credit_weight=%.4lf config_weight=%.4lf\n",
host.id, difference_weight, credit_weight,
config.granted_credit_weight
);
combined_weight = credit_weight*difference_weight*config.granted_credit_weight;
log_messages.printf(MSG_DEBUG, "[HOSTID:%d] Weight details: "
"diff_weight=%.4lf credit_weight=%.4lf config_weight=%.4lf\n",
host.id, difference_weight, credit_weight,
config.granted_credit_weight
);
// Compute the new value for claimed credit
new_claimed_credit=(1-combined_weight)*host.claimed_credit_per_cpu_sec;
new_claimed_credit=new_claimed_credit+combined_weight*host.credit_per_cpu_sec;
if ( new_claimed_credit < host.claimed_credit_per_cpu_sec ) {
log_messages.printf(MSG_DEBUG, "[HOSTID:%d] Modified claimed credit "
"(lowered) original: %.1lf new: %.1lf historical: %.1lf "
"combined weight: %.4lf\n", host.id,
host.claimed_credit_per_cpu_sec*86400,
new_claimed_credit*86400, host.credit_per_cpu_sec*86400,
combined_weight
);
if (new_claimed_credit < host.claimed_credit_per_cpu_sec) {
log_messages.printf(MSG_DEBUG,
"[HOSTID:%d] Modified claimed credit "
"(lowered) original: %.1lf new: %.1lf historical: %.1lf "
"combined weight: %.4lf\n", host.id,
host.claimed_credit_per_cpu_sec*86400,
new_claimed_credit*86400, host.credit_per_cpu_sec*86400,
combined_weight
);
} else {
log_messages.printf(MSG_DEBUG, "[HOSTID:%d] Modified claimed credit "
"(increased) original: %.1lf new: %.1lf historical: %.1lf "
"combined weight: %.4lf\n", host.id,
host.claimed_credit_per_cpu_sec*86400,
new_claimed_credit*86400, host.credit_per_cpu_sec*86400,
combined_weight
);
}
host.claimed_credit_per_cpu_sec=new_claimed_credit;
log_messages.printf(MSG_DEBUG,
"[HOSTID:%d] Modified claimed credit "
"(increased) original: %.1lf new: %.1lf historical: %.1lf "
"combined weight: %.4lf\n", host.id,
host.claimed_credit_per_cpu_sec*86400,
new_claimed_credit*86400, host.credit_per_cpu_sec*86400,
combined_weight
);
}
host.claimed_credit_per_cpu_sec = new_claimed_credit;
}
}
// somewhat arbitrary formula for credit as a function of CPU time.
// Could also include terms for RAM size, network speed etc.
@ -164,7 +170,7 @@ void compute_credit_rating(HOST& host) {
x /= SECONDS_PER_DAY;
x *= scale;
host.claimed_credit_per_cpu_sec = x;
if (config.granted_credit_weight) {
modify_credit_rating(host);
}