From df1d8e2bde2845d927cfa937142f147f73efbebe Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 6 Mar 2014 13:23:52 -0800 Subject: [PATCH] server: store and display gpu_active_frac - gpu_active_frac is the fraction of time GPU use is allowed while the client is running. Previously the client reported it but we weren't storing it in the DB. We may need it in the future for batch scheduling logic. - fix a crashing bug in scheduler - client: minor message tweak --- client/work_fetch.cpp | 2 +- db/boinc_db.cpp | 16 ++++++++++++---- db/boinc_db_types.h | 2 +- db/schema.sql | 1 + html/inc/host.inc | 7 ++++--- html/ops/db_update.php | 7 +++++++ lib/procinfo_unix.cpp | 5 +++-- sched/sched_types.cpp | 4 ++-- 8 files changed, 31 insertions(+), 13 deletions(-) diff --git a/client/work_fetch.cpp b/client/work_fetch.cpp index d7f0bd2b78..fa21178ad2 100644 --- a/client/work_fetch.cpp +++ b/client/work_fetch.cpp @@ -229,7 +229,7 @@ void RSC_WORK_FETCH::set_request(PROJECT* p) { if (log_flags.work_fetch_debug) { msg_printf(p, MSG_INFO, - "[work_fetch] set_request() for %s: ninst %d nused_total %f nidle_now %f fetch share %f req_inst %f req_secs %f", + "[work_fetch] set_request() for %s: ninst %d nused_total %.2f nidle_now %.2f fetch share %.2f req_inst %.2f req_secs %.2f", rsc_name_long(rsc_type), ninstances, w.nused_total, nidle_now, w.fetchable_share, req_instances, req_secs ); diff --git a/db/boinc_db.cpp b/db/boinc_db.cpp index 231ae15fb9..075dd51fd2 100644 --- a/db/boinc_db.cpp +++ b/db/boinc_db.cpp @@ -491,14 +491,16 @@ void DB_HOST::db_print(char* buf){ "avg_turnaround=%.15e, " "host_cpid='%s', external_ip_addr='%s', max_results_day=%d, " "error_rate=%.15e, " - "product_name='%s' ", + "product_name='%s', " + "gpu_active_frac=%.15e ", create_time, userid, rpc_seqno, rpc_time, total_credit, expavg_credit, expavg_time, timezone, domain_name, serialnum, last_ip_addr, nsame_ip_addr, - on_frac, connected_frac, active_frac, - cpu_efficiency, duration_correction_factor, + on_frac, connected_frac, + active_frac, cpu_efficiency, + duration_correction_factor, p_ncpus, p_vendor, p_model, p_fpops, p_iops, p_membw, os_name, os_version, @@ -511,7 +513,8 @@ void DB_HOST::db_print(char* buf){ avg_turnaround, host_cpid, external_ip_addr, _max_results_day, _error_rate, - product_name + product_name, + gpu_active_frac ); UNESCAPE(domain_name); UNESCAPE(serialnum); @@ -572,6 +575,7 @@ void DB_HOST::db_parse(MYSQL_ROW &r) { _max_results_day = atoi(r[i++]); _error_rate = atof(r[i++]); strcpy2(product_name, r[i++]); + gpu_active_frac = atof(r[i++]); } int DB_HOST::update_diff_validator(HOST& h) { @@ -793,6 +797,10 @@ int DB_HOST::update_diff_sched(HOST& h) { unescape_string(product_name, sizeof(product_name)); strcat(updates, buf); } + if (gpu_active_frac != h.gpu_active_frac) { + sprintf(buf, " gpu_active_frac=%.15e,", gpu_active_frac); + strcat(updates, buf); + } int n = strlen(updates); if (n == 0) return 0; diff --git a/db/boinc_db_types.h b/db/boinc_db_types.h index b4277114ef..c7f6d65a0d 100644 --- a/db/boinc_db_types.h +++ b/db/boinc_db_types.h @@ -337,6 +337,7 @@ struct HOST { // that fail validation // DEPRECATED char product_name[256]; + double gpu_active_frac; // the following items are passed in scheduler requests, // and used in the scheduler, @@ -349,7 +350,6 @@ struct HOST { OPENCL_CPU_PROP opencl_cpu_prop[MAX_OPENCL_CPU_PLATFORMS]; // stuff from time_stats - double gpu_active_frac; double cpu_and_network_available_frac; double client_start_time; double previous_uptime; diff --git a/db/schema.sql b/db/schema.sql index 9dcb379fbf..cf7b457239 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -186,6 +186,7 @@ create table host ( max_results_day integer not null, error_rate double not null default 0, product_name varchar(254) not null, + gpu_active_frac double not null, primary key (id) ) engine=InnoDB; diff --git a/html/inc/host.inc b/html/inc/host.inc index 1665855017..68c0b7069d 100644 --- a/html/inc/host.inc +++ b/html/inc/host.inc @@ -182,11 +182,12 @@ function show_host($host, $user, $ipprivate) { if ($user) { row2(tra("Number of times client has contacted server"), $host->rpc_seqno); row2(tra("Last time contacted server"), sched_log_link($host->rpc_time)); - row2(tra("% of time BOINC is running"), 100*$host->on_frac." %"); + row2(tra("% of time BOINC is running"), number_format(100*$host->on_frac, 2)."%"); if ($host->connected_frac > 0) { - row2(tra("While BOINC running, % of time host has an Internet connection"), 100*$host->connected_frac." %"); + row2(tra("While BOINC running, % of time host has an Internet connection"), number_format(100*$host->connected_frac, 2)."%"); } - row2(tra("While BOINC running, % of time work is allowed"), 100*$host->active_frac." %"); + row2(tra("While BOINC running, % of time work is allowed"), number_format(100*$host->active_frac, 2)."%"); + row2(tra("While BOINC running, % of time GPU work is allowed"), number_format(100*$host->gpu_active_frac, 2)."%"); if ($host->cpu_efficiency) { row2(tra("Average CPU efficiency"), $host->cpu_efficiency); } diff --git a/html/ops/db_update.php b/html/ops/db_update.php index da4c62ba37..df9c741fd4 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -909,6 +909,12 @@ function update_1_13_2014() { ); } +function update_3_6_2014() { + do_query( + "alter table host add gpu_active_frac double not null" + ); +} + // Updates are done automatically if you use "upgrade". // // If you need to do updates manually, @@ -947,6 +953,7 @@ $db_updates = array ( array(27004, "update_9_17_2013"), array(27005, "update_12_22_2013"), array(27006, "update_1_13_2014"), + array(27007, "update_3_6_2014"), ); ?> diff --git a/lib/procinfo_unix.cpp b/lib/procinfo_unix.cpp index 41b3f3249b..de9a13fc29 100644 --- a/lib/procinfo_unix.cpp +++ b/lib/procinfo_unix.cpp @@ -252,8 +252,9 @@ int procinfo_setup(PROC_MAP& pm) { strlcpy(p.command, ps.comm, sizeof(p.command)); p.is_boinc_app = (p.id == pid || strcasestr(p.command, "boinc")); p.is_low_priority = (ps.priority == 39); - // Linux seems to add 20 here, - // but this isn't documented anywhere + // Internally Linux stores the process priority as nice + 20 + // as -ve values are error codes. Thus this generally gives + // a process priority range of 39..0 pm.insert(std::pair(p.id, p)); #endif } diff --git a/sched/sched_types.cpp b/sched/sched_types.cpp index 2454d3e077..02e8b13b3c 100644 --- a/sched/sched_types.cpp +++ b/sched/sched_types.cpp @@ -1344,7 +1344,7 @@ void GLOBAL_PREFS::defaults() { void GUI_URLS::init() { text = 0; read_file_malloc(config.project_path("gui_urls.xml"), text); - text = lf_terminate(text); + if (text) text = lf_terminate(text); } void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf, int len) { @@ -1386,7 +1386,7 @@ void GUI_URLS::get_gui_urls(USER& user, HOST& host, TEAM& team, char* buf, int l void PROJECT_FILES::init() { text = 0; read_file_malloc(config.project_path("project_files.xml"), text); - text = lf_terminate(text); + if (text) text = lf_terminate(text); } void get_weak_auth(USER& user, char* buf) {