- GUI RPC: expose TIME_STATS info (e.g. on_frac) in

the binding of the get_state() RPC
- client: move client_start_time and previous_uptime
    from CLIENT_STATE to TIME_STATS,
    so that these are also visible in GUI RPC
- scheduler RPC: move uptime and previous_uptime
    into <time_stats>
- client: condition an RR simulation message on <rrsim_detail>
- boinccmd: show TIME_STATS info in --get_state
This commit is contained in:
David Anderson 2012-10-29 15:44:51 -07:00 committed by Oliver Bock
parent f1b4b16bbf
commit 9cf10b400a
13 changed files with 144 additions and 64 deletions

View File

@ -6444,3 +6444,27 @@ David 28 Oct 2012
tools/
update_versions
David 29 Oct 2012
- GUI RPC: expose TIME_STATS info (e.g. on_frac) in
the binding of the get_state() RPC
- client: move client_start_time and previous_uptime
from CLIENT_STATE to TIME_STATS,
so that these are also visible in GUI RPC
- scheduler RPC: move uptime and previous_uptime
into <time_stats>
- client: condition an RR simulation message on <rrsim_detail>
- boinccmd: show TIME_STATS info in --get_state
client/
client_state.cpp,h
cs_prefs.cpp
cs_scheduler.cpp
cs_statefile.cpp
rr_sim.cpp
time_stats.cpp,h
lib/
common_defs.h
gui_rpc_client.h
gui_rpc_client_ops.cpp
gui_rpc_client_print.cpp

View File

