client/server: change implementation of "exact fraction done".

My last commit did this using a new API call.
But this would require rebuilding apps any time you want to change it;
too much work.
So instead make it an attribute of apps,
which you can set via the admin web interface.

Corresponding changes to client.
This commit is contained in:
David Anderson 2014-05-04 00:02:32 -07:00
parent 77c4dd7b32
commit e5810f3061
14 changed files with 39 additions and 22 deletions

View File

@ -127,7 +127,6 @@ APP_CLIENT_SHM* app_client_shm = 0;
static volatile int time_until_checkpoint;
// time until enable checkpoint
static volatile double fraction_done;
static volatile bool fd_exact = false;
static volatile double last_checkpoint_cpu_time;
static volatile bool ready_to_checkpoint = false;
static volatile int in_critical_section = 0;
@ -384,9 +383,6 @@ static bool update_app_progress(double cpu_t, double cp_cpu_t) {
sprintf(buf, "<fraction_done>%e</fraction_done>\n", fdone);
strlcat(msg_buf, buf, sizeof(msg_buf));
}
if (fd_exact) {
strlcat(msg_buf, "<fd_exact/>\n", sizeof(msg_buf));
}
if (bytes_sent) {
sprintf(buf, "<bytes_sent>%f</bytes_sent>\n", bytes_sent);
strlcat(msg_buf, buf, sizeof(msg_buf));
@ -1435,12 +1431,6 @@ int boinc_fraction_done(double x) {
return 0;
}
int boinc_fraction_done_exact(double x) {
fraction_done = x;
fd_exact = true;
return 0;
}
int boinc_receive_trickle_down(char* buf, int len) {
std::string filename;
char path[MAXPATHLEN];

View File

@ -92,7 +92,6 @@ extern int boinc_send_trickle_up(char* variety, char* text);
extern int boinc_set_min_checkpoint_period(int);
extern int boinc_checkpoint_completed(void);
extern int boinc_fraction_done(double);
extern int boinc_fraction_done_exact(double);
extern int boinc_suspend_other_activities(void);
extern int boinc_resume_other_activities(void);
extern int boinc_report_app_status(

View File

@ -108,8 +108,6 @@ struct ACTIVE_TASK {
// will be zero if the app doesn't use this call
double fraction_done_elapsed_time;
// elapsed time when fraction done was last reported
bool fraction_done_exact;
// true if app thinks fraction done is accurate
int scheduler_state;
int next_scheduler_state; // temp
int signal;

View File

@ -1349,7 +1349,6 @@ bool ACTIVE_TASK::get_app_status_msg() {
bytes_received_episode = dtemp;
}
parse_int(msg_buf, "<want_network>", want_network);
parse_bool(msg_buf, "fd_exact", fraction_done_exact);
if (parse_int(msg_buf, "<other_pid>", other_pid)) {
// for now, we handle only one of these
other_pids.clear();

View File

@ -134,6 +134,7 @@ int APP::parse(XML_PARSER& xp) {
if (xp.parse_str("name", name, sizeof(name))) continue;
if (xp.parse_str("user_friendly_name", user_friendly_name, sizeof(user_friendly_name))) continue;
if (xp.parse_bool("non_cpu_intensive", non_cpu_intensive)) continue;
if (xp.parse_bool("fraction_done_exact", fraction_done_exact)) continue;
#ifdef SIM
if (xp.parse_double("latency_bound", latency_bound)) continue;
if (xp.parse_double("fpops_est", fpops_est)) continue;

View File

@ -244,6 +244,7 @@ struct APP {
char name[256];
char user_friendly_name[256];
bool non_cpu_intensive;
bool fraction_done_exact;
PROJECT* project;
int max_concurrent;
// Limit on # of concurrent jobs of this app; 0 if none

View File

@ -798,7 +798,11 @@ int CLIENT_STATE::handle_scheduler_reply(
for (i=0; i<sr.apps.size(); i++) {
APP* app = lookup_app(project, sr.apps[i].name);
if (app) {
// update app attributes; they may have changed on server
//
safe_strcpy(app->user_friendly_name, sr.apps[i].user_friendly_name);
app->non_cpu_intensive = sr.apps[i].non_cpu_intensive;
app->fraction_done_exact = sr.apps[i].fraction_done_exact;
} else {
app = new APP;
*app = sr.apps[i];
@ -879,9 +883,7 @@ int CLIENT_STATE::handle_scheduler_reply(
app, avpp.platform, avpp.version_num, avpp.plan_class
);
if (avp) {
// update performance-related info;
// generally this shouldn't change,
// but if it does it's better to use the new stuff
// update app version attributes in case they changed on server
//
avp->avg_ncpus = avpp.avg_ncpus;
avp->max_ncpus = avpp.max_ncpus;

View File

@ -1058,7 +1058,7 @@ double ACTIVE_TASK::est_dur() {
// if app says fraction done is accurate, just use it
//
if (fraction_done_exact) return frac_est;
if (result->app->fraction_done_exact) return frac_est;
// weighting of dynamic estimate is the fraction done
// i.e. when fraction done is 0.5, weighting is 50/50

View File

@ -214,7 +214,8 @@ void DB_APP::db_print(char* buf){
"homogeneous_app_version=%d, "
"non_cpu_intensive=%d, "
"locality_scheduling=%d, "
"n_size_classes=%d ",
"n_size_classes=%d, "
"fraction_done_exact=%d ",
create_time,
name,
min_version,
@ -229,7 +230,8 @@ void DB_APP::db_print(char* buf){
homogeneous_app_version?1:0,
non_cpu_intensive?1:0,
locality_scheduling,
n_size_classes
n_size_classes,
fraction_done_exact?1:0
);
}
@ -252,6 +254,7 @@ void DB_APP::db_parse(MYSQL_ROW &r) {
non_cpu_intensive = (atoi(r[i++]) != 0);
locality_scheduling = atoi(r[i++]);
n_size_classes = atoi(r[i++]);
fraction_done_exact = (atoi(r[i++]) != 0);
}
void DB_APP_VERSION::db_print(char* buf){

View File

@ -82,6 +82,8 @@ struct APP {
// type of locality scheduling used by this app (see above)
int n_size_classes;
// for multi-size apps, number of size classes
bool fraction_done_exact;
// fraction done reported by app is accurate
int write(FILE*);
void clear();

View File

@ -55,6 +55,7 @@ create table app (
non_cpu_intensive tinyint not null default 0,
locality_scheduling integer not null default 0,
n_size_classes smallint not null default 0,
fraction_done_exact tinyint not null default 0,
primary key (id)
) engine=InnoDB;

View File

@ -925,6 +925,14 @@ function update_4_2_2014() {
);
}
function update_5_3_2014() {
do_query(
"alter table app
add fraction_done_exact tinyint not null
"
);
}
// Updates are done automatically if you use "upgrade".
//
// If you need to do updates manually,
@ -965,6 +973,7 @@ $db_updates = array (
array(27006, "update_1_13_2014"),
array(27007, "update_3_6_2014"),
array(27008, "update_4_2_2014"),
array(27009, "update_5_3_2014"),
);
?>

View File

@ -43,6 +43,9 @@ function do_updates() {
$n = post_str("beta", true)?1:0;
$app->update("beta=$n");
$n = post_str("fraction_done_exact", true)?1:0;
$app->update("fraction_done_exact=$n");
echo "Application $id updated.
<p>
You must restart the project for this to take effect.
@ -82,11 +85,12 @@ function show_form() {
"Created",
"weight<br><a href=http://boinc.berkeley.edu/trac/wiki/BackendPrograms#feeder><span class=note>details</span></a>",
"shmem items",
"homogeneous redundancy type<br><a href=http://boinc.berkeley.edu/trac/wiki/HomogeneousRedundancy><span class=note>details</span></a>",
"HR type<br><a href=http://boinc.berkeley.edu/trac/wiki/HomogeneousRedundancy><span class=note>details</span></a>",
"homogeneous app version?<br><a href=http://boinc.berkeley.edu/trac/wiki/HomogeneousAppVersion><span class=note>details</span></a>",
"deprecated?",
"Non-CPU-intensive?",
"Beta?",
"Exact fraction done?",
""
);
@ -153,6 +157,12 @@ function show_form() {
<input name='beta' type='checkbox' $v></TD>
";
$v = '';
if ($app->fraction_done_exact) $v = ' CHECKED ';
echo " <TD align='center'>
<input name='fraction_done_exact' type='checkbox' $v></TD>
";
echo "<td><input type=submit name=submit value=Update>";
echo "</tr></form>";
}

View File

@ -1026,9 +1026,11 @@ int APP::write(FILE* fout) {
" <name>%s</name>\n"
" <user_friendly_name>%s</user_friendly_name>\n"
" <non_cpu_intensive>%d</non_cpu_intensive>\n"
" <fraction_done_exact>%d</fraction_done_exact>\n"
"</app>\n",
name, user_friendly_name,
non_cpu_intensive?1:0
non_cpu_intensive?1:0,
fraction_done_exact?1:0
);
return 0;
}