@ -143,7 +143,6 @@ CLIENT_STATE::CLIENT_STATE()
launched_by_manager = false;
initialized = false;
last_wakeup_time = dtime();
previous_uptime = 0;
}
void CLIENT_STATE::show_host_info() {
@ -301,7 +300,6 @@ int CLIENT_STATE::init() {
srand((unsigned int)time(0));
now = dtime();
client_start_time = now;
scheduler_op->url_random = drand();
notices.init();

View File

@ -92,7 +92,7 @@ struct CLIENT_STATE {
GET_PROJECT_LIST_OP get_project_list_op;
ACCT_MGR_OP acct_mgr_op;
TIME_STATS time_stats;
CLIENT_TIME_STATS time_stats;
GLOBAL_PREFS global_prefs;
NET_STATS net_stats;
ACTIVE_TASK_SET active_tasks;
@ -185,9 +185,6 @@ struct CLIENT_STATE {
// this affects auto-update
bool run_by_updater;
double now;
double client_start_time;
double previous_uptime;
// duration of previous client session
double last_wakeup_time;
bool initialized;
bool cant_write_state_file;

View File

@ -206,7 +206,7 @@ int CLIENT_STATE::check_suspend_processing() {
return SUSPEND_REASON_BENCHMARKS;
}
if (config.start_delay && now < client_start_time + config.start_delay) {
if (config.start_delay && now < time_stats.client_start_time + config.start_delay) {
return SUSPEND_REASON_INITIAL_DELAY;
}

View File

@ -121,9 +121,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) {
" <prrs_fraction>%f</prrs_fraction>\n"
" <duration_correction_factor>%f</duration_correction_factor>\n"
" <allow_multiple_clients>%d</allow_multiple_clients>\n"
" <sandbox>%d</sandbox>\n"
" <uptime>%f</uptime>\n"
" <previous_uptime>%f</previous_uptime>\n",
" <sandbox>%d</sandbox>\n",
p->authenticator,
p->hostid,
p->rpc_seqno,
@ -135,9 +133,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) {
prrs_fraction,
p->duration_correction_factor,
config.allow_multiple_clients?1:0,
g_use_sandbox?1:0,
now - client_start_time,
previous_uptime
g_use_sandbox?1:0
);
work_fetch.write_request(f, p);

View File

@ -500,7 +500,7 @@ int CLIENT_STATE::parse_state_file_aux(const char* fname) {
if (xp.parse_string("newer_version", newer_version)) {
continue;
}
if (xp.parse_double("previous_uptime", previous_uptime)) {
if (xp.parse_double("previous_uptime", time_stats.previous_uptime)) {
continue;
}
#ifdef ENABLE_AUTO_UPDATE
@ -771,7 +771,7 @@ int CLIENT_STATE::write_state(MIOFILE& f) {
cpu_benchmarks_pending?"<cpu_benchmarks_pending/>\n":"",
new_version_check_time,
all_projects_list_check_time,
now - client_start_time
now - time_stats.client_start_time
);
if (newer_version.size()) {
f.printf("<newer_version>%s</newer_version>\n", newer_version.c_str());
@ -931,11 +931,6 @@ int CLIENT_STATE::write_state_gui(MIOFILE& f) {
f.printf("<client_state>\n");
#if 1
// NOTE: the following stuff is not in CC_STATE.
// However, BoincView (which does its own parsing) expects it
// to be in the get_state() reply, so leave it in for now
//
retval = host_info.write(f, true, false);
if (retval) return retval;
@ -948,12 +943,18 @@ int CLIENT_STATE::write_state_gui(MIOFILE& f) {
f.printf("<have_ati/>\n");
}
retval = time_stats.write(f, false);
if (retval) return retval;
#if 1
// NOTE: the following is not in CC_STATE.
// However, BoincView (which does its own parsing) expects it
// to be in the get_state() reply, so leave it in for now
//
retval = net_stats.write(f);
if (retval) return retval;
#endif
retval = time_stats.write(f, true);
if (retval) return retval;
for (j=0; j<projects.size(); j++) {
PROJECT* p = projects[j];
retval = p->write_state(f, true);

View File

@ -489,10 +489,12 @@ void RR_SIM::simulate() {
COPROC& cp = coprocs.coprocs[i];
int mask = (1<<cp.count)-1;
rwf.sim_excluded_instances = ~(rwf.sim_used_instances) & mask;
msg_printf(0, MSG_INFO,
"rsc %d: sim_used_inst %d mask %d sim_excluded_instances %d",
i, rwf.sim_used_instances, mask, rwf.sim_excluded_instances
);
if (log_flags.rrsim_detail) {
msg_printf(0, MSG_INFO,
"[rrsim_detail] rsc %d: sim_used_inst %d mask %d sim_excluded_instances %d",
i, rwf.sim_used_instances, mask, rwf.sim_excluded_instances
);
}
}
// if simulation ends before end of buffer, take the tail into account

View File

@ -76,7 +76,7 @@ int get_connected_state() {
const float ALPHA = (SECONDS_PER_DAY*10);
//const float ALPHA = 60; // for testing
void TIME_STATS::init() {
void CLIENT_TIME_STATS::init() {
last_update = 0;
first = true;
on_frac = 1;
@ -84,6 +84,8 @@ void TIME_STATS::init() {
active_frac = 1;
gpu_active_frac = 1;
cpu_and_network_available_frac = 1;
client_start_time = gstate.now;
previous_uptime = 0;
previous_connected_state = CONNECTED_STATE_UNINITIALIZED;
inactive_start = 0;
trim_stats_log();
@ -92,7 +94,7 @@ void TIME_STATS::init() {
// if log file is over a meg, discard everything older than a year
//
void TIME_STATS::trim_stats_log() {
void CLIENT_TIME_STATS::trim_stats_log() {
#ifndef SIM
double size;
char buf[256];
@ -137,7 +139,7 @@ void send_log_after(const char* filename, double t, MIOFILE& mf) {
// copy the log file after a given time
//
void TIME_STATS::get_log_after(double t, MIOFILE& mf) {
void CLIENT_TIME_STATS::get_log_after(double t, MIOFILE& mf) {
if (time_stats_log) {
fclose(time_stats_log); // win: can't open twice
}
@ -150,7 +152,7 @@ void TIME_STATS::get_log_after(double t, MIOFILE& mf) {
// so these get written to disk only when other activities
// cause this to happen. Maybe should change this.
//
void TIME_STATS::update(int suspend_reason, int _gpu_suspend_reason) {
void CLIENT_TIME_STATS::update(int suspend_reason, int _gpu_suspend_reason) {
double dt, w1, w2;
bool is_active = !(suspend_reason & ~SUSPEND_REASON_CPU_THROTTLE);
@ -276,21 +278,29 @@ void TIME_STATS::update(int suspend_reason, int _gpu_suspend_reason) {
// Write XML based time statistics
//
int TIME_STATS::write(MIOFILE& out, bool to_server) {
int CLIENT_TIME_STATS::write(MIOFILE& out, bool to_remote) {
out.printf(
"<time_stats>\n"
" <on_frac>%f</on_frac>\n"
" <connected_frac>%f</connected_frac>\n"
" <cpu_and_network_available_frac>%f</cpu_and_network_available_frac>\n"
" <active_frac>%f</active_frac>\n"
" <gpu_active_frac>%f</gpu_active_frac>\n",
" <gpu_active_frac>%f</gpu_active_frac>\n"
" <client_start_time>%f</client_start_time>\n"
" <previous_uptime>%f</previous_uptime>\n",
on_frac,
connected_frac,
cpu_and_network_available_frac,
active_frac,
gpu_active_frac
gpu_active_frac,
client_start_time,
previous_uptime
);
if (!to_server) {
if (to_remote) {
out.printf(
" <now>%f</now>\n", gstate.now
);
} else {
out.printf(
" <last_update>%f</last_update>\n",
last_update
@ -302,7 +312,7 @@ int TIME_STATS::write(MIOFILE& out, bool to_server) {
// Parse XML based time statistics, usually from client_state.xml
//
int TIME_STATS::parse(XML_PARSER& xp) {
int CLIENT_TIME_STATS::parse(XML_PARSER& xp) {
double x;
#ifdef SIM
double on_lambda = 3600, connected_lambda = 3600;
@ -392,27 +402,27 @@ int TIME_STATS::parse(XML_PARSER& xp) {
return ERR_XML_PARSE;
}
void TIME_STATS::start() {
void CLIENT_TIME_STATS::start() {
time_stats_log = fopen(TIME_STATS_LOG, "a");
if (time_stats_log) {
setbuf(time_stats_log, 0);
}
}
void TIME_STATS::quit() {
void CLIENT_TIME_STATS::quit() {
log_append("power_off", gstate.now);
}
#ifdef SIM
void TIME_STATS::log_append(const char* , double ) {}
void CLIENT_TIME_STATS::log_append(const char* , double ) {}
#else
void TIME_STATS::log_append(const char* msg, double t) {
void CLIENT_TIME_STATS::log_append(const char* msg, double t) {
if (!time_stats_log) return;
fprintf(time_stats_log, "%f %s\n", t, msg);
}
#endif
void TIME_STATS::log_append_net(int new_state) {
void CLIENT_TIME_STATS::log_append_net(int new_state) {
switch(new_state) {
case CONNECTED_STATE_NOT_CONNECTED:
log_append("net_not_connected", gstate.now);

View File

@ -18,32 +18,16 @@
#ifndef _TIME_STATS_
#define _TIME_STATS_
#include "miofile.h"
#include <vector>
struct TIME_STATS {
#include "miofile.h"
#include "common_defs.h"
struct CLIENT_TIME_STATS : TIME_STATS {
bool first;
int previous_connected_state;
double last_update;
// we maintain an exponentially weighted average of these quantities:
double on_frac;
// the fraction of total time this host runs the client
double connected_frac;
// of the time this host runs the client,
// the fraction it is connected to the Internet,
// or -1 if not known
double cpu_and_network_available_frac;
// of the time this host runs the client,
// the fraction it is connected to the Internet
// AND network usage is allowed (by prefs and user toggle)
// AND CPU usage is allowed
double active_frac;
// of the time this host runs the client,
// the fraction it is enabled to use CPU
// (as determined by preferences, manual suspend/resume, etc.)
double gpu_active_frac;
// same, GPU
FILE* time_stats_log;
double inactive_start;
@ -51,7 +35,7 @@ struct TIME_STATS {
void update(int suspend_reason, int gpu_suspend_reason);
void init();
int write(MIOFILE&, bool to_server);
int write(MIOFILE&, bool to_remote);
int parse(XML_PARSER&);
double availability_frac(int rsc_type) {

View File

@ -19,6 +19,7 @@
#define _COMMON_DEFS_
#include "miofile.h"
#include "parse.h"
// #defines or enums that are shared by more than one BOINC component
// (e.g. client, server, Manager, etc.)
@ -179,6 +180,36 @@ enum SUSPEND_REASON {
#define RPC_REASON_INIT 6
#define RPC_REASON_PROJECT_REQ 7
struct TIME_STATS {
// we maintain an exponentially weighted average of these quantities:
double now;
// the client's time of day
double on_frac;
// the fraction of total time this host runs the client
double connected_frac;
// of the time this host runs the client,
// the fraction it is connected to the Internet,
// or -1 if not known
double cpu_and_network_available_frac;
// of the time this host runs the client,
// the fraction it is connected to the Internet
// AND network usage is allowed (by prefs and user toggle)
// AND CPU usage is allowed
double active_frac;
// of the time this host runs the client,
// the fraction it is enabled to use CPU
// (as determined by preferences, manual suspend/resume, etc.)
double gpu_active_frac;
// same, GPU
double client_start_time;
double previous_uptime;
// duration of previous session
void write(MIOFILE&);
int parse(XML_PARSER&);
void print();
};
struct VERSION_INFO {
int major;
int minor;

View File

@ -369,6 +369,9 @@ struct GR_PROXY_INFO {
void clear();
};
// Represents the entire client state.
// Call get_state() infrequently.
//
struct CC_STATE {
std::vector<PROJECT*> projects;
std::vector<APP*> apps;
@ -378,11 +381,12 @@ struct CC_STATE {
std::vector<std::string> platforms;
// platforms supported by client
GLOBAL_PREFS global_prefs; // working prefs, i.e. network + override
VERSION_INFO version_info; // populated only if talking to pre-5.6 CC
VERSION_INFO version_info; // populated only if talking to pre-5.6 client
bool executing_as_daemon; // true if client is running as a service / daemon
HOST_INFO host_info;
bool have_nvidia; // redundant; include for compat (set by <have_cuda/>)
bool have_ati; // redundant; include for compat
TIME_STATS time_stats;
bool have_nvidia; // deprecated; include for compat (set by <have_cuda/>)
bool have_ati; // deprecated; include for compat
CC_STATE();
~CC_STATE();

View File

@ -77,6 +77,22 @@ using std::string;
using std::vector;
using std::sort;
int TIME_STATS::parse(XML_PARSER& xp) {
memset(this, 0, sizeof(TIME_STATS));
while (!xp.get_tag()) {
if (xp.match_tag("/time_stats")) return 0;
if (xp.parse_double("now", now)) continue;
if (xp.parse_double("on_frac", on_frac)) continue;
if (xp.parse_double("connected_frac", connected_frac)) continue;
if (xp.parse_double("cpu_and_network_available_frac", cpu_and_network_available_frac)) continue;
if (xp.parse_double("active_frac", active_frac)) continue;
if (xp.parse_double("gpu_active_frac", gpu_active_frac)) continue;
if (xp.parse_double("client_start_time", client_start_time)) continue;
if (xp.parse_double("previous_uptime", previous_uptime)) continue;
}
return ERR_XML_PARSE;
}
int DAILY_XFER::parse(XML_PARSER& xp) {
while (!xp.get_tag()) {
if (xp.match_tag("/dx")) return 0;
@ -942,6 +958,10 @@ int CC_STATE::parse(XML_PARSER& xp) {
host_info.parse(xp);
continue;
}
if (xp.match_tag("time_stats")) {
time_stats.parse(xp);
continue;
}
if (xp.parse_bool("have_cuda", have_nvidia)) continue;
if (xp.parse_bool("have_ati", have_ati)) continue;
}

View File

@ -211,6 +211,17 @@ void SIMPLE_GUI_INFO::print() {
}
}
void TIME_STATS::print() {
printf(" now: %f\n", now);
printf(" on_frac: %f\n", on_frac);
printf(" connected_frac: %f\n", connected_frac);
printf(" cpu_and_network_available_frac: %f\n", cpu_and_network_available_frac);
printf(" active_frac: %f\n", active_frac);
printf(" gpu_active_frac: %f\n", gpu_active_frac);
printf(" client_start_time: %f\n", client_start_time);
printf(" previous_uptime: %f\n", previous_uptime);
}
void CC_STATE::print() {
unsigned int i;
printf("======== Projects ========\n");
@ -238,6 +249,8 @@ void CC_STATE::print() {
printf("%d) -----------\n", i+1);
results[i]->print();
}
printf("\n======== Time stats ========\n");
time_stats.print();
}
void print_status(