From 3b1ebfd1b0c3aefd45446d1ec6dacb6d7be4d4c5 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 2 Aug 2022 13:59:32 -0700 Subject: [PATCH 01/21] Add new "not in use" (niu) prefs niu_cpu_usage_limit: CPU throttling while computer not in use niu_max_ncpus_pct: # CPUs to use while computer not in use niu_suspend_cpu_usage: suspend if non-BOINC usage while computer not in use Client: parse these from global_prefs files, and enforce them. If not specified, use the corresponding (non-niu) pref all the time. Web: add them to the computing prefs pages. Refactor the prefs into: in use / not in use / tasks / disk / network TODO: update the Manager prefs dialog accordingly --- client/app.cpp | 12 +- client/app_control.cpp | 2 +- client/client_state.cpp | 10 +- client/client_state.h | 34 +++- client/cpu_sched.cpp | 56 +++--- client/cs_benchmark.cpp | 4 +- client/cs_prefs.cpp | 36 ++-- client/cs_scheduler.cpp | 2 +- client/gui_rpc_server_ops.cpp | 22 +-- client/rr_sim.cpp | 4 +- client/rrsim_test.cpp | 6 +- client/sim.cpp | 6 +- client/work_fetch.cpp | 4 +- html/inc/prefs.inc | 346 ++++++++++++++++++---------------- lib/prefs.cpp | 44 ++++- lib/prefs.h | 10 +- 16 files changed, 336 insertions(+), 262 deletions(-) diff --git a/client/app.cpp b/client/app.cpp index db9bcecc743..8b3347cac42 100644 --- a/client/app.cpp +++ b/client/app.cpp @@ -657,9 +657,9 @@ int ACTIVE_TASK::get_free_slot(RESULT* rp) { // paranoia - don't allow unbounded slots // - if (j > gstate.ncpus*100) { + if (j > gstate.n_usable_cpus*100) { msg_printf(rp->project, MSG_INTERNAL_ERROR, - "exceeded limit of %d slot directories", gstate.ncpus*100 + "exceeded limit of %d slot directories", gstate.n_usable_cpus*100 ); return ERR_NULL; } @@ -1205,16 +1205,14 @@ void* throttler(void*) { while (1) { client_mutex.lock(); - if (gstate.tasks_suspended - || gstate.global_prefs.cpu_usage_limit > 99 - || gstate.global_prefs.cpu_usage_limit < 0.005 - ) { + double limit = gstate.current_cpu_usage_limit(); + if (gstate.tasks_suspended || limit == 0) { client_mutex.unlock(); // ::Sleep((int)(1000*10)); // for Win debugging boinc_sleep(10); continue; } - double on, off, on_frac = gstate.global_prefs.cpu_usage_limit / 100; + double on, off, on_frac = limit / 100; #if 0 // sub-second CPU throttling // DOESN'T WORK BECAUSE OF 1-SEC API POLL diff --git a/client/app_control.cpp b/client/app_control.cpp index 60ac606c190..b1e1427c4d3 100644 --- a/client/app_control.cpp +++ b/client/app_control.cpp @@ -1546,7 +1546,7 @@ void ACTIVE_TASK_SET::get_msgs() { last_time = gstate.now; double et_diff = delta_t; - double et_diff_throttle = delta_t * gstate.global_prefs.cpu_usage_limit/100; + double et_diff_throttle = delta_t * gstate.current_cpu_usage_limit()/100; for (i=0; i 0) { @@ -626,7 +626,7 @@ int CLIENT_STATE::init() { // host_info.p_vm_extensions_disabled = false; - set_ncpus(); + set_n_usable_cpus(); show_host_info(); // this follows parse_state_file() because that's where we read project names @@ -992,6 +992,8 @@ bool CLIENT_STATE::poll_slow_events() { #endif if (user_active != old_user_active) { + set_n_usable_cpus(); + // if niu_max_ncpus_pct pref is set, # usable CPUs may change request_schedule_cpus(user_active?"Not idle":"Idle"); } diff --git a/client/client_state.h b/client/client_state.h index 40bdb84155b..ae65adf720e 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -18,7 +18,6 @@ #ifndef BOINC_CLIENT_STATE_H #define BOINC_CLIENT_STATE_H -#define NEW_CPU_THROTTLE // do CPU throttling using a separate thread. // This makes it possible to throttle faster than the client's 1-sec poll period // NOTE: we can't actually do this because the runtime system's @@ -35,9 +34,7 @@ using std::vector; #include "coproc.h" #include "util.h" -#ifdef NEW_CPU_THROTTLE #include "thread.h" -#endif #include "acct_mgr.h" #include "acct_setup.h" @@ -345,7 +342,7 @@ struct CLIENT_STATE { // - an app fails to start (CS::schedule_cpus()) // - any project op is done via RPC (suspend/resume) // - any result op is done via RPC (suspend/resume) - void set_ncpus(); + void set_n_usable_cpus(); // --------------- cs_account.cpp: int add_project( @@ -363,12 +360,13 @@ struct CLIENT_STATE { double get_fraction_done(RESULT* result); int input_files_available(RESULT*, bool, FILE_INFO** f=0); ACTIVE_TASK* lookup_active_task_by_result(RESULT*); - int ncpus; - // Act like there are this many CPUs. + int n_usable_cpus; + // number of usable CPUs // By default this is the # of physical CPUs, // but it can be changed in two ways: - // - type N in the config file - // - type the max_ncpus_pct pref + // - N in cc_config.xml + // (for debugging; can be > # physical CPUs) + // - the max_ncpus_pct and niu_max_ncpus_pct prefs int latest_version(APP*, char*); int app_finished(ACTIVE_TASK&); @@ -521,6 +519,24 @@ struct CLIENT_STATE { #endif KEYWORDS keywords; + + double current_cpu_usage_limit() { + double x = global_prefs.cpu_usage_limit; + if (!user_active && global_prefs.niu_cpu_usage_limit>=0) { + x = global_prefs.niu_cpu_usage_limit; + } + if (x < 0.005 || x > 99) { + x = 100; + } + return x; + } + double current_suspend_cpu_usage() { + double x = global_prefs.suspend_cpu_usage; + if (!user_active && global_prefs.niu_suspend_cpu_usage>=0) { + x = global_prefs.niu_suspend_cpu_usage; + } + return x; + } }; extern CLIENT_STATE gstate; @@ -535,10 +551,8 @@ extern double calculate_exponential_backoff( int n, double MIN, double MAX ); -#ifdef NEW_CPU_THROTTLE extern THREAD_LOCK client_mutex; extern THREAD throttle_thread; -#endif //////// TIME-RELATED CONSTANTS //////////// diff --git a/client/cpu_sched.cpp b/client/cpu_sched.cpp index bce568d6087..8f81b6694de 100644 --- a/client/cpu_sched.cpp +++ b/client/cpu_sched.cpp @@ -95,7 +95,7 @@ struct PROC_RESOURCES { COPROCS pr_coprocs; void init() { - ncpus = gstate.ncpus; + ncpus = gstate.n_usable_cpus; ncpus_used_st = 0; ncpus_used_mt = 0; pr_coprocs.clone(coprocs, false); @@ -567,7 +567,7 @@ void CLIENT_STATE::reset_rec_accounting() { // static void update_rec() { double f = gstate.host_info.p_fpops; - double on_frac = gstate.global_prefs.cpu_usage_limit / 100; + double on_frac = gstate.current_cpu_usage_limit() / 100; for (unsigned int i=0; i& runnable_jobs) { vector::iterator cur = runnable_jobs.begin(); while(1) { if (cur == runnable_jobs.end()) break; - if (cpus_used >= gstate.ncpus) break; + if (cpus_used >= gstate.n_usable_cpus) break; RESULT* rp = *cur; if (rp->rr_sim_misses_deadline) break; double nc = rp->avp->avg_ncpus; @@ -1251,9 +1251,9 @@ bool CLIENT_STATE::enforce_run_list(vector& run_list) { // don't allow additional CPU jobs; // allow coproc jobs if the resulting CPU load is at most ncpus+1 // - if (ncpus_used >= ncpus) { + if (ncpus_used >= n_usable_cpus) { if (rp->uses_coprocs()) { - if (ncpus_used + rp->avp->avg_ncpus > ncpus+1) { + if (ncpus_used + rp->avp->avg_ncpus > n_usable_cpus+1) { if (log_flags.cpu_sched_debug) { msg_printf(rp->project, MSG_INFO, "[cpu_sched_debug] skipping GPU job %s; CPU committed", @@ -1266,7 +1266,7 @@ bool CLIENT_STATE::enforce_run_list(vector& run_list) { if (log_flags.cpu_sched_debug) { msg_printf(rp->project, MSG_INFO, "[cpu_sched_debug] all CPUs used (%.2f >= %d), skipping %s", - ncpus_used, ncpus, + ncpus_used, n_usable_cpus, rp->name ); } @@ -1350,11 +1350,11 @@ bool CLIENT_STATE::enforce_run_list(vector& run_list) { } } - if (log_flags.cpu_sched_debug && ncpus_used < ncpus) { + if (log_flags.cpu_sched_debug && ncpus_used < n_usable_cpus) { msg_printf(0, MSG_INFO, "[cpu_sched_debug] using %.2f out of %d CPUs", - ncpus_used, ncpus + ncpus_used, n_usable_cpus ); - if (ncpus_used < ncpus) { + if (ncpus_used < n_usable_cpus) { request_work_fetch("CPUs idle"); } } @@ -1622,12 +1622,14 @@ ACTIVE_TASK* CLIENT_STATE::get_task(RESULT* rp) { return atp; } -// called at startup (after get_host_info()) -// and when general prefs have been parsed. -// NOTE: GSTATE.NCPUS MUST BE 1 OR MORE; WE DIVIDE BY IT IN A COUPLE OF PLACES +// called: +// - at startup (after get_host_info()) +// - when general prefs have been parsed +// - when user_active changes +// NOTE: n_usable_cpus MUST BE 1 OR MORE; WE DIVIDE BY IT IN A COUPLE OF PLACES // -void CLIENT_STATE::set_ncpus() { - int ncpus_old = ncpus; +void CLIENT_STATE::set_n_usable_cpus() { + int ncpus_old = n_usable_cpus; // config file can say to act like host has N CPUs // @@ -1638,25 +1640,29 @@ void CLIENT_STATE::set_ncpus() { first = false; } if (cc_config.ncpus>0) { - ncpus = cc_config.ncpus; - host_info.p_ncpus = ncpus; // use this in scheduler requests + n_usable_cpus = cc_config.ncpus; + host_info.p_ncpus = n_usable_cpus; // use this in scheduler requests } else { host_info.p_ncpus = original_p_ncpus; - ncpus = host_info.p_ncpus; + n_usable_cpus = host_info.p_ncpus; } - if (ncpus <= 0) { - ncpus = 1; // shouldn't happen + + double p = global_prefs.max_ncpus_pct; + if (!user_active && global_prefs.niu_max_ncpus_pct>=0) { + p = global_prefs.niu_max_ncpus_pct; + } + if (p) { + n_usable_cpus = (int)((n_usable_cpus * p)/100); } - if (global_prefs.max_ncpus_pct) { - ncpus = (int)((ncpus * global_prefs.max_ncpus_pct)/100); - if (ncpus == 0) ncpus = 1; + if (n_usable_cpus <= 0) { + n_usable_cpus = 1; } - if (initialized && ncpus != ncpus_old) { + if (initialized && n_usable_cpus != ncpus_old) { msg_printf(0, MSG_INFO, "Number of usable CPUs has changed from %d to %d.", - ncpus_old, ncpus + ncpus_old, n_usable_cpus ); request_schedule_cpus("Number of usable CPUs has changed"); request_work_fetch("Number of usable CPUs has changed"); diff --git a/client/cs_benchmark.cpp b/client/cs_benchmark.cpp index 9020ee9a101..3483419333f 100644 --- a/client/cs_benchmark.cpp +++ b/client/cs_benchmark.cpp @@ -262,9 +262,9 @@ void CLIENT_STATE::start_cpu_benchmarks(bool force) { cpu_benchmarks_start = dtime(); benchmark_descs.clear(); - benchmark_descs.resize(ncpus); + benchmark_descs.resize(n_usable_cpus); - bm_ncpus = ncpus; + bm_ncpus = n_usable_cpus; benchmarks_running = true; for (i=0; i global_prefs.suspend_cpu_usage) { + if (non_boinc_cpu_usage*100 > current_suspend_cpu_usage()) { last_cpu_usage_suspend = now; return SUSPEND_REASON_CPU_USAGE; } @@ -301,26 +301,6 @@ int CLIENT_STATE::check_suspend_processing() { } #endif -#ifndef NEW_CPU_THROTTLE - // CPU throttling. - // Do this check last; that way if suspend_reason is CPU_THROTTLE, - // the GUI knows there's no other source of suspension - // - if (global_prefs.cpu_usage_limit < 99) { // round-off? - static double last_time=0, debt=0; - double diff = now - last_time; - last_time = now; - if (diff >= POLL_INTERVAL/2. && diff < POLL_INTERVAL*10.) { - debt += diff*global_prefs.cpu_usage_limit/100; - if (debt < 0) { - return SUSPEND_REASON_CPU_THROTTLE; - } else { - debt -= diff; - } - } - } -#endif - // CPU is not suspended. See if GPUs are // if (!coprocs.none()) { @@ -686,10 +666,10 @@ void CLIENT_STATE::read_global_prefs( #endif // max_cpus, bandwidth limits may have changed // - set_ncpus(); - if (ncpus != host_info.p_ncpus) { + set_n_usable_cpus(); + if (n_usable_cpus != host_info.p_ncpus) { msg_printf(NULL, MSG_INFO, - " max CPUs used: %d", ncpus + " max CPUs used: %d", n_usable_cpus ); } if (!global_prefs.run_if_user_active) { @@ -709,6 +689,12 @@ void CLIENT_STATE::read_global_prefs( global_prefs.suspend_cpu_usage ); } + if (global_prefs.niu_suspend_cpu_usage > 0) { + msg_printf(NULL, MSG_INFO, + " when idle, suspend work if non-BOINC CPU load exceeds %.0f%%", + global_prefs.niu_suspend_cpu_usage + ); + } if (global_prefs.max_bytes_sec_down) { msg_printf(NULL, MSG_INFO, " max download rate: %.0f bytes/sec", diff --git a/client/cs_scheduler.cpp b/client/cs_scheduler.cpp index eafccd5e136..6923e775a6e 100644 --- a/client/cs_scheduler.cpp +++ b/client/cs_scheduler.cpp @@ -211,7 +211,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p) { // update hardware info, and write host info // host_info.get_host_info(false); - set_ncpus(); + set_n_usable_cpus(); host_info.write(mf, !cc_config.suppress_net_info, false); // get and write disk usage diff --git a/client/gui_rpc_server_ops.cpp b/client/gui_rpc_server_ops.cpp index 7698112a6f1..31770c3a917 100644 --- a/client/gui_rpc_server_ops.cpp +++ b/client/gui_rpc_server_ops.cpp @@ -636,7 +636,7 @@ static void handle_reset_host_info(GUI_RPC_CONN& grc) { gstate.host_info.get_host_info(true); // the amount of RAM or #CPUs may have changed // - gstate.set_ncpus(); + gstate.set_n_usable_cpus(); gstate.request_schedule_cpus("reset_host_info"); gstate.show_host_info(); grc.mfout.printf("\n"); @@ -1331,7 +1331,7 @@ static void handle_read_cc_config(GUI_RPC_CONN& grc) { read_config_file(false); cc_config.show(); log_flags.show(); - gstate.set_ncpus(); + gstate.set_n_usable_cpus(); process_gpu_exclusions(); // also reread app_config.xml files @@ -1349,12 +1349,12 @@ static void handle_get_daily_xfer_history(GUI_RPC_CONN& grc) { #ifdef __APPLE__ static void stop_graphics_app(pid_t thePID, - long iBrandID, - char current_dir[], - char switcher_path[], - string theScreensaverLoginUser, - GUI_RPC_CONN& grc - ) { + long iBrandID, + char current_dir[], + char switcher_path[], + string theScreensaverLoginUser, + GUI_RPC_CONN& grc +) { char* argv[16]; int argc; char screensaverLoginUser[256]; @@ -1365,19 +1365,19 @@ static void stop_graphics_app(pid_t thePID, char pidString[10]; snprintf(pidString, sizeof(pidString), "%d", thePID); - #if 1 +#if 1 argv[0] = const_cast(SWITCHER_FILE_NAME); argv[1] = saverName[iBrandID]; argv[2] = "-kill_gfx"; argv[3] = pidString; argc = 4; - #else +#else argv[0] = const_cast(SWITCHER_FILE_NAME); argv[1] = "/bin/kill"; argv[2] = "-kill"; argv[3] = (char *)pidString; argc = 4; - #endif +#endif if (!theScreensaverLoginUser.empty()) { argv[argc++] = "--ScreensaverLoginUser"; safe_strcpy(screensaverLoginUser, theScreensaverLoginUser.c_str()); diff --git a/client/rr_sim.cpp b/client/rr_sim.cpp index 73b4d8bef38..2320ea65e90 100644 --- a/client/rr_sim.cpp +++ b/client/rr_sim.cpp @@ -368,7 +368,7 @@ void RR_SIM::pick_jobs_to_run(double reltime) { continue; } } else { - if (rsc_work_fetch[rt].sim_nused >= gstate.ncpus) break; + if (rsc_work_fetch[rt].sim_nused >= gstate.n_usable_cpus) break; } ++rsc_pwf.pending_iter; } @@ -403,7 +403,7 @@ void RR_SIM::pick_jobs_to_run(double reltime) { // after the initial assignment of jobs // static void record_nidle_now() { - rsc_work_fetch[0].nidle_now = gstate.ncpus - rsc_work_fetch[0].sim_nused; + rsc_work_fetch[0].nidle_now = gstate.n_usable_cpus - rsc_work_fetch[0].sim_nused; if (rsc_work_fetch[0].nidle_now < 0) rsc_work_fetch[0].nidle_now = 0; for (int i=1; i gstate.ncpus) { - cpu_scale = (gstate.ncpus - cpu_usage_gpu) / (cpu_usage - cpu_usage_gpu); + if (cpu_usage > gstate.n_usable_cpus) { + cpu_scale = (gstate.n_usable_cpus - cpu_usage_gpu) / (cpu_usage - cpu_usage_gpu); } double used = 0; diff --git a/client/work_fetch.cpp b/client/work_fetch.cpp index 31d105f8a68..e54cb0ab3d2 100644 --- a/client/work_fetch.cpp +++ b/client/work_fetch.cpp @@ -1077,7 +1077,7 @@ void WORK_FETCH::set_initial_work_request(PROJECT* p) { // called once, at client startup // void WORK_FETCH::init() { - rsc_work_fetch[0].init(0, gstate.ncpus, 1); + rsc_work_fetch[0].init(0, gstate.n_usable_cpus, 1); double cpu_flops = gstate.host_info.p_fpops; // use 20% as a rough estimate of GPU efficiency @@ -1127,7 +1127,7 @@ void CLIENT_STATE::compute_nuploading_results() { rp->project->nuploading_results++; } } - int n = gstate.ncpus; + int n = gstate.n_usable_cpus; for (int j=1; j n) { n = coprocs.coprocs[j].count; diff --git a/html/inc/prefs.inc b/html/inc/prefs.inc index 2b3021aa987..e22326939fe 100644 --- a/html/inc/prefs.inc +++ b/html/inc/prefs.inc @@ -1,7 +1,7 @@
"); @@ -323,29 +342,33 @@ function element_end_global($parser, $name) { global $parse_result; global $top_parse_result; global $venue_name; - global $cpu_prefs; + global $in_use_prefs; + global $not_in_use_prefs; + global $job_prefs; global $disk_prefs; - global $mem_prefs; global $net_prefs; - foreach ($cpu_prefs as $p) { - if (is_string($p)) continue; + foreach ($in_use_prefs as $p) { if ($p->xml_parse($parse_result, $name, $text)) { return; } } - foreach ($disk_prefs as $p) { + foreach ($not_in_use_prefs as $p) { + if ($p->xml_parse($parse_result, $name, $text)) { + return; + } + } + foreach ($job_prefs as $p) { if ($p->xml_parse($parse_result, $name, $text)) { return; } } - foreach ($mem_prefs as $p) { + foreach ($disk_prefs as $p) { if ($p->xml_parse($parse_result, $name, $text)) { return; } } foreach ($net_prefs as $p) { - if (is_string($p)) continue; if ($p->xml_parse($parse_result, $name, $text)) { return; } @@ -374,24 +397,26 @@ function char_handler($parser, $x) { // state of prefs before parsing; defines prefs for new users // function default_prefs_global() { - global $cpu_prefs; + global $in_use_prefs; + global $not_in_use_prefs; + global $job_prefs; global $disk_prefs; - global $mem_prefs; global $net_prefs; $p = new StdClass; - foreach ($cpu_prefs as $pref) { - if (is_string($pref)) continue; + foreach ($in_use_prefs as $pref) { $pref->set_default($p); } - foreach ($disk_prefs as $pref) { + foreach ($not_in_use_prefs as $pref) { $pref->set_default($p); } - foreach ($mem_prefs as $pref) { + foreach ($job_prefs as $pref) { + $pref->set_default($p); + } + foreach ($disk_prefs as $pref) { $pref->set_default($p); } foreach ($net_prefs as $pref) { - if (is_string($pref)) continue; $pref->set_default($p); } return $p; @@ -414,66 +439,60 @@ function prefs_parse_global($prefs_xml) { // Display all venues as columns next to descriptions // function prefs_show_columns_global($prefs) { - global $cpu_prefs; + global $in_use_prefs; + global $not_in_use_prefs; + global $job_prefs; global $disk_prefs; - global $mem_prefs; global $net_prefs; - row_top(CPU_LIMIT_DESC); - foreach ($cpu_prefs as $p) { - if (is_string($p)) { - group_header($p); - continue; - } + row_top(IN_USE_DESC); + foreach ($in_use_prefs as $p) { $p->show_cols($prefs); } - row_top(DISK_LIMIT_DESC); - foreach ($disk_prefs as $p) { + row_top(NOT_IN_USE_DESC); + foreach ($not_in_use_prefs as $p) { + $p->show_cols($prefs); + } + row_top(JOBS_DESC); + foreach ($job_prefs as $p) { $p->show_cols($prefs); } - row_top(MEM_LIMIT_DESC); - foreach ($mem_prefs as $p) { + row_top(DISK_DESC); + foreach ($disk_prefs as $p) { $p->show_cols($prefs); } - row_top(NETWORK_LIMIT_DESC); + row_top(NET_DESC); foreach ($net_prefs as $p) { - if (is_string($p)) { - group_header($p); - continue; - } $p->show_cols($prefs); } row_links("global", $prefs); } function prefs_show_global($prefs) { - global $cpu_prefs; + global $in_use_prefs; + global $not_in_use_prefs; + global $job_prefs; global $disk_prefs; - global $mem_prefs; global $net_prefs; - row1(CPU_LIMIT_DESC); - foreach ($cpu_prefs as $p) { - if (is_string($p)) { - group_header($p); - continue; - } + row1(IN_USE_DESC); + foreach ($in_use_prefs as $p) { $p->show($prefs); } - row1(DISK_LIMIT_DESC); - foreach ($disk_prefs as $p) { + row1(NOT_IN_USE_DESC); + foreach ($not_in_use_prefs as $p) { $p->show($prefs); } - row1(MEM_LIMIT_DESC); - foreach ($mem_prefs as $p) { + row1(JOBS_DESC); + foreach ($job_prefs as $p) { $p->show($prefs); } - row1(NETWORK_LIMIT_DESC); + row1(DISK_DESC); + foreach ($disk_prefs as $p) { + $p->show($prefs); + } + row1(NET_DESC); foreach ($net_prefs as $p) { - if (is_string($p)) { - group_header($p); - continue; - } $p->show($prefs); } } @@ -491,7 +510,7 @@ function prefs_display_venue($prefs, $venue, $subset) { if ($x) { start_table(); - row_heading(tra("Separate preferences for %1", $venue)); + row_heading(tra("Separate preferences for %1", $venue), 'bg-info'); if ($subset == "global") { prefs_show_global($x); } else { @@ -604,33 +623,30 @@ function print_prefs_form( // Functions to display preference subsets as forms // function prefs_form_global($user, $prefs, $error=false) { - global $cpu_prefs; + global $in_use_prefs; + global $not_in_use_prefs; + global $job_prefs; global $disk_prefs; - global $mem_prefs; global $net_prefs; - row1(CPU_LIMIT_DESC); - foreach ($cpu_prefs as $p) { - if (is_string($p)) { - group_header($p); - continue; - } + row1(IN_USE_DESC); + foreach ($in_use_prefs as $p) { $p->show_form_row($prefs, $error); } - row1(DISK_LIMIT_DESC); - foreach ($disk_prefs as $p) { + row1(NOT_IN_USE_DESC); + foreach ($not_in_use_prefs as $p) { + $p->show_form_row($prefs, $error); + } + row1(JOBS_DESC); + foreach ($job_prefs as $p) { $p->show_form_row($prefs, $error); } - row1(MEM_LIMIT_DESC); - foreach ($mem_prefs as $p) { + row1(DISK_DESC); + foreach ($disk_prefs as $p) { $p->show_form_row($prefs, $error); } - row1(NETWORK_LIMIT_DESC); + row1(NET_DESC); foreach ($net_prefs as $p) { - if (is_string($p)) { - group_header($p); - continue; - } $p->show_form_row($prefs, $error); } } @@ -697,24 +713,26 @@ function venue_parse_form(&$user) { // returns an object with errorvalues or false in success case // function prefs_global_parse_form(&$prefs) { - global $cpu_prefs; + global $in_use_prefs; + global $not_in_use_prefs; + global $job_prefs; global $disk_prefs; - global $mem_prefs; global $net_prefs; $error = false; - foreach ($cpu_prefs as $p) { - if (is_string($p)) continue; + foreach ($in_use_prefs as $p) { $p->parse_form($prefs, $error); } - foreach ($disk_prefs as $p) { + foreach ($not_in_use_prefs as $p) { $p->parse_form($prefs, $error); } - foreach ($mem_prefs as $p) { + foreach ($job_prefs as $p) { + $p->parse_form($prefs, $error); + } + foreach ($disk_prefs as $p) { $p->parse_form($prefs, $error); } foreach ($net_prefs as $p) { - if (is_string($p)) continue; $p->parse_form($prefs, $error); } return $error; @@ -726,9 +744,10 @@ function prefs_global_parse_form(&$prefs) { // convert prefs from structure to XML // function global_prefs_make_xml($prefs, $primary=true) { - global $cpu_prefs; + global $in_use_prefs; + global $not_in_use_prefs; + global $job_prefs; global $disk_prefs; - global $mem_prefs; global $net_prefs; $xml = ""; @@ -738,18 +757,19 @@ function global_prefs_make_xml($prefs, $primary=true) { $xml = $xml."$now\n"; } - foreach ($cpu_prefs as $p) { - if (is_string($p)) continue; + foreach ($in_use_prefs as $p) { $xml .= $p->xml_string($prefs); } - foreach ($disk_prefs as $p) { + foreach ($not_in_use_prefs as $p) { $xml .= $p->xml_string($prefs); } - foreach ($mem_prefs as $p) { + foreach ($job_prefs as $p) { + $xml .= $p->xml_string($prefs); + } + foreach ($disk_prefs as $p) { $xml .= $p->xml_string($prefs); } foreach ($net_prefs as $p) { - if (is_string($p)) continue; $xml .= $p->xml_string($prefs); } diff --git a/lib/prefs.cpp b/lib/prefs.cpp index e7d90be7264..aec0005c8ec 100644 --- a/lib/prefs.cpp +++ b/lib/prefs.cpp @@ -60,6 +60,9 @@ void GLOBAL_PREFS_MASK::set_all() { net_end_hour = true; net_start_hour = true; network_wifi_only = true; + niu_max_ncpus_pct = true; + niu_cpu_usage_limit = true; + niu_suspend_cpu_usage = true; ram_max_used_busy_frac = true; ram_max_used_idle_frac = true; run_gpu_if_user_active = true; @@ -97,6 +100,9 @@ bool GLOBAL_PREFS_MASK::are_prefs_set() { if (net_start_hour) return true; if (network_wifi_only) return true; if (net_end_hour) return true; + if (niu_max_ncpus_pct) return true; + if (niu_cpu_usage_limit) return true; + if (niu_suspend_cpu_usage) return true; if (ram_max_used_busy_frac) return true; if (ram_max_used_idle_frac) return true; if (run_gpu_if_user_active) return true; @@ -232,6 +238,9 @@ void GLOBAL_PREFS::defaults() { #else network_wifi_only = false; #endif + niu_max_ncpus_pct = -1; // -1 means unspecified, use max_ncpus_pct + niu_cpu_usage_limit = -1; + niu_suspend_cpu_usage = -1; ram_max_used_busy_frac = 0.5; #ifdef ANDROID ram_max_used_idle_frac = 0.5; @@ -460,6 +469,10 @@ int GLOBAL_PREFS::parse_override( mask.suspend_cpu_usage = true; continue; } + if (xp.parse_double("niu_suspend_cpu_usage", niu_suspend_cpu_usage)) { + mask.niu_suspend_cpu_usage = true; + continue; + } if (xp.parse_double("start_hour", cpu_times.start_hour)) { mask.start_hour = true; continue; @@ -512,6 +525,12 @@ int GLOBAL_PREFS::parse_override( mask.max_ncpus_pct = true; continue; } + if (xp.parse_double("niu_max_ncpus_pct", niu_max_ncpus_pct)) { + if (niu_max_ncpus_pct < 0) niu_max_ncpus_pct = 0; + if (niu_max_ncpus_pct > 100) niu_max_ncpus_pct = 100; + mask.niu_max_ncpus_pct = true; + continue; + } if (xp.parse_int("max_cpus", max_ncpus)) { if (max_ncpus < 0) max_ncpus = 0; mask.max_ncpus = true; @@ -573,6 +592,13 @@ int GLOBAL_PREFS::parse_override( } continue; } + if (xp.parse_double("niu_cpu_usage_limit", dtemp)) { + if (dtemp > 0 && dtemp <= 100) { + niu_cpu_usage_limit = dtemp; + mask.niu_cpu_usage_limit = true; + } + continue; + } if (xp.parse_double("daily_xfer_limit_mb", dtemp)) { if (dtemp >= 0) { daily_xfer_limit_mb = dtemp; @@ -652,6 +678,9 @@ int GLOBAL_PREFS::write(MIOFILE& f) { " %f\n" " %f\n" " %f\n" + " %f\n" + " %f\n" + " %f\n" " %f\n" " %f\n" " %f\n" @@ -688,6 +717,9 @@ int GLOBAL_PREFS::write(MIOFILE& f) { work_buf_min_days, work_buf_additional_days, max_ncpus_pct, + niu_max_ncpus_pct, + niu_cpu_usage_limit, + niu_suspend_cpu_usage, cpu_scheduling_period_minutes, disk_interval, disk_max_used_gb, @@ -778,7 +810,6 @@ int GLOBAL_PREFS::write_subset(MIOFILE& f, GLOBAL_PREFS_MASK& mask) { ); } if (mask.suspend_cpu_usage) { - f.printf(" %f\n", suspend_cpu_usage ); @@ -834,6 +865,17 @@ int GLOBAL_PREFS::write_subset(MIOFILE& f, GLOBAL_PREFS_MASK& mask) { if (mask.max_ncpus_pct) { f.printf(" %f\n", max_ncpus_pct); } + if (mask.niu_max_ncpus_pct) { + f.printf(" %f\n", niu_max_ncpus_pct); + } + if (mask.niu_cpu_usage_limit) { + f.printf(" %f\n", niu_cpu_usage_limit); + } + if (mask.niu_suspend_cpu_usage) { + f.printf(" %f\n", + niu_suspend_cpu_usage + ); + } if (mask.max_ncpus) { f.printf(" %d\n", max_ncpus); } diff --git a/lib/prefs.h b/lib/prefs.h index eb2166d71d4..da5ffe7ccd2 100644 --- a/lib/prefs.h +++ b/lib/prefs.h @@ -59,6 +59,9 @@ struct GLOBAL_PREFS_MASK { bool net_end_hour; bool net_start_hour; bool network_wifi_only; + bool niu_cpu_usage_limit; + bool niu_max_ncpus_pct; + bool niu_suspend_cpu_usage; bool ram_max_used_busy_frac; bool ram_max_used_idle_frac; bool run_if_user_active; @@ -143,8 +146,8 @@ struct TIME_PREFS : public TIME_SPAN { struct GLOBAL_PREFS { double mod_time; - double battery_charge_min_pct; - double battery_max_temperature; + double battery_charge_min_pct; // Android + double battery_max_temperature; // Android bool confirm_before_connecting; double cpu_scheduling_period_minutes; // length of a time slice. @@ -172,6 +175,9 @@ struct GLOBAL_PREFS { // not on public cell networks. // CAUTION: this only applies to file transfers. // scheduler RPCs are made regardless of this preference. + double niu_cpu_usage_limit; + double niu_max_ncpus_pct; + double niu_suspend_cpu_usage; double ram_max_used_busy_frac; double ram_max_used_idle_frac; bool run_gpu_if_user_active; From 3ce929114589590f0dd40c427a019cf10a6f0ba0 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 6 Aug 2022 06:58:39 -0700 Subject: [PATCH 02/21] change "Tasks" to "General" --- html/inc/prefs.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/inc/prefs.inc b/html/inc/prefs.inc index e22326939fe..ccfca5aa1c2 100644 --- a/html/inc/prefs.inc +++ b/html/inc/prefs.inc @@ -258,7 +258,7 @@ $net_prefs = array( define("IN_USE_DESC", tra("When computer is in use")); define("NOT_IN_USE_DESC", tra("When computer is not in use")); -define("JOBS_DESC", tra("Tasks")); +define("JOBS_DESC", tra("General")); define("DISK_DESC", tra("Disk")); define("NET_DESC", tra("Network")); From 50f56c5b21ab8c813d4a2b32fc89e788bdc168f3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 6 Aug 2022 12:34:43 -0700 Subject: [PATCH 03/21] Manager: restructure compute prefs; add not-in-use prefs --- clientgui/DlgAdvPreferences.cpp | 51 ++- clientgui/DlgAdvPreferencesBase.cpp | 461 ++++++++++++++-------------- clientgui/DlgAdvPreferencesBase.h | 97 +++--- 3 files changed, 331 insertions(+), 278 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 2fb34f6f54b..55d8fd0bcf7 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -131,7 +131,9 @@ void CDlgAdvPreferences::SetValidators() { // ######### proc usage page m_txtProcUseProcessors->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); + m_txtProcUseProcessorsNotInUse->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); m_txtProcUseCPUTime->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); + m_txtProcUseCPUTimeNotInUse->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); m_txtProcIdleFor->SetValidator(wxTextValidator(wxFILTER_NUMERIC)); m_txtProcIdleFor->SetMaxLength(16); @@ -276,7 +278,8 @@ void CDlgAdvPreferences::DisplayValue(double value, wxTextCtrl* textCtrl, wxChec } -/* read preferences from core client and initialize control values */ +// read preferences from core client and initialize control values +// void CDlgAdvPreferences::ReadPreferenceSettings() { CMainDocument* pDoc = wxGetApp().GetDocument(); int retval; @@ -303,11 +306,13 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { // 0 means "no restriction" but we don't use a checkbox here if (prefs.max_ncpus_pct == 0.0) prefs.max_ncpus_pct = 100.0; DisplayValue(prefs.max_ncpus_pct, m_txtProcUseProcessors); + DisplayValue(prefs.niu_max_ncpus_pct, m_txtProcUseProcessorsNotInUse); - //cpu limit + // cpu limit // 0 means "no restriction" but we don't use a checkbox here if (prefs.cpu_usage_limit == 0.0) prefs.cpu_usage_limit = 100.0; DisplayValue(prefs.cpu_usage_limit, m_txtProcUseCPUTime); + DisplayValue(prefs.niu_cpu_usage_limit, m_txtProcUseCPUTimeNotInUse); // on batteries m_chkProcOnBatteries->SetValue(! prefs.run_on_batteries); @@ -335,6 +340,8 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { DisplayValue(prefs.suspend_if_no_recent_input, m_txtNoRecentInput); m_chkMaxLoad->SetValue(prefs.suspend_cpu_usage > 0.0); DisplayValue(prefs.suspend_cpu_usage, m_txtMaxLoad, m_chkMaxLoad); + m_chkMaxLoadNotInUse->SetValue(prefs.niu_suspend_cpu_usage > 0.0); + DisplayValue(prefs.niu_suspend_cpu_usage, m_txtMaxLoadNotInUse, m_chkMaxLoadNotInUse); // connection interval DisplayValue(prefs.work_buf_min_days, m_txtNetConnectInterval); @@ -434,8 +441,9 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { this->UpdateControlStates(); } -/* write overridden preferences to disk (global_prefs_override.xml) */ -/* IMPORTANT: Any items added here must be checked in ValidateInput()! */ +// write overridden preferences to disk (global_prefs_override.xml) +// IMPORTANT: Any items added here must be checked in ValidateInput()! +// bool CDlgAdvPreferences::SavePreferencesSettings() { double td; @@ -445,11 +453,16 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { m_txtProcUseProcessors->GetValue().ToDouble(&td); prefs.max_ncpus_pct = RoundToHundredths(td); mask.max_ncpus_pct=true; + m_txtProcUseProcessorsNotInUse->GetValue().ToDouble(&td); + prefs.niu_max_ncpus_pct = RoundToHundredths(td); + mask.niu_max_ncpus_pct=true; - // m_txtProcUseCPUTime->GetValue().ToDouble(&td); prefs.cpu_usage_limit=RoundToHundredths(td); mask.cpu_usage_limit=true; + m_txtProcUseCPUTimeNotInUse->GetValue().ToDouble(&td); + prefs.niu_cpu_usage_limit = RoundToHundredths(td); + mask.niu_cpu_usage_limit = true; prefs.run_on_batteries = ! (m_chkProcOnBatteries->GetValue()); mask.run_on_batteries=true; @@ -466,12 +479,10 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { mask.idle_time_to_run=true; } - // m_txtNoRecentInput->GetValue().ToDouble(&td); prefs.suspend_if_no_recent_input = RoundToHundredths(td); mask.suspend_if_no_recent_input = true; - // if (m_chkMaxLoad->IsChecked()) { m_txtMaxLoad->GetValue().ToDouble(&td); prefs.suspend_cpu_usage=RoundToHundredths(td); @@ -480,6 +491,14 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { } mask.suspend_cpu_usage=true; + if (m_chkMaxLoadNotInUse->IsChecked()) { + m_txtMaxLoadNotInUse->GetValue().ToDouble(&td); + prefs.niu_suspend_cpu_usage=RoundToHundredths(td); + } else { + prefs.niu_suspend_cpu_usage = 0.0; + } + mask.niu_suspend_cpu_usage=true; + m_txtNetConnectInterval->GetValue().ToDouble(&td); prefs.work_buf_min_days=RoundToHundredths(td); mask.work_buf_min_days=true; @@ -697,10 +716,15 @@ bool CDlgAdvPreferences::ValidateInput() { ShowErrorMessage(invMsgLimit100, m_txtProcUseProcessors); return false; } + buffer = m_txtProcUseProcessorsNotInUse->GetValue(); + if(!IsValidFloatValueBetween(buffer, 0.0, 100.0)) { + ShowErrorMessage(invMsgLimit100, m_txtProcUseProcessorsNotInUse); + return false; + } - buffer = m_txtProcUseCPUTime->GetValue(); + buffer = m_txtProcUseCPUTimeNotInUse->GetValue(); if(!IsValidFloatValueBetween(buffer, 0.0, 100.0)) { - ShowErrorMessage(invMsgLimit100, m_txtProcUseCPUTime); + ShowErrorMessage(invMsgLimit100, m_txtProcUseCPUTimeNotInUse); return false; } @@ -725,8 +749,15 @@ bool CDlgAdvPreferences::ValidateInput() { return false; } } + if (m_chkMaxLoadNotInUse->IsChecked()) { + buffer = m_txtMaxLoadNotInUse->GetValue(); + if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) { + ShowErrorMessage(invMsgLimit1_100, m_txtMaxLoadNotInUse); + return false; + } + } - //limit additional days from 0 to 10 + // limit additional days from 0 to 10 buffer = m_txtNetConnectInterval->GetValue(); if(!IsValidFloatValueBetween(buffer, 0.0, 10.0)) { ShowErrorMessage(invMsgLimit10,m_txtNetConnectInterval); diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index 11cc1b20f24..daaa49e8f87 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -156,7 +156,7 @@ CDlgAdvPreferencesBase::CDlgAdvPreferencesBase( wxWindow* parent, int id, wxStri m_panelDiskAndMemory = createDiskAndMemoryTab(m_Notebook); iImageIndex = pImageList->Add(wxBitmap(usage_xpm)); - m_Notebook->AddPage( m_panelDiskAndMemory, _("Disk and memory"), true, iImageIndex ); + m_Notebook->AddPage( m_panelDiskAndMemory, _("Disk"), true, iImageIndex ); m_panelDailySchedules = createDailySchedulesTab(m_Notebook); iImageIndex = pImageList->Add(wxBitmap(clock_xpm)); @@ -238,8 +238,7 @@ void CDlgAdvPreferencesBase::addNewRowToSizer( } -wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) -{ +wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxASSERT(pSkinAdvanced); @@ -250,233 +249,272 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) wxBoxSizer* processorTabSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBox* usageLimitsStaticBox = new wxStaticBox(processorTab, -1, _("Usage limits") ); - wxStaticBoxSizer* usageLimitsBoxSizer = new wxStaticBoxSizer(usageLimitsStaticBox, wxVERTICAL); - makeStaticBoxLabelItalic(usageLimitsStaticBox); - - /*xgettext:no-c-format*/ - wxString MaxCPUPctTT(_("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.")); - wxStaticText* staticText20 = new wxStaticText( - usageLimitsStaticBox, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txtProcUseProcessors = new wxTextCtrl( usageLimitsStaticBox, ID_TXTPROCUSEPROCESSORS, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - /*xgettext:no-c-format*/ - wxStaticText* staticText21 = new wxStaticText( usageLimitsStaticBox, ID_DEFAULT, _("% of the CPUs"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(usageLimitsBoxSizer, MaxCPUPctTT, staticText20, m_txtProcUseProcessors, staticText21); - - /*xgettext:no-c-format*/ - wxString MaxCPUTimeTT(_("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.")); - wxStaticText* staticText22 = new wxStaticText( - usageLimitsStaticBox, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txtProcUseCPUTime = new wxTextCtrl( usageLimitsStaticBox, ID_TXTPROCUSECPUTIME, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - /*xgettext:no-c-format*/ - wxStaticText* staticText23 = new wxStaticText( usageLimitsStaticBox, ID_DEFAULT, _("% of CPU time"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(usageLimitsBoxSizer, MaxCPUTimeTT, staticText22, m_txtProcUseCPUTime, staticText23); - - processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); - processorTabSizer->Add( usageLimitsBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); - - wxStaticBox* suspendComputingStaticBox = new wxStaticBox(processorTab, -1, _("When to suspend") ); - wxStaticBoxSizer* suspendComputingBoxSizer = new wxStaticBoxSizer(suspendComputingStaticBox, wxVERTICAL); - makeStaticBoxLabelItalic(suspendComputingStaticBox); + // ------------ In-use box -------------- + // + wxStaticBox* box = new wxStaticBox(processorTab, -1, _("When computer is in use") ); + wxStaticBoxSizer* box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); + makeStaticBoxLabelItalic(box); - m_chkProcOnBatteries = new wxCheckBox( - suspendComputingStaticBox, ID_CHKPROCONBATTERIES, - _("Suspend when computer is on battery"), wxDefaultPosition, wxDefaultSize, 0 + // in-use if input in last X min + // + wxString ProcIdleForTT(_("This determines when the computer is considered 'in use'.")); + wxStaticText* staticText24 = new wxStaticText( + box, ID_DEFAULT, + // context: 'In use' means mouse/keyboard input in last ___ minutes + _("'In use' means mouse/keyboard input in last"), + wxDefaultPosition, wxDefaultSize, 0 ); - m_chkProcOnBatteries->SetToolTip( - _("Check this to suspend computing on portables when running on battery power.") + m_txtProcIdleFor = new wxTextCtrl( + box, ID_TXTPROCIDLEFOR, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT + ); + wxStaticText* staticText25 = new wxStaticText( + box, ID_DEFAULT, + // context: 'In use' means mouse/keyboard input in last ___ minutes + _("minutes"), + wxDefaultPosition, wxDefaultSize, 0 ); - suspendComputingBoxSizer->Add( m_chkProcOnBatteries, 0, wxALL, 5 ); + addNewRowToSizer(box_sizer, ProcIdleForTT, staticText24, m_txtProcIdleFor, staticText25); + // suspend while in use + // m_chkProcInUse = new wxCheckBox( - suspendComputingStaticBox, ID_CHKPROCINUSE, + box, ID_CHKPROCINUSE, _("Suspend when computer is in use"), wxDefaultPosition, wxDefaultSize, 0 ); m_chkProcInUse->SetToolTip( _("Check this to suspend computing and file transfers when you're using the computer.") ); - suspendComputingBoxSizer->Add( m_chkProcInUse, 0, wxALL, 5 ); + box_sizer->Add( m_chkProcInUse, 0, wxALL, 5 ); + // suspend GPU while in use + // m_chkGPUProcInUse = new wxCheckBox( - suspendComputingStaticBox, ID_CHKGPUPROCINUSE, + box, ID_CHKGPUPROCINUSE, _("Suspend GPU computing when computer is in use"), wxDefaultPosition, wxDefaultSize, 0 ); m_chkGPUProcInUse->SetToolTip( _("Check this to suspend GPU computing when you're using the computer.") ); - suspendComputingBoxSizer->Add( m_chkGPUProcInUse, 0, wxALL, 5 ); + box_sizer->Add( m_chkGPUProcInUse, 0, wxALL, 5 ); - // min idle time - wxString ProcIdleForTT(_("This determines when the computer is considered 'in use'.")); - - wxStaticText* staticText24 = new wxStaticText( - suspendComputingStaticBox, ID_DEFAULT, - // context: 'In use' means mouse/keyboard input in last ___ minutes - _("'In use' means mouse/keyboard input in last"), - wxDefaultPosition, wxDefaultSize, 0 - ); + // max # CPUs + // + /*xgettext:no-c-format*/ + wxString MaxCPUPctTT(_("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.")); + wxStaticText* staticText20 = new wxStaticText( + box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtProcUseProcessors = new wxTextCtrl(box, ID_TXTPROCUSEPROCESSORS, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + /*xgettext:no-c-format*/ + wxStaticText* staticText21 = new wxStaticText(box, ID_DEFAULT, _("% of the CPUs"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, MaxCPUPctTT, staticText20, m_txtProcUseProcessors, staticText21); - m_txtProcIdleFor = new wxTextCtrl( - suspendComputingStaticBox, ID_TXTPROCIDLEFOR, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT + // CPU throttling + // + /*xgettext:no-c-format*/ + wxString MaxCPUTimeTT(_("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.")); + wxStaticText* staticText22 = new wxStaticText( + box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txtProcUseCPUTime = new wxTextCtrl(box, ID_TXTPROCUSECPUTIME, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + /*xgettext:no-c-format*/ + wxStaticText* staticText23 = new wxStaticText(box, ID_DEFAULT, _("% of CPU time"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, MaxCPUTimeTT, staticText22, m_txtProcUseCPUTime, staticText23); - wxStaticText* staticText25 = new wxStaticText( - suspendComputingStaticBox, ID_DEFAULT, - // context: 'In use' means mouse/keyboard input in last ___ minutes - _("minutes"), + // max CPU load + // + wxString MaxLoadCheckBoxText = wxEmptyString; + MaxLoadCheckBoxText.Printf(_("Suspend when non-BOINC CPU usage is above")); + wxString MaxLoadTT(_("Suspend computing when your computer is busy running other programs.")); + m_chkMaxLoad = new wxCheckBox( + box, ID_CHKMAXLOAD, MaxLoadCheckBoxText, wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtMaxLoad = new wxTextCtrl( + box, ID_TXTMAXLOAD, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("100.00")), wxTE_RIGHT + ); + wxStaticText* staticText26 = new wxStaticText( box, ID_DEFAULT, wxT("%"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, MaxLoadTT, m_chkMaxLoad, m_txtMaxLoad, staticText26); - addNewRowToSizer(suspendComputingBoxSizer, ProcIdleForTT, staticText24, m_txtProcIdleFor, staticText25); + // max memory while in use + // + wxString MemoryMaxInUseTT = wxEmptyString; + MemoryMaxInUseTT.Printf(_("Limit the memory used by %s when you're using the computer."), pSkinAdvanced->GetApplicationShortName().c_str()); + wxStaticText* staticText50 = new wxStaticText(box, ID_DEFAULT, _("When computer is in use, use at most"), wxDefaultPosition, wxDefaultSize, 0 ); + textCtrlSize = getTextCtrlSize(wxT("100.00")); + m_txtMemoryMaxInUse = new wxTextCtrl( box, ID_TXTMEMORYMAXINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + /*xgettext:no-c-format*/ + wxStaticText* staticText51 = new wxStaticText( box, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, MemoryMaxInUseTT, staticText50, m_txtMemoryMaxInUse, staticText51); - // suspend after max idle time - wxString NoRecentInputTT(_("This allows some computers to enter low-power mode when not in use.")); + processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); + processorTabSizer->Add(box, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); + + // ------------ Not-in-use box -------------- + // + box = new wxStaticBox(processorTab, -1, _("When computer is not in use") ); + box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); + makeStaticBoxLabelItalic(box); + + // max # CPUs + // + /*xgettext:no-c-format*/ + m_txtProcUseProcessorsNotInUse = new wxTextCtrl(box, ID_TXTPROCUSEPROCESSORSNOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + addNewRowToSizer(box_sizer, MaxCPUPctTT, staticText20, m_txtProcUseProcessorsNotInUse, staticText21); + + // CPU throttling + // + m_txtProcUseCPUTimeNotInUse = new wxTextCtrl(box, ID_TXTPROCUSECPUTIMENOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + addNewRowToSizer(box_sizer, MaxCPUTimeTT, staticText22, m_txtProcUseCPUTimeNotInUse, staticText23); + + // max CPU load + // + m_chkMaxLoadNotInUse = new wxCheckBox( + box, ID_CHKMAXLOADNOTINUSE, MaxLoadCheckBoxText, wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtMaxLoadNotInUse = new wxTextCtrl( + box, ID_TXTMAXLOADNOTINUSE, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("100.00")), wxTE_RIGHT + ); + addNewRowToSizer(box_sizer, MaxLoadTT, m_chkMaxLoadNotInUse, m_txtMaxLoadNotInUse, staticText26); + + // max memory when not in use + // + wxString MemoryMaxOnIdleTT = wxEmptyString; + MemoryMaxOnIdleTT.Printf(_("Limit the memory used by %s when you're not using the computer."), pSkinAdvanced->GetApplicationShortName().c_str()); + wxStaticText* staticText52 = new wxStaticText( box, ID_DEFAULT, _("When computer is not in use, use at most"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txtMemoryMaxOnIdle = new wxTextCtrl( box, ID_TXTMEMORYMAXONIDLE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + /*xgettext:no-c-format*/ + wxStaticText* staticText53 = new wxStaticText( box, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, MemoryMaxOnIdleTT, staticText52, m_txtMemoryMaxOnIdle, staticText53); + + // suspend after idle time + // + wxString NoRecentInputTT(_("This allows some computers to enter low-power mode when not in use.")); wxStaticText* staticText27 = new wxStaticText( - suspendComputingStaticBox, ID_DEFAULT, + box, ID_DEFAULT, _("Suspend when no mouse/keyboard input in last"), wxDefaultPosition, wxDefaultSize, 0 ); - wxStaticText* staticText28 = new wxStaticText( - suspendComputingStaticBox, ID_DEFAULT, + box, ID_DEFAULT, _("minutes"), wxDefaultPosition, wxDefaultSize, 0 ); - m_txtNoRecentInput = new wxTextCtrl( - suspendComputingStaticBox, ID_TXTNORECENTINPUT, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT + box, ID_TXTNORECENTINPUT, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT ); + addNewRowToSizer(box_sizer, NoRecentInputTT, staticText27, m_txtNoRecentInput, staticText28); - addNewRowToSizer(suspendComputingBoxSizer, NoRecentInputTT, staticText27, m_txtNoRecentInput, staticText28); - - // max CPU load - wxString MaxLoadCheckBoxText = wxEmptyString; - MaxLoadCheckBoxText.Printf(_("Suspend when non-BOINC CPU usage is above")); - - wxString MaxLoadTT(_("Suspend computing when your computer is busy running other programs.")); - m_chkMaxLoad = new wxCheckBox( - suspendComputingStaticBox, ID_CHKMAXLOAD, MaxLoadCheckBoxText, wxDefaultPosition, wxDefaultSize, 0); - - m_txtMaxLoad = new wxTextCtrl( - suspendComputingStaticBox, ID_TXTMAXLOAD, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("100.00")), wxTE_RIGHT + box_sizer->Add( + new wxStaticText(box, ID_DEFAULT, _("To suspend by time of day, see the \"Daily Schedules\" section."), wxDefaultPosition, wxDefaultSize, 0), + 0, wxALL, 5 ); - wxStaticText* staticText26 = new wxStaticText( suspendComputingStaticBox, ID_DEFAULT, wxT("%"), - wxDefaultPosition, wxDefaultSize, 0 ); + processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); + processorTabSizer->Add(box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE); + + // ------------ General box -------------- + // - addNewRowToSizer(suspendComputingBoxSizer, MaxLoadTT, m_chkMaxLoad, m_txtMaxLoad, staticText26); + box = new wxStaticBox(processorTab, -1, _("General")); + box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); + makeStaticBoxLabelItalic(box); - suspendComputingBoxSizer->Add( - new wxStaticText( suspendComputingStaticBox, ID_DEFAULT, _("To suspend by time of day, see the \"Daily Schedules\" section."), wxDefaultPosition, wxDefaultSize, 0), - 0, wxALL, 5 + // suspend while on battery + // + m_chkProcOnBatteries = new wxCheckBox( + box, ID_CHKPROCONBATTERIES, + _("Suspend when computer is on battery"), wxDefaultPosition, wxDefaultSize, 0 ); + m_chkProcOnBatteries->SetToolTip( + _("Check this to suspend computing on portables when running on battery power.") + ); + box_sizer->Add( m_chkProcOnBatteries, 0, wxALL, 5 ); - processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); - processorTabSizer->Add( suspendComputingBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); + // switch every X + // + wxString ProcSwitchEveryTT = wxEmptyString; + ProcSwitchEveryTT.Printf(_("If you run several projects, %s may switch between them this often."), pSkinAdvanced->GetApplicationShortName().c_str()); + wxStaticText* staticText18 = new wxStaticText( + box, ID_DEFAULT, + // context: Switch between tasks every ___ minutes + _("Switch between tasks every"), + wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtProcSwitchEvery = new wxTextCtrl( box, ID_TXTPROCSWITCHEVERY, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("9999.99")), wxTE_RIGHT ); + wxStaticText* staticText19 = new wxStaticText( + box, ID_DEFAULT, + // context: Switch between tasks every ___ minutes + _("minutes"), + wxDefaultPosition, wxDefaultSize, 0 + ); + addNewRowToSizer(box_sizer, ProcSwitchEveryTT, staticText18, m_txtProcSwitchEvery, staticText19); - wxStaticBox* miscProcStaticBox = new wxStaticBox( - processorTab, -1, - // Context: heading for a group of miscellaneous preferences - _("Other") + // checkpoint every X + // + wxString DiskWriteToDiskTT(_("This controls how often tasks save their state to disk, so that they later can be continued from that point.")); + wxStaticText* staticText46 = new wxStaticText( + box, ID_DEFAULT, + // context: Request tasks to checkpoint at most every ___ seconds + _("Request tasks to checkpoint at most every"), + wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtDiskWriteToDisk = new wxTextCtrl( box, ID_TXTDISKWRITETODISK, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + wxStaticText* staticText47 = new wxStaticText( + box, ID_DEFAULT, + // context: Request tasks to checkpoint at most every ___ seconds + _("seconds"), + wxDefaultPosition, wxDefaultSize, 0 ); - wxStaticBoxSizer* miscProcBoxSizer = new wxStaticBoxSizer( miscProcStaticBox, wxVERTICAL ); - makeStaticBoxLabelItalic(miscProcStaticBox); + addNewRowToSizer(box_sizer, DiskWriteToDiskTT, staticText46, m_txtDiskWriteToDisk, staticText47); - // buffer sizes + // work buffer min + // wxString NetConnectIntervalTT(_("Store at least enough tasks to keep the computer busy for this long.")); wxStaticText* staticText30 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, + box, ID_DEFAULT, // context: Store at least ___ days of work _("Store at least"), wxDefaultPosition, wxDefaultSize, 0 ); - m_txtNetConnectInterval = new wxTextCtrl( - miscProcStaticBox, ID_TXTNETCONNECTINTERVAL, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT + box, ID_TXTNETCONNECTINTERVAL, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - wxStaticText* staticText31 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, + box, ID_DEFAULT, // context: Store at least ___ days of work _("days of work"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, NetConnectIntervalTT, staticText30, m_txtNetConnectInterval, staticText31); - addNewRowToSizer(miscProcBoxSizer, NetConnectIntervalTT, staticText30, m_txtNetConnectInterval, staticText31); - + // work buffer additional + // wxString NetAdditionalDaysTT(_("Store additional tasks above the minimum level. Determines how much work is requested when contacting a project.")); wxStaticText* staticText331 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, + box, ID_DEFAULT, // context: Store up to an additional ___ days of work _("Store up to an additional"), wxDefaultPosition, wxDefaultSize, 0 ); staticText331->SetToolTip(NetAdditionalDaysTT); - m_txtNetAdditionalDays = new wxTextCtrl( - miscProcStaticBox, ID_TXTNETADDITIONALDAYS, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT + box, ID_TXTNETADDITIONALDAYS, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - wxStaticText* staticText341 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, + box, ID_DEFAULT, // context: Store up to an additional ___ days of work _("days of work"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, NetAdditionalDaysTT, staticText331, m_txtNetAdditionalDays, staticText341); - addNewRowToSizer(miscProcBoxSizer, NetAdditionalDaysTT, staticText331, m_txtNetAdditionalDays, staticText341); - - wxString ProcSwitchEveryTT = wxEmptyString; - ProcSwitchEveryTT.Printf(_("If you run several projects, %s may switch between them this often."), pSkinAdvanced->GetApplicationShortName().c_str()); - - wxStaticText* staticText18 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, - // context: Switch between tasks every ___ minutes - _("Switch between tasks every"), - wxDefaultPosition, wxDefaultSize, 0 - ); - - m_txtProcSwitchEvery = new wxTextCtrl( miscProcStaticBox, ID_TXTPROCSWITCHEVERY, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("9999.99")), wxTE_RIGHT ); - - wxStaticText* staticText19 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, - // context: Switch between tasks every ___ minutes - _("minutes"), - wxDefaultPosition, wxDefaultSize, 0 - ); - - addNewRowToSizer(miscProcBoxSizer, ProcSwitchEveryTT, staticText18, m_txtProcSwitchEvery, staticText19); - - wxString DiskWriteToDiskTT(_("This controls how often tasks save their state to disk, so that they later can be continued from that point.")); - wxStaticText* staticText46 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, - // context: Request tasks to checkpoint at most every ___ seconds - _("Request tasks to checkpoint at most every"), - wxDefaultPosition, wxDefaultSize, 0 - ); - - m_txtDiskWriteToDisk = new wxTextCtrl( miscProcStaticBox, ID_TXTDISKWRITETODISK, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - wxStaticText* staticText47 = new wxStaticText( - miscProcStaticBox, ID_DEFAULT, - // context: Request tasks to checkpoint at most every ___ seconds - _("seconds"), - wxDefaultPosition, wxDefaultSize, 0 - ); - - addNewRowToSizer(miscProcBoxSizer, DiskWriteToDiskTT, staticText46, m_txtDiskWriteToDisk, staticText47); - - miscProcBoxSizer->AddSpacer(1); // Ensure staticText22 is fully visible on Mac + box_sizer->AddSpacer(1); // Ensure staticText22 is fully visible on Mac processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); - processorTabSizer->Add( miscProcBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); + processorTabSizer->Add( box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); processorTab->SetSizer( processorTabSizer ); @@ -486,9 +524,8 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) return processorTab; } -wxPanel* CDlgAdvPreferencesBase::createNetworkTab(wxNotebook* notebook) -{ - CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); +wxPanel* CDlgAdvPreferencesBase::createNetworkTab(wxNotebook* notebook) { + CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxASSERT(pSkinAdvanced); wxSize textCtrlSize = getTextCtrlSize(wxT("9999.99")); @@ -498,54 +535,43 @@ wxPanel* CDlgAdvPreferencesBase::createNetworkTab(wxNotebook* notebook) wxBoxSizer* networkTabSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBox* networkUsageLimitsStaticBox = new wxStaticBox( networkTab, -1, _("Usage limits") ); - wxStaticBoxSizer* networkUsageLimitsBoxSizer = new wxStaticBoxSizer( networkUsageLimitsStaticBox, wxVERTICAL ); - makeStaticBoxLabelItalic(networkUsageLimitsStaticBox); - - // upload/download rates + wxStaticBox* box = new wxStaticBox( networkTab, -1, _("Usage limits") ); + wxStaticBoxSizer* box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); + makeStaticBoxLabelItalic(box); + // download rate + // wxString NetDownloadRateTT(_("Limit the download rate of file transfers.")); - m_chkNetDownloadRate = new wxCheckBox( networkUsageLimitsStaticBox, ID_CHKNETDOWNLOADRATE, _("Limit download rate to"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txtNetDownloadRate = new wxTextCtrl( networkUsageLimitsStaticBox, ID_TXTNETDOWNLOADRATE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - wxStaticText* staticText33 = new wxStaticText( networkUsageLimitsStaticBox, ID_DEFAULT, _("KB/second"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(networkUsageLimitsBoxSizer, NetDownloadRateTT, m_chkNetDownloadRate, m_txtNetDownloadRate, staticText33); + m_chkNetDownloadRate = new wxCheckBox( box, ID_CHKNETDOWNLOADRATE, _("Limit download rate to"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txtNetDownloadRate = new wxTextCtrl( box, ID_TXTNETDOWNLOADRATE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + wxStaticText* staticText33 = new wxStaticText( box, ID_DEFAULT, _("KB/second"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, NetDownloadRateTT, m_chkNetDownloadRate, m_txtNetDownloadRate, staticText33); + // upload rate + // wxString NetUploadRateTT(_("Limit the upload rate of file transfers.")); - m_chkNetUploadRate = new wxCheckBox( networkUsageLimitsStaticBox, ID_CHKNETUPLOADRATE, _("Limit upload rate to"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txtNetUploadRate = new wxTextCtrl( networkUsageLimitsStaticBox, ID_TXTNETUPLOADRATE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - wxStaticText* staticText35 = new wxStaticText( networkUsageLimitsStaticBox, ID_DEFAULT, _("KB/second"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(networkUsageLimitsBoxSizer, NetUploadRateTT, m_chkNetUploadRate, m_txtNetUploadRate, staticText35); + m_chkNetUploadRate = new wxCheckBox( box, ID_CHKNETUPLOADRATE, _("Limit upload rate to"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txtNetUploadRate = new wxTextCtrl( box, ID_TXTNETUPLOADRATE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + wxStaticText* staticText35 = new wxStaticText( box, ID_DEFAULT, _("KB/second"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, NetUploadRateTT, m_chkNetUploadRate, m_txtNetUploadRate, staticText35); // long-term quota - + // wxString daily_xfer_limitTT = wxEmptyString; daily_xfer_limitTT.Printf(_("Example: %s should transfer at most 2000 MB of data every 30 days."), pSkinAdvanced->GetApplicationShortName().c_str()); - - m_chk_daily_xfer_limit = new wxCheckBox( networkUsageLimitsStaticBox, ID_CHKDAILYXFERLIMIT, _("Limit usage to"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txt_daily_xfer_limit_mb = new wxTextCtrl( networkUsageLimitsStaticBox, ID_TXTNETDOWNLOADRATE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - wxStaticText* staticText_daily_xfer2 = new wxStaticText( networkUsageLimitsStaticBox, ID_DEFAULT, _("MB every"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txt_daily_xfer_period_days = new wxTextCtrl( networkUsageLimitsStaticBox, ID_TXTNETUPLOADRATE, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT ); - - wxStaticText* staticText_daily_xfer4 = new wxStaticText( networkUsageLimitsStaticBox, ID_DEFAULT, _("days"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(networkUsageLimitsBoxSizer, daily_xfer_limitTT, m_chk_daily_xfer_limit, m_txt_daily_xfer_limit_mb, staticText_daily_xfer2, m_txt_daily_xfer_period_days, staticText_daily_xfer4); - - networkUsageLimitsBoxSizer->Add( - new wxStaticText( networkUsageLimitsStaticBox, ID_DEFAULT, _("To limit transfers by time of day, see the \"Daily Schedules\" section."), wxDefaultPosition, wxDefaultSize, 0), + m_chk_daily_xfer_limit = new wxCheckBox( box, ID_CHKDAILYXFERLIMIT, _("Limit usage to"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txt_daily_xfer_limit_mb = new wxTextCtrl( box, ID_TXTNETDOWNLOADRATE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + wxStaticText* staticText_daily_xfer2 = new wxStaticText( box, ID_DEFAULT, _("MB every"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txt_daily_xfer_period_days = new wxTextCtrl( box, ID_TXTNETUPLOADRATE, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT ); + wxStaticText* staticText_daily_xfer4 = new wxStaticText( box, ID_DEFAULT, _("days"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(box_sizer, daily_xfer_limitTT, m_chk_daily_xfer_limit, m_txt_daily_xfer_limit_mb, staticText_daily_xfer2, m_txt_daily_xfer_period_days, staticText_daily_xfer4); + box_sizer->Add( + new wxStaticText( box, ID_DEFAULT, _("To limit transfers by time of day, see the \"Daily Schedules\" section."), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5 ); networkTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); - networkTabSizer->Add( networkUsageLimitsBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); + networkTabSizer->Add( box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); // Context: heading for a group of miscellaneous preferences wxStaticBox* connectOptionsStaticBox = new wxStaticBox( @@ -556,17 +582,21 @@ wxPanel* CDlgAdvPreferencesBase::createNetworkTab(wxNotebook* notebook) wxStaticBoxSizer* connectOptionsSizer = new wxStaticBoxSizer( connectOptionsStaticBox, wxVERTICAL ); makeStaticBoxLabelItalic(connectOptionsStaticBox); + // skip image verification + // wxString NetSkipImageVerificationTT = wxEmptyString; NetSkipImageVerificationTT.Printf(_("Check this only if your Internet provider modifies image files. Skipping verification reduces the security of %s."), pSkinAdvanced->GetApplicationShortName().c_str()); - m_chkNetSkipImageVerification = new wxCheckBox( connectOptionsStaticBox, ID_CHKNETSKIPIMAGEVERIFICATION, _("Skip data verification for image files"), wxDefaultPosition, wxDefaultSize, 0 ); m_chkNetSkipImageVerification->SetToolTip(NetSkipImageVerificationTT); connectOptionsSizer->Add( m_chkNetSkipImageVerification, 0, wxALL, 5 ); + // confirm before connecting + // m_chkNetConfirmBeforeConnect = new wxCheckBox( connectOptionsStaticBox, ID_CHKNETCONFIRMBEFORECONNECT, _("Confirm before connecting to Internet"), wxDefaultPosition, wxDefaultSize, 0 ); m_chkNetConfirmBeforeConnect->SetToolTip( _("Useful only if you have a modem, ISDN or VPN connection.") ); connectOptionsSizer->Add( m_chkNetConfirmBeforeConnect, 0, wxALL, 5 ); + // disconnect when done m_chkNetDisconnectWhenDone = new wxCheckBox( connectOptionsStaticBox, ID_CHKNETDISCONNECTWHENDONE, _("Disconnect when done"), wxDefaultPosition, wxDefaultSize, 0 ); m_chkNetDisconnectWhenDone->SetToolTip( _("Useful only if you have a modem, ISDN or VPN connection.") ); connectOptionsSizer->Add( m_chkNetDisconnectWhenDone, 0, wxALL, 5 ); @@ -604,41 +634,35 @@ wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) 0, wxALL, 5 ); + // total disk usage + // wxString DiskMaxSpaceTT = wxEmptyString; DiskMaxSpaceTT.Printf(_("Limit the total amount of disk space used by %s."), pSkinAdvanced->GetApplicationShortName().c_str()); - m_chkDiskMaxSpace = new wxCheckBox ( diskUsageStaticBox, ID_CHKDISKMAXSPACE, _("Use no more than"), wxDefaultPosition, wxDefaultSize, 0 ); - m_txtDiskMaxSpace = new wxTextCtrl( diskUsageStaticBox, ID_TXTDISKMAXSPACE,wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - wxStaticText* staticText41 = new wxStaticText( diskUsageStaticBox, ID_DEFAULT, _("GB"), wxDefaultPosition, wxDefaultSize, 0 ); - addNewRowToSizer(diskUsageBoxSizer, DiskMaxSpaceTT, m_chkDiskMaxSpace, m_txtDiskMaxSpace, staticText41); + // leave at least X free + // wxString DiskLeastFreeTT = wxEmptyString; DiskLeastFreeTT.Printf(_("Limit disk usage to leave this much free space on the volume where %s stores data."), pSkinAdvanced->GetApplicationShortName().c_str()); - m_chkDiskLeastFree = new wxCheckBox ( diskUsageStaticBox, ID_CHKDISKLEASTFREE, _("Leave at least"), wxDefaultPosition, wxDefaultSize, 0 ); - m_txtDiskLeastFree = new wxTextCtrl( diskUsageStaticBox, ID_TXTDISKLEASTFREE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - wxStaticText* staticText43 = new wxStaticText( diskUsageStaticBox, ID_DEFAULT, _("GB free"), wxDefaultPosition, wxDefaultSize, 0 ); - addNewRowToSizer(diskUsageBoxSizer, DiskLeastFreeTT, m_chkDiskLeastFree, m_txtDiskLeastFree, staticText43); + // use at most X% + // wxString DiskMaxOfTotalTT = wxEmptyString; DiskMaxOfTotalTT.Printf(_("Limit the percentage of disk space used by %s on the volume where it stores data."), pSkinAdvanced->GetApplicationShortName().c_str()); - m_chkDiskMaxOfTotal = new wxCheckBox ( diskUsageStaticBox, ID_CHKDISKMAXOFTOTAL, _("Use no more than"), wxDefaultPosition, wxDefaultSize, 0 ); - m_txtDiskMaxOfTotal = new wxTextCtrl( diskUsageStaticBox, ID_TXTDISKMAXOFTOTAL, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - /*xgettext:no-c-format*/ wxStaticText* staticText45 = new wxStaticText( diskUsageStaticBox, ID_DEFAULT, _("% of total"), wxDefaultPosition, wxDefaultSize, 0 ); - addNewRowToSizer(diskUsageBoxSizer, DiskMaxOfTotalTT, m_chkDiskMaxOfTotal, m_txtDiskMaxOfTotal, staticText45); diskAndMemoryTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); @@ -648,31 +672,8 @@ wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) wxStaticBoxSizer* memoryUsageBoxSizer = new wxStaticBoxSizer( memoryUsageStaticBox, wxVERTICAL ); makeStaticBoxLabelItalic(memoryUsageStaticBox); - wxString MemoryMaxInUseTT = wxEmptyString; - MemoryMaxInUseTT.Printf(_("Limit the memory used by %s when you're using the computer."), pSkinAdvanced->GetApplicationShortName().c_str()); - - wxStaticText* staticText50 = new wxStaticText( memoryUsageStaticBox, ID_DEFAULT, _("When computer is in use, use at most"), wxDefaultPosition, wxDefaultSize, 0 ); - - textCtrlSize = getTextCtrlSize(wxT("100.00")); - m_txtMemoryMaxInUse = new wxTextCtrl( memoryUsageStaticBox, ID_TXTMEMORYMAXINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - /*xgettext:no-c-format*/ - wxStaticText* staticText51 = new wxStaticText( memoryUsageStaticBox, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(memoryUsageBoxSizer, MemoryMaxInUseTT, staticText50, m_txtMemoryMaxInUse, staticText51); - - wxString MemoryMaxOnIdleTT = wxEmptyString; - MemoryMaxOnIdleTT.Printf(_("Limit the memory used by %s when you're not using the computer."), pSkinAdvanced->GetApplicationShortName().c_str()); - - wxStaticText* staticText52 = new wxStaticText( memoryUsageStaticBox, ID_DEFAULT, _("When computer is not in use, use at most"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txtMemoryMaxOnIdle = new wxTextCtrl( memoryUsageStaticBox, ID_TXTMEMORYMAXONIDLE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - - /*xgettext:no-c-format*/ - wxStaticText* staticText53 = new wxStaticText( memoryUsageStaticBox, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(memoryUsageBoxSizer, MemoryMaxOnIdleTT, staticText52, m_txtMemoryMaxOnIdle, staticText53); - + // leave non-GPU tasks in memory while suspended + // m_chkMemoryWhileSuspended = new wxCheckBox( memoryUsageStaticBox, ID_CHKMEMORYWHILESUSPENDED, _("Leave non-GPU tasks in memory while suspended"), wxDefaultPosition, wxDefaultSize, 0 ); m_chkMemoryWhileSuspended->SetToolTip( _("If checked, suspended tasks stay in memory, and resume with no work lost. If unchecked, suspended tasks are removed from memory, and resume from their last checkpoint.") ); memoryUsageBoxSizer->Add(m_chkMemoryWhileSuspended, 0, wxALL, 5 ); diff --git a/clientgui/DlgAdvPreferencesBase.h b/clientgui/DlgAdvPreferencesBase.h index 416bde5cd9a..cdb3f9eee8a 100644 --- a/clientgui/DlgAdvPreferencesBase.h +++ b/clientgui/DlgAdvPreferencesBase.h @@ -81,6 +81,7 @@ enum { ID_CHKPROCEVERYDAY, ID_CHKPROCINUSE, ID_CHKMAXLOAD, + ID_CHKMAXLOADNOTINUSE, ID_CHKPROCONBATTERIES, ID_TABPAGE_SCHED, ID_TABPAGE_DISK, @@ -113,6 +114,7 @@ enum { ID_TXTNETWEDNESDAYSTART, ID_TXTNETWEDNESDAYSTOP, ID_TXTPROCUSECPUTIME, + ID_TXTPROCUSECPUTIMENOTINUSE, ID_TXTPROCEVERYDAYSTART, ID_TXTPROCEVERYDAYSTOP, ID_TXTPROCFRIDAYSTART, @@ -131,36 +133,83 @@ enum { ID_TXTPROCTUESDAYSTART, ID_TXTPROCTUESDAYSTOP, ID_TXTPROCUSEPROCESSORS, + ID_TXTPROCUSEPROCESSORSNOTINUSE, ID_TXTPROCWEDNESDAYSTART, ID_TXTPROCWEDNESDAYSTOP, ID_CHKGPUPROCINUSE, ID_TXTMAXLOAD, + ID_TXTMAXLOADNOTINUSE, ID_DAILY_XFER_LIMIT_MB, ID_DAILY_XFER_PERIOD_DAYS, ID_ADV_PREFS_LAST }; -/** - * Class CDlgAdvPreferencesBase - */ -class CDlgAdvPreferencesBase : public wxDialog -{ +class CDlgAdvPreferencesBase : public wxDialog { protected: wxStaticBitmap* m_bmpWarning; wxButton* m_btnClear; wxPanel* m_panelControls; wxNotebook* m_Notebook; + + // Computing panel + // + // In-use items wxPanel* m_panelProcessor; - wxTextCtrl* m_txtProcUseProcessors; - wxTextCtrl* m_txtProcUseCPUTime; - wxCheckBox* m_chkProcOnBatteries; + wxTextCtrl* m_txtProcIdleFor; wxCheckBox* m_chkProcInUse; wxCheckBox* m_chkGPUProcInUse; - wxTextCtrl* m_txtProcIdleFor; - wxTextCtrl* m_txtNoRecentInput; + wxTextCtrl* m_txtProcUseProcessors; + wxTextCtrl* m_txtProcUseCPUTime; wxCheckBox* m_chkMaxLoad; wxTextCtrl* m_txtMaxLoad; + wxTextCtrl* m_txtMemoryMaxInUse; + // Not in Use items + // + wxTextCtrl* m_txtProcUseProcessorsNotInUse; + wxTextCtrl* m_txtProcUseCPUTimeNotInUse; + wxCheckBox* m_chkMaxLoadNotInUse; + wxTextCtrl* m_txtMaxLoadNotInUse; + wxTextCtrl* m_txtMemoryMaxOnIdle; + wxTextCtrl* m_txtNoRecentInput; + // General items + // + wxCheckBox* m_chkProcOnBatteries; + wxTextCtrl* m_txtProcSwitchEvery; + wxTextCtrl* m_txtDiskWriteToDisk; + wxCheckBox* m_chkMemoryWhileSuspended; + wxTextCtrl* m_txtNetConnectInterval; + wxTextCtrl* m_txtNetAdditionalDays; + wxTextCtrl* m_txtDiskMaxSwap; + + // Network panel + // + wxPanel* m_panelNetwork; + wxCheckBox* m_chkNetDownloadRate; + wxTextCtrl* m_txtNetDownloadRate; + wxCheckBox* m_chkNetUploadRate; + wxTextCtrl* m_txtNetUploadRate; + + wxCheckBox * m_chk_daily_xfer_limit; + wxTextCtrl* m_txt_daily_xfer_limit_mb; + wxTextCtrl* m_txt_daily_xfer_period_days; + + wxCheckBox* m_chkNetSkipImageVerification; + wxCheckBox* m_chkNetConfirmBeforeConnect; + wxCheckBox* m_chkNetDisconnectWhenDone; + + // Disk panel + // + wxPanel* m_panelDiskAndMemory; + wxCheckBox* m_chkDiskMaxSpace; + wxTextCtrl* m_txtDiskMaxSpace; + wxCheckBox* m_chkDiskLeastFree; + wxTextCtrl* m_txtDiskLeastFree; + wxCheckBox* m_chkDiskMaxOfTotal; + wxTextCtrl* m_txtDiskMaxOfTotal; + + // Daily schedules panel + wxPanel* m_panelDailySchedules; wxCheckBox* m_chkNetEveryDay; wxCheckBox* m_chkProcEveryDay; wxTextCtrl* m_txtProcEveryDayStart; @@ -186,23 +235,7 @@ class CDlgAdvPreferencesBase : public wxDialog wxCheckBox* m_chkProcSunday; wxTextCtrl* m_txtProcSundayStart; wxTextCtrl* m_txtProcSundayStop; - wxTextCtrl* m_txtProcSwitchEvery; - wxTextCtrl* m_txtDiskWriteToDisk; - wxPanel* m_panelNetwork; - wxCheckBox* m_chkNetDownloadRate; - wxTextCtrl* m_txtNetDownloadRate; - wxCheckBox* m_chkNetUploadRate; - wxTextCtrl* m_txtNetUploadRate; - - wxCheckBox * m_chk_daily_xfer_limit; - wxTextCtrl* m_txt_daily_xfer_limit_mb; - wxTextCtrl* m_txt_daily_xfer_period_days; - wxTextCtrl* m_txtNetConnectInterval; - wxTextCtrl* m_txtNetAdditionalDays; - wxCheckBox* m_chkNetSkipImageVerification; - wxCheckBox* m_chkNetConfirmBeforeConnect; - wxCheckBox* m_chkNetDisconnectWhenDone; wxTextCtrl* m_txtNetEveryDayStart; wxTextCtrl* m_txtNetEveryDayStop; wxCheckBox* m_chkNetMonday; @@ -226,18 +259,6 @@ class CDlgAdvPreferencesBase : public wxDialog wxCheckBox* m_chkNetSunday; wxTextCtrl* m_txtNetSundayStart; wxTextCtrl* m_txtNetSundayStop; - wxPanel* m_panelDiskAndMemory; - wxCheckBox* m_chkDiskMaxSpace; - wxTextCtrl* m_txtDiskMaxSpace; - wxCheckBox* m_chkDiskLeastFree; - wxTextCtrl* m_txtDiskLeastFree; - wxCheckBox* m_chkDiskMaxOfTotal; - wxTextCtrl* m_txtDiskMaxOfTotal; - wxTextCtrl* m_txtDiskMaxSwap; - wxTextCtrl* m_txtMemoryMaxInUse; - wxTextCtrl* m_txtMemoryMaxOnIdle; - wxCheckBox* m_chkMemoryWhileSuspended; - wxPanel* m_panelDailySchedules; wxPanel* m_panelButtons; wxButton* m_btnOK; From b6570bcf85f24fe373ceb63120b9a19bf495a0ee Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Sat, 6 Aug 2022 17:45:51 -0700 Subject: [PATCH 04/21] Manager: change advanced prefs dialog to include not-in-use prefs --- clientgui/DlgAdvPreferences.cpp | 5 +- clientgui/DlgAdvPreferencesBase.cpp | 105 +++++++++++++++------------- lib/prefs.cpp | 6 +- 3 files changed, 64 insertions(+), 52 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 55d8fd0bcf7..a3983c1c9e8 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -672,6 +672,7 @@ void CDlgAdvPreferences::UpdateControlStates() { if (m_chkProcInUse->IsChecked()) m_chkGPUProcInUse->SetValue(true); m_txtMaxLoad->Enable(m_chkMaxLoad->IsChecked()); + m_txtMaxLoadNotInUse->Enable(m_chkMaxLoadNotInUse->IsChecked()); // ######### disk and memory usage page m_txtDiskMaxSpace->Enable(m_chkDiskMaxSpace->IsChecked()); @@ -1066,7 +1067,9 @@ void CDlgAdvPreferences::OnHandleCommandEvent(wxCommandEvent& ev) { case ID_CHKMAXLOAD: DisplayValue(defaultPrefs.suspend_cpu_usage, m_txtMaxLoad, m_chkMaxLoad); break; - + case ID_CHKMAXLOADNOTINUSE: + DisplayValue(defaultPrefs.niu_suspend_cpu_usage, m_txtMaxLoadNotInUse, m_chkMaxLoadNotInUse); + break; // network usage page case ID_CHKNETDOWNLOADRATE: DisplayValue((defaultPrefs.max_bytes_sec_down / 1024), m_txtNetDownloadRate, m_chkNetDownloadRate); diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index daaa49e8f87..765ad3affda 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -341,15 +341,15 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { // wxString MemoryMaxInUseTT = wxEmptyString; MemoryMaxInUseTT.Printf(_("Limit the memory used by %s when you're using the computer."), pSkinAdvanced->GetApplicationShortName().c_str()); - wxStaticText* staticText50 = new wxStaticText(box, ID_DEFAULT, _("When computer is in use, use at most"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* staticText50 = new wxStaticText(box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); textCtrlSize = getTextCtrlSize(wxT("100.00")); m_txtMemoryMaxInUse = new wxTextCtrl( box, ID_TXTMEMORYMAXINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); /*xgettext:no-c-format*/ - wxStaticText* staticText51 = new wxStaticText( box, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* staticText51 = new wxStaticText( box, ID_DEFAULT, _("% of memory"), wxDefaultPosition, wxDefaultSize, 0 ); addNewRowToSizer(box_sizer, MemoryMaxInUseTT, staticText50, m_txtMemoryMaxInUse, staticText51); processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); - processorTabSizer->Add(box, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); + processorTabSizer->Add(box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); // ------------ Not-in-use box -------------- // @@ -361,32 +361,51 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { // max # CPUs // /*xgettext:no-c-format*/ - m_txtProcUseProcessorsNotInUse = new wxTextCtrl(box, ID_TXTPROCUSEPROCESSORSNOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - addNewRowToSizer(box_sizer, MaxCPUPctTT, staticText20, m_txtProcUseProcessorsNotInUse, staticText21); + wxString MaxCPUPctTTniu(_("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.")); + wxStaticText* staticText20niu = new wxStaticText( + box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtProcUseProcessorsNotInUse = new wxTextCtrl(box, ID_TXTPROCUSEPROCESSORSNOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT); + /*xgettext:no-c-format*/ + wxStaticText* staticText21niu = new wxStaticText(box, ID_DEFAULT, _("% of the CPUs"), wxDefaultPosition, wxDefaultSize, 0); + addNewRowToSizer(box_sizer, MaxCPUPctTTniu, staticText20niu, m_txtProcUseProcessorsNotInUse, staticText21niu); // CPU throttling // - m_txtProcUseCPUTimeNotInUse = new wxTextCtrl(box, ID_TXTPROCUSECPUTIMENOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - addNewRowToSizer(box_sizer, MaxCPUTimeTT, staticText22, m_txtProcUseCPUTimeNotInUse, staticText23); + wxString MaxCPUTimeTTniu(_("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.")); + wxStaticText* staticText22niu = new wxStaticText( + box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtProcUseCPUTimeNotInUse = new wxTextCtrl(box, ID_TXTPROCUSECPUTIMENOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT); + /*xgettext:no-c-format*/ + wxStaticText* staticText23niu = new wxStaticText(box, ID_DEFAULT, _("% of CPU time"), wxDefaultPosition, wxDefaultSize, 0); + addNewRowToSizer(box_sizer, MaxCPUTimeTTniu, staticText22niu, m_txtProcUseCPUTimeNotInUse, staticText23niu); // max CPU load // + + wxString MaxLoadCheckBoxTextniu = wxEmptyString; + MaxLoadCheckBoxTextniu.Printf(_("Suspend when non-BOINC CPU usage is above")); + wxString MaxLoadTTniu(_("Suspend computing when your computer is busy running other programs.")); m_chkMaxLoadNotInUse = new wxCheckBox( - box, ID_CHKMAXLOADNOTINUSE, MaxLoadCheckBoxText, wxDefaultPosition, wxDefaultSize, 0 + box, ID_CHKMAXLOADNOTINUSE, MaxLoadCheckBoxTextniu, wxDefaultPosition, wxDefaultSize, 0 ); m_txtMaxLoadNotInUse = new wxTextCtrl( box, ID_TXTMAXLOADNOTINUSE, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("100.00")), wxTE_RIGHT ); - addNewRowToSizer(box_sizer, MaxLoadTT, m_chkMaxLoadNotInUse, m_txtMaxLoadNotInUse, staticText26); + wxStaticText* staticText26niu = new wxStaticText(box, ID_DEFAULT, wxT("%"), + wxDefaultPosition, wxDefaultSize, 0 + ); + addNewRowToSizer(box_sizer, MaxLoadTTniu, m_chkMaxLoadNotInUse, m_txtMaxLoadNotInUse, staticText26niu); // max memory when not in use // wxString MemoryMaxOnIdleTT = wxEmptyString; MemoryMaxOnIdleTT.Printf(_("Limit the memory used by %s when you're not using the computer."), pSkinAdvanced->GetApplicationShortName().c_str()); - wxStaticText* staticText52 = new wxStaticText( box, ID_DEFAULT, _("When computer is not in use, use at most"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* staticText52 = new wxStaticText( box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtMemoryMaxOnIdle = new wxTextCtrl( box, ID_TXTMEMORYMAXONIDLE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); /*xgettext:no-c-format*/ - wxStaticText* staticText53 = new wxStaticText( box, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); + wxStaticText* staticText53 = new wxStaticText( box, ID_DEFAULT, _("% of memory"), wxDefaultPosition, wxDefaultSize, 0 ); addNewRowToSizer(box_sizer, MemoryMaxOnIdleTT, staticText52, m_txtMemoryMaxOnIdle, staticText53); // suspend after idle time @@ -407,10 +426,6 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { ); addNewRowToSizer(box_sizer, NoRecentInputTT, staticText27, m_txtNoRecentInput, staticText28); - box_sizer->Add( - new wxStaticText(box, ID_DEFAULT, _("To suspend by time of day, see the \"Daily Schedules\" section."), wxDefaultPosition, wxDefaultSize, 0), - 0, wxALL, 5 - ); processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); processorTabSizer->Add(box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE); @@ -470,6 +485,12 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { ); addNewRowToSizer(box_sizer, DiskWriteToDiskTT, staticText46, m_txtDiskWriteToDisk, staticText47); + // leave non-GPU tasks in memory while suspended +// + m_chkMemoryWhileSuspended = new wxCheckBox(box, ID_CHKMEMORYWHILESUSPENDED, _("Leave non-GPU tasks in memory while suspended"), wxDefaultPosition, wxDefaultSize, 0); + m_chkMemoryWhileSuspended->SetToolTip(_("If checked, suspended tasks stay in memory, and resume with no work lost. If unchecked, suspended tasks are removed from memory, and resume from their last checkpoint.")); + box_sizer->Add(m_chkMemoryWhileSuspended, 0, wxALL, 5); + // work buffer min // wxString NetConnectIntervalTT(_("Store at least enough tasks to keep the computer busy for this long.")); @@ -511,6 +532,11 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { ); addNewRowToSizer(box_sizer, NetAdditionalDaysTT, staticText331, m_txtNetAdditionalDays, staticText341); + box_sizer->Add( + new wxStaticText(box, ID_DEFAULT, _("To suspend by time of day, see the \"Daily Schedules\" section."), wxDefaultPosition, wxDefaultSize, 0), + 0, wxALL, 5 + ); + box_sizer->AddSpacer(1); // Ensure staticText22 is fully visible on Mac processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); @@ -535,7 +561,7 @@ wxPanel* CDlgAdvPreferencesBase::createNetworkTab(wxNotebook* notebook) { wxBoxSizer* networkTabSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBox* box = new wxStaticBox( networkTab, -1, _("Usage limits") ); + wxStaticBox* box = new wxStaticBox( networkTab, -1, _("Network usage") ); wxStaticBoxSizer* box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); makeStaticBoxLabelItalic(box); @@ -612,8 +638,7 @@ wxPanel* CDlgAdvPreferencesBase::createNetworkTab(wxNotebook* notebook) { return networkTab; } -wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) -{ +wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) { CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxASSERT(pSkinAdvanced); @@ -624,16 +649,10 @@ wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) wxBoxSizer* diskAndMemoryTabSizer = new wxBoxSizer( wxVERTICAL ); - wxStaticBox* diskUsageStaticBox = new wxStaticBox( diskMemoryTab, -1, _("Disk") ); + wxStaticBox* diskUsageStaticBox = new wxStaticBox( diskMemoryTab, -1, _("Disk usage") ); wxStaticBoxSizer* diskUsageBoxSizer = new wxStaticBoxSizer( diskUsageStaticBox, wxVERTICAL ); makeStaticBoxLabelItalic(diskUsageStaticBox); - wxString MostRestrictiveText = wxEmptyString; - MostRestrictiveText.Printf(_("%s will use the most restrictive of these settings:"), pSkinAdvanced->GetApplicationShortName().c_str()); - diskUsageBoxSizer->Add(new wxStaticText( diskUsageStaticBox, -1, MostRestrictiveText, wxDefaultPosition, wxDefaultSize, 0), - 0, wxALL, 5 - ); - // total disk usage // wxString DiskMaxSpaceTT = wxEmptyString; @@ -665,34 +684,24 @@ wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) wxStaticText* staticText45 = new wxStaticText( diskUsageStaticBox, ID_DEFAULT, _("% of total"), wxDefaultPosition, wxDefaultSize, 0 ); addNewRowToSizer(diskUsageBoxSizer, DiskMaxOfTotalTT, m_chkDiskMaxOfTotal, m_txtDiskMaxOfTotal, staticText45); - diskAndMemoryTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); - diskAndMemoryTabSizer->Add( diskUsageBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); - - wxStaticBox* memoryUsageStaticBox = new wxStaticBox( diskMemoryTab, -1, _("Memory") ); - wxStaticBoxSizer* memoryUsageBoxSizer = new wxStaticBoxSizer( memoryUsageStaticBox, wxVERTICAL ); - makeStaticBoxLabelItalic(memoryUsageStaticBox); - - // leave non-GPU tasks in memory while suspended + wxString MostRestrictiveText = wxEmptyString; + MostRestrictiveText.Printf(_("%s will use the most restrictive of the above settings"), pSkinAdvanced->GetApplicationShortName().c_str()); + diskUsageBoxSizer->Add(new wxStaticText(diskUsageStaticBox, -1, MostRestrictiveText, wxDefaultPosition, wxDefaultSize, 0), + 0, wxALL, 5 + ); + + // swap space limit // - m_chkMemoryWhileSuspended = new wxCheckBox( memoryUsageStaticBox, ID_CHKMEMORYWHILESUSPENDED, _("Leave non-GPU tasks in memory while suspended"), wxDefaultPosition, wxDefaultSize, 0 ); - m_chkMemoryWhileSuspended->SetToolTip( _("If checked, suspended tasks stay in memory, and resume with no work lost. If unchecked, suspended tasks are removed from memory, and resume from their last checkpoint.") ); - memoryUsageBoxSizer->Add(m_chkMemoryWhileSuspended, 0, wxALL, 5 ); - wxString DiskMaxSwapTT = wxEmptyString; DiskMaxSwapTT.Printf(_("Limit the swap space (page file) used by %s."), pSkinAdvanced->GetApplicationShortName().c_str()); - - wxStaticText* staticText48 = new wxStaticText( memoryUsageStaticBox, ID_DEFAULT, _("Page/swap file: use at most"), wxDefaultPosition, wxDefaultSize, 0 ); - - m_txtDiskMaxSwap = new wxTextCtrl( memoryUsageStaticBox, ID_TXTDISKWRITETODISK, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - + wxStaticText* staticText48 = new wxStaticText(diskUsageStaticBox, ID_DEFAULT, _("Page/swap file: use at most"), wxDefaultPosition, wxDefaultSize, 0 ); + m_txtDiskMaxSwap = new wxTextCtrl(diskUsageStaticBox, ID_TXTDISKWRITETODISK, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); /*xgettext:no-c-format*/ - wxStaticText* staticText49 = new wxStaticText( memoryUsageStaticBox, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); - - addNewRowToSizer(memoryUsageBoxSizer, DiskMaxSwapTT, staticText48, m_txtDiskMaxSwap, staticText49); + wxStaticText* staticText49 = new wxStaticText(diskUsageStaticBox, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); + addNewRowToSizer(diskUsageBoxSizer, DiskMaxSwapTT, staticText48, m_txtDiskMaxSwap, staticText49); - diskAndMemoryTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); - diskAndMemoryTabSizer->Add( memoryUsageBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); - diskAndMemoryTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); + diskAndMemoryTabSizer->AddSpacer(STATICBOXVERTICALSPACER); + diskAndMemoryTabSizer->Add(diskUsageBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE); diskMemoryTab->SetSizer( diskAndMemoryTabSizer ); diskMemoryTab->Layout(); diff --git a/lib/prefs.cpp b/lib/prefs.cpp index aec0005c8ec..2bf27469b0f 100644 --- a/lib/prefs.cpp +++ b/lib/prefs.cpp @@ -238,9 +238,9 @@ void GLOBAL_PREFS::defaults() { #else network_wifi_only = false; #endif - niu_max_ncpus_pct = -1; // -1 means unspecified, use max_ncpus_pct - niu_cpu_usage_limit = -1; - niu_suspend_cpu_usage = -1; + niu_max_ncpus_pct = 100; + niu_cpu_usage_limit = 100; + niu_suspend_cpu_usage = 50; ram_max_used_busy_frac = 0.5; #ifdef ANDROID ram_max_used_idle_frac = 0.5; From 5789724ed296ebc9b2695032461ad6c7d54b6c06 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 6 Aug 2022 18:41:58 -0700 Subject: [PATCH 05/21] Manager: add checkbox for "suspend if no recent input pref". --- clientgui/DlgAdvPreferences.cpp | 27 ++++++++++++++++++++------- clientgui/DlgAdvPreferencesBase.cpp | 11 +++++++---- clientgui/DlgAdvPreferencesBase.h | 4 +++- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index a3983c1c9e8..4bcaa83282a 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -337,7 +337,9 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { m_txtProcIdleFor->Disable(); } + m_chkNoRecentInput->SetValue(prefs.suspend_if_no_recent_input > 0.0); DisplayValue(prefs.suspend_if_no_recent_input, m_txtNoRecentInput); + m_chkMaxLoad->SetValue(prefs.suspend_cpu_usage > 0.0); DisplayValue(prefs.suspend_cpu_usage, m_txtMaxLoad, m_chkMaxLoad); m_chkMaxLoadNotInUse->SetValue(prefs.niu_suspend_cpu_usage > 0.0); @@ -479,9 +481,13 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { mask.idle_time_to_run=true; } - m_txtNoRecentInput->GetValue().ToDouble(&td); - prefs.suspend_if_no_recent_input = RoundToHundredths(td); - mask.suspend_if_no_recent_input = true; + if (m_chkNoRecentInput->IsChecked()) { + m_txtNoRecentInput->GetValue().ToDouble(&td); + prefs.suspend_if_no_recent_input = RoundToHundredths(td); + } else { + prefs.suspend_if_no_recent_input = 0; + } + mask.suspend_if_no_recent_input = true; if (m_chkMaxLoad->IsChecked()) { m_txtMaxLoad->GetValue().ToDouble(&td); @@ -673,6 +679,7 @@ void CDlgAdvPreferences::UpdateControlStates() { m_txtMaxLoad->Enable(m_chkMaxLoad->IsChecked()); m_txtMaxLoadNotInUse->Enable(m_chkMaxLoadNotInUse->IsChecked()); + m_txtNoRecentInput->Enable(m_chkNoRecentInput->IsChecked()); // ######### disk and memory usage page m_txtDiskMaxSpace->Enable(m_chkDiskMaxSpace->IsChecked()); @@ -737,10 +744,12 @@ bool CDlgAdvPreferences::ValidateInput() { } } - buffer = m_txtNoRecentInput->GetValue(); - if (!IsValidFloatValueBetween(buffer, 0, 9999999999999.99)) { - ShowErrorMessage(invMsgFloat, m_txtNoRecentInput); - return false; + if (m_chkNoRecentInput->IsChecked()) { + buffer = m_txtNoRecentInput->GetValue(); + if (!IsValidFloatValueBetween(buffer, 0, 9999999999999.99)) { + ShowErrorMessage(invMsgFloat, m_txtNoRecentInput); + return false; + } } if (m_chkMaxLoad->IsChecked()) { @@ -750,6 +759,7 @@ bool CDlgAdvPreferences::ValidateInput() { return false; } } + if (m_chkMaxLoadNotInUse->IsChecked()) { buffer = m_txtMaxLoadNotInUse->GetValue(); if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) { @@ -1070,6 +1080,9 @@ void CDlgAdvPreferences::OnHandleCommandEvent(wxCommandEvent& ev) { case ID_CHKMAXLOADNOTINUSE: DisplayValue(defaultPrefs.niu_suspend_cpu_usage, m_txtMaxLoadNotInUse, m_chkMaxLoadNotInUse); break; + case ID_CHKNORECENTINPUT: + DisplayValue(defaultPrefs.suspend_if_no_recent_input, m_txtNoRecentInput, m_chkNoRecentInput); + break; // network usage page case ID_CHKNETDOWNLOADRATE: DisplayValue((defaultPrefs.max_bytes_sec_down / 1024), m_txtNetDownloadRate, m_chkNetDownloadRate); diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index 765ad3affda..53279992ad5 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -383,10 +383,8 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { // max CPU load // - wxString MaxLoadCheckBoxTextniu = wxEmptyString; MaxLoadCheckBoxTextniu.Printf(_("Suspend when non-BOINC CPU usage is above")); - wxString MaxLoadTTniu(_("Suspend computing when your computer is busy running other programs.")); m_chkMaxLoadNotInUse = new wxCheckBox( box, ID_CHKMAXLOADNOTINUSE, MaxLoadCheckBoxTextniu, wxDefaultPosition, wxDefaultSize, 0 ); @@ -396,6 +394,7 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { wxStaticText* staticText26niu = new wxStaticText(box, ID_DEFAULT, wxT("%"), wxDefaultPosition, wxDefaultSize, 0 ); + wxString MaxLoadTTniu(_("Suspend computing when your computer is busy running other programs.")); addNewRowToSizer(box_sizer, MaxLoadTTniu, m_chkMaxLoadNotInUse, m_txtMaxLoadNotInUse, staticText26niu); // max memory when not in use @@ -410,7 +409,11 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { // suspend after idle time // - wxString NoRecentInputTT(_("This allows some computers to enter low-power mode when not in use.")); + wxString str0 = wxEmptyString; + str0.Printf(_("Suspend when non-BOINC CPU usage is above")); + m_chkNoRecentInput = new wxCheckBox( + box, ID_CHKNORECENTINPUT, str0, wxDefaultPosition, wxDefaultSize, 0 + ); wxStaticText* staticText27 = new wxStaticText( box, ID_DEFAULT, _("Suspend when no mouse/keyboard input in last"), @@ -424,9 +427,9 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { m_txtNoRecentInput = new wxTextCtrl( box, ID_TXTNORECENTINPUT, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT ); + wxString NoRecentInputTT(_("This allows some computers to enter low-power mode when not in use.")); addNewRowToSizer(box_sizer, NoRecentInputTT, staticText27, m_txtNoRecentInput, staticText28); - processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); processorTabSizer->Add(box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE); diff --git a/clientgui/DlgAdvPreferencesBase.h b/clientgui/DlgAdvPreferencesBase.h index cdb3f9eee8a..edb147ea4ee 100644 --- a/clientgui/DlgAdvPreferencesBase.h +++ b/clientgui/DlgAdvPreferencesBase.h @@ -137,6 +137,7 @@ enum { ID_TXTPROCWEDNESDAYSTART, ID_TXTPROCWEDNESDAYSTOP, ID_CHKGPUPROCINUSE, + ID_CHKNORECENTINPUT, ID_TXTMAXLOAD, ID_TXTMAXLOADNOTINUSE, ID_DAILY_XFER_LIMIT_MB, @@ -171,6 +172,7 @@ class CDlgAdvPreferencesBase : public wxDialog { wxCheckBox* m_chkMaxLoadNotInUse; wxTextCtrl* m_txtMaxLoadNotInUse; wxTextCtrl* m_txtMemoryMaxOnIdle; + wxCheckBox* m_chkNoRecentInput; wxTextCtrl* m_txtNoRecentInput; // General items // @@ -190,7 +192,7 @@ class CDlgAdvPreferencesBase : public wxDialog { wxCheckBox* m_chkNetUploadRate; wxTextCtrl* m_txtNetUploadRate; - wxCheckBox * m_chk_daily_xfer_limit; + wxCheckBox* m_chk_daily_xfer_limit; wxTextCtrl* m_txt_daily_xfer_limit_mb; wxTextCtrl* m_txt_daily_xfer_period_days; From 51bfc0a3689852c1fac1009823853ddac123ac58 Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Sat, 6 Aug 2022 18:44:35 -0700 Subject: [PATCH 06/21] client: if new not-in-use prefs aren't specified in XML file, use the values from corresponding in-use pref --- lib/prefs.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/prefs.cpp b/lib/prefs.cpp index 2bf27469b0f..1fe02e416c4 100644 --- a/lib/prefs.cpp +++ b/lib/prefs.cpp @@ -397,6 +397,17 @@ int GLOBAL_PREFS::parse_override( if (net_times.start_hour == net_times.end_hour) { mask.net_start_hour = mask.net_end_hour = false; } + // if not-in-use prefs weren't specified, use in-use counterpart + // + if (!mask.niu_max_ncpus_pct) { + niu_max_ncpus_pct = max_ncpus_pct; + } + if (!mask.niu_cpu_usage_limit) { + niu_cpu_usage_limit = cpu_usage_limit; + } + if (!mask.niu_suspend_cpu_usage) { + niu_suspend_cpu_usage = suspend_cpu_usage; + } return 0; } if (in_venue) { From 7d24c0214fe44b1c6d6506517cd31dce872e73e3 Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Sat, 6 Aug 2022 21:02:55 -0700 Subject: [PATCH 07/21] Client and Manager: debug computing prefs. Note: the Manager code is written in a clunky way. I cleaned up one instance. TODO: clean up others. --- clientgui/DlgAdvPreferences.cpp | 2 +- clientgui/DlgAdvPreferencesBase.cpp | 39 +++++++++++++---------------- clientgui/DlgAdvPreferencesBase.h | 18 ++++++------- lib/prefs.cpp | 2 +- 4 files changed, 28 insertions(+), 33 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 4bcaa83282a..903ebea24ff 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -338,7 +338,7 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { } m_chkNoRecentInput->SetValue(prefs.suspend_if_no_recent_input > 0.0); - DisplayValue(prefs.suspend_if_no_recent_input, m_txtNoRecentInput); + DisplayValue(prefs.suspend_if_no_recent_input, m_txtNoRecentInput, m_chkNoRecentInput); m_chkMaxLoad->SetValue(prefs.suspend_cpu_usage > 0.0); DisplayValue(prefs.suspend_cpu_usage, m_txtMaxLoad, m_chkMaxLoad); diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index 53279992ad5..144e1f1a3cf 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -154,9 +154,9 @@ CDlgAdvPreferencesBase::CDlgAdvPreferencesBase( wxWindow* parent, int id, wxStri iImageIndex = pImageList->Add(wxBitmap(xfer_xpm)); m_Notebook->AddPage( m_panelNetwork, _("Network"), true, iImageIndex ); - m_panelDiskAndMemory = createDiskAndMemoryTab(m_Notebook); + m_panelDisk = createDiskTab(m_Notebook); iImageIndex = pImageList->Add(wxBitmap(usage_xpm)); - m_Notebook->AddPage( m_panelDiskAndMemory, _("Disk"), true, iImageIndex ); + m_Notebook->AddPage( m_panelDisk, _("Disk"), true, iImageIndex ); m_panelDailySchedules = createDailySchedulesTab(m_Notebook); iImageIndex = pImageList->Add(wxBitmap(clock_xpm)); @@ -323,19 +323,19 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { // max CPU load // - wxString MaxLoadCheckBoxText = wxEmptyString; - MaxLoadCheckBoxText.Printf(_("Suspend when non-BOINC CPU usage is above")); - wxString MaxLoadTT(_("Suspend computing when your computer is busy running other programs.")); m_chkMaxLoad = new wxCheckBox( - box, ID_CHKMAXLOAD, MaxLoadCheckBoxText, wxDefaultPosition, wxDefaultSize, 0 + box, ID_CHKMAXLOAD, + wxString(_("Suspend when non-BOINC CPU usage is above")), + wxDefaultPosition, wxDefaultSize, 0 ); m_txtMaxLoad = new wxTextCtrl( box, ID_TXTMAXLOAD, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("100.00")), wxTE_RIGHT ); - wxStaticText* staticText26 = new wxStaticText( box, ID_DEFAULT, wxT("%"), - wxDefaultPosition, wxDefaultSize, 0 + addNewRowToSizer(box_sizer, + wxString (_("Suspend computing when your computer is busy running other programs.")), + m_chkMaxLoad, m_txtMaxLoad, + new wxStaticText(box, ID_DEFAULT, wxT("%"), wxDefaultPosition, wxDefaultSize, 0) ); - addNewRowToSizer(box_sizer, MaxLoadTT, m_chkMaxLoad, m_txtMaxLoad, staticText26); // max memory while in use // @@ -410,15 +410,10 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { // suspend after idle time // wxString str0 = wxEmptyString; - str0.Printf(_("Suspend when non-BOINC CPU usage is above")); + str0.Printf(_("Suspend when no mouse/keyboard input in last")); m_chkNoRecentInput = new wxCheckBox( box, ID_CHKNORECENTINPUT, str0, wxDefaultPosition, wxDefaultSize, 0 ); - wxStaticText* staticText27 = new wxStaticText( - box, ID_DEFAULT, - _("Suspend when no mouse/keyboard input in last"), - wxDefaultPosition, wxDefaultSize, 0 - ); wxStaticText* staticText28 = new wxStaticText( box, ID_DEFAULT, _("minutes"), @@ -428,7 +423,7 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { box, ID_TXTNORECENTINPUT, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("999.99")), wxTE_RIGHT ); wxString NoRecentInputTT(_("This allows some computers to enter low-power mode when not in use.")); - addNewRowToSizer(box_sizer, NoRecentInputTT, staticText27, m_txtNoRecentInput, staticText28); + addNewRowToSizer(box_sizer, NoRecentInputTT, m_chkNoRecentInput, m_txtNoRecentInput, staticText28); processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); processorTabSizer->Add(box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE); @@ -641,7 +636,7 @@ wxPanel* CDlgAdvPreferencesBase::createNetworkTab(wxNotebook* notebook) { return networkTab; } -wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) { +wxPanel* CDlgAdvPreferencesBase::createDiskTab(wxNotebook* notebook) { CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxASSERT(pSkinAdvanced); @@ -650,7 +645,7 @@ wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) { wxPanel* diskMemoryTab = new wxPanel( notebook, ID_TABPAGE_DISK, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); diskMemoryTab->SetExtraStyle( wxWS_EX_VALIDATE_RECURSIVELY ); - wxBoxSizer* diskAndMemoryTabSizer = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* diskTabSizer = new wxBoxSizer( wxVERTICAL ); wxStaticBox* diskUsageStaticBox = new wxStaticBox( diskMemoryTab, -1, _("Disk usage") ); wxStaticBoxSizer* diskUsageBoxSizer = new wxStaticBoxSizer( diskUsageStaticBox, wxVERTICAL ); @@ -703,12 +698,12 @@ wxPanel* CDlgAdvPreferencesBase::createDiskAndMemoryTab(wxNotebook* notebook) { wxStaticText* staticText49 = new wxStaticText(diskUsageStaticBox, ID_DEFAULT, _("%"), wxDefaultPosition, wxDefaultSize, 0 ); addNewRowToSizer(diskUsageBoxSizer, DiskMaxSwapTT, staticText48, m_txtDiskMaxSwap, staticText49); - diskAndMemoryTabSizer->AddSpacer(STATICBOXVERTICALSPACER); - diskAndMemoryTabSizer->Add(diskUsageBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE); + diskTabSizer->AddSpacer(STATICBOXVERTICALSPACER); + diskTabSizer->Add(diskUsageBoxSizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE); - diskMemoryTab->SetSizer( diskAndMemoryTabSizer ); + diskMemoryTab->SetSizer( diskTabSizer ); diskMemoryTab->Layout(); - diskAndMemoryTabSizer->Fit( diskMemoryTab ); + diskTabSizer->Fit( diskMemoryTab ); return diskMemoryTab; } diff --git a/clientgui/DlgAdvPreferencesBase.h b/clientgui/DlgAdvPreferencesBase.h index edb147ea4ee..fe06690b249 100644 --- a/clientgui/DlgAdvPreferencesBase.h +++ b/clientgui/DlgAdvPreferencesBase.h @@ -39,9 +39,6 @@ #include #include -/////////////////////////////////////////////////////////////////////////// - - #define PROC_DAY_OF_WEEK_TOOLTIP_TEXT _("On this day of the week, compute only during these hours.") #define NET_DAY_OF_WEEK_TOOLTIP_TEXT _("On this day of the week, transfer files only during these hours.") @@ -145,7 +142,6 @@ enum { ID_ADV_PREFS_LAST }; - class CDlgAdvPreferencesBase : public wxDialog { protected: wxStaticBitmap* m_bmpWarning; @@ -202,7 +198,7 @@ class CDlgAdvPreferencesBase : public wxDialog { // Disk panel // - wxPanel* m_panelDiskAndMemory; + wxPanel* m_panelDisk; wxCheckBox* m_chkDiskMaxSpace; wxTextCtrl* m_txtDiskMaxSpace; wxCheckBox* m_chkDiskLeastFree; @@ -271,15 +267,19 @@ class CDlgAdvPreferencesBase : public wxDialog { bool m_bUsingLocalPrefs; public: - CDlgAdvPreferencesBase( wxWindow* parent, int id = -1, wxString title = wxT(""), wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize, int style = wxDEFAULT_DIALOG_STYLE ); + CDlgAdvPreferencesBase( + wxWindow* parent, int id = -1, wxString title = wxT(""), wxPoint pos = wxDefaultPosition, + wxSize size = wxDefaultSize, int style = wxDEFAULT_DIALOG_STYLE + ); private: void addNewRowToSizer(wxSizer* toSizer, wxString& toolTipText, - wxWindow* first, wxWindow* second, wxWindow* third, - wxWindow* fourth=NULL, wxWindow* fifth=NULL); + wxWindow* first, wxWindow* second, wxWindow* third, + wxWindow* fourth=NULL, wxWindow* fifth=NULL + ); wxPanel* createProcessorTab(wxNotebook* notebook); wxPanel* createNetworkTab(wxNotebook* notebook); - wxPanel* createDiskAndMemoryTab(wxNotebook* notebook); + wxPanel* createDiskTab(wxNotebook* notebook); wxPanel* createDailySchedulesTab(wxNotebook* notebook); wxSize getTextCtrlSize(wxString maxText); bool doesLocalPrefsFileExist(); diff --git a/lib/prefs.cpp b/lib/prefs.cpp index 1fe02e416c4..ab060cea4a3 100644 --- a/lib/prefs.cpp +++ b/lib/prefs.cpp @@ -255,7 +255,7 @@ void GLOBAL_PREFS::defaults() { #else suspend_cpu_usage = 25; #endif - suspend_if_no_recent_input = 0; + suspend_if_no_recent_input = 60; vm_max_used_frac = 0.75; work_buf_additional_days = 0.5; work_buf_min_days = 0.1; From 588ab8fdfa0f9d702d1cbaf22216b36094629e8b Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 6 Aug 2022 21:07:07 -0700 Subject: [PATCH 08/21] Web: in computing prefs, move swap limit to Disk section --- html/inc/prefs.inc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/html/inc/prefs.inc b/html/inc/prefs.inc index ccfca5aa1c2..15b24f0168c 100644 --- a/html/inc/prefs.inc +++ b/html/inc/prefs.inc @@ -177,13 +177,6 @@ $job_prefs = [ tra("Compute only during a particular period each day."), "start_hour", "end_hour" ), - new PREF_NUM( - tra("Page/swap file: use at most"), - tra("Limit the swap space (page file) used by BOINC."), - "vm_max_used_pct", - // xgettext:no-php-format - new NUM_SPEC(tra("%"), 1, 100, 75) - ), ]; $dp = get_disk_space_config(); @@ -208,6 +201,13 @@ $disk_prefs = array( // xgettext:no-php-format new NUM_SPEC(tra("% of total"), 0, 100, $dp->disk_max_used_pct) ), + new PREF_NUM( + tra("Page/swap file: use at most"), + tra("Limit the swap space (page file) used by BOINC."), + "vm_max_used_pct", + // xgettext:no-php-format + new NUM_SPEC(tra("%"), 1, 100, 75) + ), ); $net_prefs = array( From 7fe31668ff401caf8d6716e79bf53bbc882ecaba Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 7 Aug 2022 09:47:01 -0700 Subject: [PATCH 09/21] Manager: gcc compile fix --- clientgui/DlgAdvPreferencesBase.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index 144e1f1a3cf..c4cbee35c2d 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -331,8 +331,9 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { m_txtMaxLoad = new wxTextCtrl( box, ID_TXTMAXLOAD, wxEmptyString, wxDefaultPosition, getTextCtrlSize(wxT("100.00")), wxTE_RIGHT ); + wxString load_tt(_("Suspend computing when your computer is busy running other programs.")); addNewRowToSizer(box_sizer, - wxString (_("Suspend computing when your computer is busy running other programs.")), + load_tt, m_chkMaxLoad, m_txtMaxLoad, new wxStaticText(box, ID_DEFAULT, wxT("%"), wxDefaultPosition, wxDefaultSize, 0) ); From c0504597e230b0f9b473cba25a477da1eca704d1 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 7 Aug 2022 09:57:29 -0700 Subject: [PATCH 10/21] sim: fix build error --- client/sim.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/sim.cpp b/client/sim.cpp index 9055d0821d8..8dcb59cfbfa 100644 --- a/client/sim.cpp +++ b/client/sim.cpp @@ -298,8 +298,8 @@ void CLIENT_STATE::get_workload(vector& ip_results) { IP_RESULT ipr(rp->name, rp->report_deadline-now, x); ip_results.push_back(ipr); } - //init_ip_results(work_buf_min(), ncpus, ip_results); - init_ip_results(0, ncpus, ip_results); + //init_ip_results(work_buf_min(), n_usable_ncpus, ip_results); + init_ip_results(0, n_usable_cpus, ip_results); } void get_apps_needing_work(PROJECT* p, vector& apps) { @@ -412,7 +412,7 @@ bool CLIENT_STATE::simulate_rpc(PROJECT* p) { double et = wup->rsc_fpops_est / rp->avp->flops; if (server_uses_workload) { IP_RESULT c(rp->name, rp->report_deadline-now, et); - if (check_candidate(c, ncpus, ip_results)) { + if (check_candidate(c, n_usable_cpus, ip_results)) { ip_results.push_back(c); } else { msg_printf(p, MSG_INFO, "job for %s misses deadline sim\n", rp->app->name); @@ -1495,7 +1495,7 @@ void do_client_simulation() { clear_backoff(); gstate.log_show_projects(); - gstate.set_ncpus(); + gstate.set_n_usable_cpus(); work_fetch.init(); //set_initial_rec(); From 70285e2d143419af629391b799c368c464d6121e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 7 Aug 2022 10:49:15 -0700 Subject: [PATCH 11/21] web: add "requires BOINC 7.20.3+" for new prefs --- html/inc/prefs.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/html/inc/prefs.inc b/html/inc/prefs.inc index 15b24f0168c..66d11f0dd8c 100644 --- a/html/inc/prefs.inc +++ b/html/inc/prefs.inc @@ -100,7 +100,7 @@ $in_use_prefs = [ ]; $not_in_use_prefs = [ new PREF_NUM( - tra("Use at most"), + tra("Use at most")."
Requires BOINC 7.20.3+", // xgettext:no-php-format tra("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU."), "niu_max_ncpus_pct", @@ -108,7 +108,7 @@ $not_in_use_prefs = [ new NUM_SPEC(tra("% of the CPUs"), 1, 100, 100) ), new PREF_NUM( - tra("Use at most"), + tra("Use at most") ."
Requires BOINC 7.20.3+", // xgettext:no-php-format tra("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat."), "niu_cpu_usage_limit", @@ -116,7 +116,7 @@ $not_in_use_prefs = [ new NUM_SPEC(tra("% of CPU time"), 1, 100, 100) ), new PREF_OPT_NUM( - tra("Suspend when non-BOINC CPU usage is above"), + tra("Suspend when non-BOINC CPU usage is above")."
Requires BOINC 7.20.3+", tra("Suspend computing when your computer is busy running other programs."), "niu_suspend_cpu_usage", new NUM_SPEC("%", 0, 100, 25) From d8e6d4e115e7bf005520de9dc01ea55d41a68550 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 9 Aug 2022 21:25:52 -0700 Subject: [PATCH 12/21] client: print global prefs more completely (e.g. show not-in-use prefs) --- client/client_state.h | 3 +- client/cs_prefs.cpp | 142 +++++++++++++++++++++++++++++++----------- 2 files changed, 109 insertions(+), 36 deletions(-) diff --git a/client/client_state.h b/client/client_state.h index ae65adf720e..a3439d823fb 100644 --- a/client/client_state.h +++ b/client/client_state.h @@ -424,6 +424,7 @@ struct CLIENT_STATE { const char* fname = GLOBAL_PREFS_FILE_NAME, const char* override_fname = GLOBAL_PREFS_OVERRIDE_FILE ); + void print_global_prefs(); int save_global_prefs(const char* prefs, char* url, char* sched); double available_ram(); double max_available_ram(); @@ -525,7 +526,7 @@ struct CLIENT_STATE { if (!user_active && global_prefs.niu_cpu_usage_limit>=0) { x = global_prefs.niu_cpu_usage_limit; } - if (x < 0.005 || x > 99) { + if (x < 0.005 || x > 99.99) { x = 100; } return x; diff --git a/client/cs_prefs.cpp b/client/cs_prefs.cpp index 8d07fd2084d..0211cdf8e15 100644 --- a/client/cs_prefs.cpp +++ b/client/cs_prefs.cpp @@ -648,53 +648,125 @@ void CLIENT_STATE::read_global_prefs( } } - msg_printf(NULL, MSG_INFO, "Preferences:"); - msg_printf(NULL, MSG_INFO, - " max memory usage when active: %.2f MB", - (host_info.m_nbytes*global_prefs.ram_max_used_busy_frac)/MEGA - ); - msg_printf(NULL, MSG_INFO, - " max memory usage when idle: %.2f MB", - (host_info.m_nbytes*global_prefs.ram_max_used_idle_frac)/MEGA - ); #ifndef SIM get_disk_usages(); - msg_printf(NULL, MSG_INFO, - " max disk usage: %.2f GB", - allowed_disk_usage(total_disk_usage)/GIGA - ); #endif - // max_cpus, bandwidth limits may have changed - // set_n_usable_cpus(); - if (n_usable_cpus != host_info.p_ncpus) { - msg_printf(NULL, MSG_INFO, - " max CPUs used: %d", n_usable_cpus - ); - } - if (!global_prefs.run_if_user_active) { - msg_printf(NULL, MSG_INFO, " don't compute while active"); + #ifdef ANDROID - } else { - msg_printf(NULL, MSG_INFO, " Android: don't compute while active"); - global_prefs.run_if_user_active = false; + global_prefs.run_if_user_active = false; +#endif +#ifndef SIM + file_xfers->set_bandwidth_limits(true); + file_xfers->set_bandwidth_limits(false); +#endif + print_global_prefs(); + request_schedule_cpus("Prefs update"); + request_work_fetch("Prefs update"); +#ifndef SIM + active_tasks.request_reread_app_info(); #endif +} + +void CLIENT_STATE::print_global_prefs() { + msg_printf(NULL, MSG_INFO, "Preferences:"); + + // in use + // + msg_printf(NULL, MSG_INFO, " When computer is in use:"); + msg_printf(NULL, MSG_INFO, + " 'In use' means mouse/keyboard in put in last %.1f minutes", + global_prefs.idle_time_to_run + ); + if (!global_prefs.run_if_user_active) { + msg_printf(NULL, MSG_INFO, " don't compute"); } if (!global_prefs.run_gpu_if_user_active) { - msg_printf(NULL, MSG_INFO, " don't use GPU while active"); + msg_printf(NULL, MSG_INFO, " don't use GPU"); + } + double p = global_prefs.max_ncpus_pct; + if (p) { + int n = (int)((host_info.p_ncpus * p)/100); + msg_printf(NULL, MSG_INFO, + " max CPUs used: %d", n + ); + } + if (global_prefs.cpu_usage_limit) { + msg_printf(NULL, MSG_INFO, + " Use at most %.0f%% of the CPU time", + global_prefs.cpu_usage_limit + ); } if (global_prefs.suspend_cpu_usage) { msg_printf(NULL, MSG_INFO, - " suspend work if non-BOINC CPU load exceeds %.0f%%", + " suspend work if non-BOINC CPU load exceeds %.0f%%", global_prefs.suspend_cpu_usage ); } + msg_printf(NULL, MSG_INFO, + " max memory usage: %.2f GB", + (host_info.m_nbytes*global_prefs.ram_max_used_busy_frac)/GIGA + ); + + // not in use + // + msg_printf(NULL, MSG_INFO, + " When computer is not in use (defaults: same as in use)" + ); + p = global_prefs.niu_max_ncpus_pct; + if (p) { + int n = (int)((host_info.p_ncpus * p)/100); + msg_printf(NULL, MSG_INFO, + " max CPUs used: %d", n + ); + } + if (global_prefs.niu_cpu_usage_limit) { + msg_printf(NULL, MSG_INFO, + " Use at most %.0f%% of the CPU time", + global_prefs.niu_cpu_usage_limit + ); + } if (global_prefs.niu_suspend_cpu_usage > 0) { msg_printf(NULL, MSG_INFO, - " when idle, suspend work if non-BOINC CPU load exceeds %.0f%%", + " suspend work if non-BOINC CPU load exceeds %.0f%%", global_prefs.niu_suspend_cpu_usage ); } + msg_printf(NULL, MSG_INFO, + " max memory usage: %.2f GB", + (host_info.m_nbytes*global_prefs.ram_max_used_idle_frac)/GIGA + ); + if (global_prefs.suspend_if_no_recent_input > 0) { + msg_printf(NULL, MSG_INFO, + " Suspend if no input in last %f minutes", + global_prefs.suspend_if_no_recent_input + ); + } + + // general + // + + if (!global_prefs.run_on_batteries) { + msg_printf(NULL, MSG_INFO, + " Suspend if running on batteries" + ); + } + if (global_prefs.leave_apps_in_memory) { + msg_printf(NULL, MSG_INFO, + " Leave apps in memory if not running" + ); + } + msg_printf(NULL, MSG_INFO, + " Store at least %.2f days of work", + global_prefs.work_buf_min_days + ); + msg_printf(NULL, MSG_INFO, + " Store up to an additional %.2f days of work", + global_prefs.work_buf_additional_days + ); + + // network + // if (global_prefs.max_bytes_sec_down) { msg_printf(NULL, MSG_INFO, " max download rate: %.0f bytes/sec", @@ -707,18 +779,18 @@ void CLIENT_STATE::read_global_prefs( global_prefs.max_bytes_sec_up ); } + + // disk + // #ifndef SIM - file_xfers->set_bandwidth_limits(true); - file_xfers->set_bandwidth_limits(false); + msg_printf(NULL, MSG_INFO, + " max disk usage: %.2f GB", + allowed_disk_usage(total_disk_usage)/GIGA + ); #endif msg_printf(NULL, MSG_INFO, " (to change preferences, visit a project web site or select Preferences in the Manager)" ); - request_schedule_cpus("Prefs update"); - request_work_fetch("Prefs update"); -#ifndef SIM - active_tasks.request_reread_app_info(); -#endif } int CLIENT_STATE::save_global_prefs( From 3b73baa492c4321eb575db102d9023aad27780ea Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 9 Aug 2022 21:48:47 -0700 Subject: [PATCH 13/21] client: put - at start of leading whitespace in messages, else it gets stripped --- client/cs_prefs.cpp | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/client/cs_prefs.cpp b/client/cs_prefs.cpp index 0211cdf8e15..1686db99101 100644 --- a/client/cs_prefs.cpp +++ b/client/cs_prefs.cpp @@ -673,72 +673,72 @@ void CLIENT_STATE::print_global_prefs() { // in use // - msg_printf(NULL, MSG_INFO, " When computer is in use:"); + msg_printf(NULL, MSG_INFO, "- When computer is in use:"); msg_printf(NULL, MSG_INFO, - " 'In use' means mouse/keyboard in put in last %.1f minutes", + "- 'In use' means mouse/keyboard in put in last %.1f minutes", global_prefs.idle_time_to_run ); if (!global_prefs.run_if_user_active) { - msg_printf(NULL, MSG_INFO, " don't compute"); + msg_printf(NULL, MSG_INFO, "- don't compute"); } if (!global_prefs.run_gpu_if_user_active) { - msg_printf(NULL, MSG_INFO, " don't use GPU"); + msg_printf(NULL, MSG_INFO, "- don't use GPU"); } double p = global_prefs.max_ncpus_pct; if (p) { int n = (int)((host_info.p_ncpus * p)/100); msg_printf(NULL, MSG_INFO, - " max CPUs used: %d", n + "- max CPUs used: %d", n ); } if (global_prefs.cpu_usage_limit) { msg_printf(NULL, MSG_INFO, - " Use at most %.0f%% of the CPU time", + "- Use at most %.0f%% of the CPU time", global_prefs.cpu_usage_limit ); } if (global_prefs.suspend_cpu_usage) { msg_printf(NULL, MSG_INFO, - " suspend work if non-BOINC CPU load exceeds %.0f%%", + "- suspend work if non-BOINC CPU load exceeds %.0f%%", global_prefs.suspend_cpu_usage ); } msg_printf(NULL, MSG_INFO, - " max memory usage: %.2f GB", + "- max memory usage: %.2f GB", (host_info.m_nbytes*global_prefs.ram_max_used_busy_frac)/GIGA ); // not in use // msg_printf(NULL, MSG_INFO, - " When computer is not in use (defaults: same as in use)" + "- When computer is not in use (defaults: same as in use)" ); p = global_prefs.niu_max_ncpus_pct; if (p) { int n = (int)((host_info.p_ncpus * p)/100); msg_printf(NULL, MSG_INFO, - " max CPUs used: %d", n + "- max CPUs used: %d", n ); } if (global_prefs.niu_cpu_usage_limit) { msg_printf(NULL, MSG_INFO, - " Use at most %.0f%% of the CPU time", + "- Use at most %.0f%% of the CPU time", global_prefs.niu_cpu_usage_limit ); } if (global_prefs.niu_suspend_cpu_usage > 0) { msg_printf(NULL, MSG_INFO, - " suspend work if non-BOINC CPU load exceeds %.0f%%", + "- suspend work if non-BOINC CPU load exceeds %.0f%%", global_prefs.niu_suspend_cpu_usage ); } msg_printf(NULL, MSG_INFO, - " max memory usage: %.2f GB", + "- max memory usage: %.2f GB", (host_info.m_nbytes*global_prefs.ram_max_used_idle_frac)/GIGA ); if (global_prefs.suspend_if_no_recent_input > 0) { msg_printf(NULL, MSG_INFO, - " Suspend if no input in last %f minutes", + "- Suspend if no input in last %f minutes", global_prefs.suspend_if_no_recent_input ); } @@ -748,20 +748,20 @@ void CLIENT_STATE::print_global_prefs() { if (!global_prefs.run_on_batteries) { msg_printf(NULL, MSG_INFO, - " Suspend if running on batteries" + "- Suspend if running on batteries" ); } if (global_prefs.leave_apps_in_memory) { msg_printf(NULL, MSG_INFO, - " Leave apps in memory if not running" + "- Leave apps in memory if not running" ); } msg_printf(NULL, MSG_INFO, - " Store at least %.2f days of work", + "- Store at least %.2f days of work", global_prefs.work_buf_min_days ); msg_printf(NULL, MSG_INFO, - " Store up to an additional %.2f days of work", + "- Store up to an additional %.2f days of work", global_prefs.work_buf_additional_days ); @@ -769,13 +769,13 @@ void CLIENT_STATE::print_global_prefs() { // if (global_prefs.max_bytes_sec_down) { msg_printf(NULL, MSG_INFO, - " max download rate: %.0f bytes/sec", + "- max download rate: %.0f bytes/sec", global_prefs.max_bytes_sec_down ); } if (global_prefs.max_bytes_sec_up) { msg_printf(NULL, MSG_INFO, - " max upload rate: %.0f bytes/sec", + "- max upload rate: %.0f bytes/sec", global_prefs.max_bytes_sec_up ); } @@ -784,12 +784,12 @@ void CLIENT_STATE::print_global_prefs() { // #ifndef SIM msg_printf(NULL, MSG_INFO, - " max disk usage: %.2f GB", + "- max disk usage: %.2f GB", allowed_disk_usage(total_disk_usage)/GIGA ); #endif msg_printf(NULL, MSG_INFO, - " (to change preferences, visit a project web site or select Preferences in the Manager)" + "- (to change preferences, visit a project web site or select Preferences in the Manager)" ); } From 5df4b27d4a3c2dd512fc97241dad2390cc137cd7 Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Fri, 12 Aug 2022 16:21:12 -0700 Subject: [PATCH 14/21] Manager: shorten prefs dialog --- client/cs_prefs.cpp | 8 +- clientgui/DlgAdvPreferencesBase.cpp | 165 +++++++++++++++++++--------- clientgui/DlgAdvPreferencesBase.h | 8 ++ 3 files changed, 128 insertions(+), 53 deletions(-) diff --git a/client/cs_prefs.cpp b/client/cs_prefs.cpp index 1686db99101..82fc9e6ddd7 100644 --- a/client/cs_prefs.cpp +++ b/client/cs_prefs.cpp @@ -673,9 +673,9 @@ void CLIENT_STATE::print_global_prefs() { // in use // - msg_printf(NULL, MSG_INFO, "- When computer is in use:"); + msg_printf(NULL, MSG_INFO, "- When computer is in use"); msg_printf(NULL, MSG_INFO, - "- 'In use' means mouse/keyboard in put in last %.1f minutes", + "- 'In use' means mouse/keyboard input in last %.1f minutes", global_prefs.idle_time_to_run ); if (!global_prefs.run_if_user_active) { @@ -699,7 +699,7 @@ void CLIENT_STATE::print_global_prefs() { } if (global_prefs.suspend_cpu_usage) { msg_printf(NULL, MSG_INFO, - "- suspend work if non-BOINC CPU load exceeds %.0f%%", + "- suspend if non-BOINC CPU load exceeds %.0f%%", global_prefs.suspend_cpu_usage ); } @@ -728,7 +728,7 @@ void CLIENT_STATE::print_global_prefs() { } if (global_prefs.niu_suspend_cpu_usage > 0) { msg_printf(NULL, MSG_INFO, - "- suspend work if non-BOINC CPU load exceeds %.0f%%", + "- suspend if non-BOINC CPU load exceeds %.0f%%", global_prefs.niu_suspend_cpu_usage ); } diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index c4cbee35c2d..89859d3aef5 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -85,15 +85,16 @@ CDlgAdvPreferencesBase::CDlgAdvPreferencesBase( wxWindow* parent, int id, wxStri if (m_bUsingLocalPrefs) { legendSizer->Add( new wxStaticText( topControlsStaticBox, ID_DEFAULT, - _("Using local preferences.\n" - "Click \"Use web prefs\" to use web-based preferences from" - ), wxDefaultPosition, wxDefaultSize, 0 ), + _("Using local prefs.") + + " " + +_("Click to use web prefs from"), + wxDefaultPosition, wxDefaultSize, 0 ), 0, wxALL, 1 ); } else { legendSizer->Add( new wxStaticText( topControlsStaticBox, ID_DEFAULT, - _("Using web-based preferences from"), + _("Using web prefs from"), wxDefaultPosition, wxDefaultSize, 0 ), 0, wxALL, 1 ); @@ -110,7 +111,7 @@ CDlgAdvPreferencesBase::CDlgAdvPreferencesBase( wxWindow* parent, int id, wxStri if (!m_bUsingLocalPrefs) { legendSizer->Add( new wxStaticText( topControlsStaticBox, ID_DEFAULT, - _("Set values and click Save to use local preferences instead."), + _("Set values and click Save to use local prefs instead."), wxDefaultPosition, wxDefaultSize, 0 ), 0, wxALL, 1 ); @@ -201,43 +202,72 @@ CDlgAdvPreferencesBase::CDlgAdvPreferencesBase( wxWindow* parent, int id, wxStri this->SetSizer( dialogSizer ); } +#define PAD0 1 +#define PAD1 3 + +// this version lets you attach different tooltips to different items +// +void CDlgAdvPreferencesBase::add_row_to_sizer2(wxSizer* toSizer, + wxWindow* item1, wxString& tt1, + wxWindow* item2, wxString& tt2, + wxWindow* item3, wxString& tt3, + wxWindow* item4, wxString& tt4, + wxWindow* item5, wxString& tt5 +) { + wxBoxSizer* rowSizer = new wxBoxSizer(wxHORIZONTAL); + + rowSizer->Add(item1, 0, wxALL, PAD1); + item1->SetToolTip(tt1); + rowSizer->Add(item2, 0, wxALL, PAD0); + item2->SetToolTip(tt2); + rowSizer->Add(item3, 0, wxALL, PAD1); + item3->SetToolTip(tt3); + rowSizer->Add(item4, 0, wxALL, PAD0); + item4->SetToolTip(tt4); + rowSizer->Add(item5, 0, wxALL, PAD1); + item5->SetToolTip(tt5); + + toSizer->Add(rowSizer, 0, 0, 1); +} + void CDlgAdvPreferencesBase::addNewRowToSizer( - wxSizer* toSizer, wxString& toolTipText, - wxWindow* first, wxWindow* second, wxWindow* third, - wxWindow* fourth, wxWindow* fifth) -{ - wxBoxSizer* rowSizer = new wxBoxSizer( wxHORIZONTAL ); + wxSizer* toSizer, wxString& toolTipText, + wxWindow* first, wxWindow* second, wxWindow* third, + wxWindow* fourth, wxWindow* fifth +) { + wxBoxSizer* rowSizer = new wxBoxSizer(wxHORIZONTAL); #ifdef __WXMSW__ // MSW adds space to the right of checkbox label if (first->IsKindOf(CLASSINFO(wxCheckBox))) { - rowSizer->Add(first, 0, wxTOP | wxBOTTOM |wxLEFT, 5 ); + rowSizer->Add(first, 0, wxTOP | wxBOTTOM |wxLEFT, PAD1 ); } else #endif - rowSizer->Add(first, 0, wxALL, 5 ); + rowSizer->Add(first, 0, wxALL, PAD1 ); + + // the last arg is padding. Less for text fields, to make things line up first->SetToolTip(toolTipText); - rowSizer->Add(second, 0, wxALL, 2 ); + rowSizer->Add(second, 0, wxALL, PAD0 ); second->SetToolTip(toolTipText); - rowSizer->Add(third, 0, wxALL, 5 ); + rowSizer->Add(third, 0, wxALL, PAD1); third->SetToolTip(toolTipText); if (fourth) { - rowSizer->Add(fourth, 0, wxALL, 2 ); + rowSizer->Add(fourth, 0, wxALL, PAD0); fourth->SetToolTip(toolTipText); } if (fifth) { - rowSizer->Add(fifth, 0, wxALL, 5 ); + rowSizer->Add(fifth, 0, wxALL, PAD1); fifth->SetToolTip(toolTipText); } toSizer->Add( rowSizer, 0, 0, 1 ); } - wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { CSkinAdvanced* pSkinAdvanced = wxGetApp().GetSkinManager()->GetAdvanced(); wxASSERT(pSkinAdvanced); @@ -260,8 +290,8 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { wxString ProcIdleForTT(_("This determines when the computer is considered 'in use'.")); wxStaticText* staticText24 = new wxStaticText( box, ID_DEFAULT, - // context: 'In use' means mouse/keyboard input in last ___ minutes - _("'In use' means mouse/keyboard input in last"), + // context: 'In use' means mouse or keyboard input in last ___ minutes + _("'In use' means mouse or keyboard input in last"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtProcIdleFor = new wxTextCtrl( @@ -269,7 +299,7 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { ); wxStaticText* staticText25 = new wxStaticText( box, ID_DEFAULT, - // context: 'In use' means mouse/keyboard input in last ___ minutes + // context: 'In use' means mouse or keyboard input in last ___ minutes _("minutes"), wxDefaultPosition, wxDefaultSize, 0 ); @@ -297,29 +327,29 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { ); box_sizer->Add( m_chkGPUProcInUse, 0, wxALL, 5 ); - // max # CPUs + // max # CPUs and throttling // - /*xgettext:no-c-format*/ - wxString MaxCPUPctTT(_("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.")); wxStaticText* staticText20 = new wxStaticText( box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtProcUseProcessors = new wxTextCtrl(box, ID_TXTPROCUSEPROCESSORS, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); - /*xgettext:no-c-format*/ - wxStaticText* staticText21 = new wxStaticText(box, ID_DEFAULT, _("% of the CPUs"), wxDefaultPosition, wxDefaultSize, 0 ); - addNewRowToSizer(box_sizer, MaxCPUPctTT, staticText20, m_txtProcUseProcessors, staticText21); - - // CPU throttling - // - /*xgettext:no-c-format*/ - wxString MaxCPUTimeTT(_("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.")); wxStaticText* staticText22 = new wxStaticText( - box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 + box, ID_DEFAULT, _("% of the CPUs and at most"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtProcUseCPUTime = new wxTextCtrl(box, ID_TXTPROCUSECPUTIME, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); /*xgettext:no-c-format*/ wxStaticText* staticText23 = new wxStaticText(box, ID_DEFAULT, _("% of CPU time"), wxDefaultPosition, wxDefaultSize, 0 ); - addNewRowToSizer(box_sizer, MaxCPUTimeTT, staticText22, m_txtProcUseCPUTime, staticText23); + /*xgettext:no-c-format*/ + wxString tt_ncpus(_("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.")); + /*xgettext:no-c-format*/ + wxString tt_throttle(_("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.")); + add_row_to_sizer2(box_sizer, + staticText20, tt_ncpus, + m_txtProcUseProcessors, tt_ncpus, + staticText22, tt_ncpus, + m_txtProcUseCPUTime, tt_throttle, + staticText23, tt_throttle + ); // max CPU load // @@ -359,28 +389,26 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { box_sizer = new wxStaticBoxSizer(box, wxVERTICAL); makeStaticBoxLabelItalic(box); - // max # CPUs + // max # CPUs and throttling // - /*xgettext:no-c-format*/ - wxString MaxCPUPctTTniu(_("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU.")); wxStaticText* staticText20niu = new wxStaticText( box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtProcUseProcessorsNotInUse = new wxTextCtrl(box, ID_TXTPROCUSEPROCESSORSNOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT); - /*xgettext:no-c-format*/ - wxStaticText* staticText21niu = new wxStaticText(box, ID_DEFAULT, _("% of the CPUs"), wxDefaultPosition, wxDefaultSize, 0); - addNewRowToSizer(box_sizer, MaxCPUPctTTniu, staticText20niu, m_txtProcUseProcessorsNotInUse, staticText21niu); - - // CPU throttling - // - wxString MaxCPUTimeTTniu(_("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat.")); wxStaticText* staticText22niu = new wxStaticText( - box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 + /*xgettext:no-c-format*/ + box, ID_DEFAULT, _("% of the CPUs and at most"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtProcUseCPUTimeNotInUse = new wxTextCtrl(box, ID_TXTPROCUSECPUTIMENOTINUSE, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT); /*xgettext:no-c-format*/ wxStaticText* staticText23niu = new wxStaticText(box, ID_DEFAULT, _("% of CPU time"), wxDefaultPosition, wxDefaultSize, 0); - addNewRowToSizer(box_sizer, MaxCPUTimeTTniu, staticText22niu, m_txtProcUseCPUTimeNotInUse, staticText23niu); + add_row_to_sizer2(box_sizer, + staticText20niu, tt_ncpus, + m_txtProcUseProcessorsNotInUse, tt_ncpus, + staticText22niu, tt_ncpus, + m_txtProcUseCPUTimeNotInUse, tt_throttle, + staticText23niu, tt_throttle + ); // max CPU load // @@ -411,7 +439,7 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { // suspend after idle time // wxString str0 = wxEmptyString; - str0.Printf(_("Suspend when no mouse/keyboard input in last")); + str0.Printf(_("Suspend when no mouse or keyboard input in last")); m_chkNoRecentInput = new wxCheckBox( box, ID_CHKNORECENTINPUT, str0, wxDefaultPosition, wxDefaultSize, 0 ); @@ -490,6 +518,7 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { m_chkMemoryWhileSuspended->SetToolTip(_("If checked, suspended tasks stay in memory, and resume with no work lost. If unchecked, suspended tasks are removed from memory, and resume from their last checkpoint.")); box_sizer->Add(m_chkMemoryWhileSuspended, 0, wxALL, 5); +#if 0 // work buffer min // wxString NetConnectIntervalTT(_("Store at least enough tasks to keep the computer busy for this long.")); @@ -530,17 +559,55 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { wxDefaultPosition, wxDefaultSize, 0 ); addNewRowToSizer(box_sizer, NetAdditionalDaysTT, staticText331, m_txtNetAdditionalDays, staticText341); +#else + // work buffer + // + wxString tt_min(_("Store at least enough tasks to keep the computer busy for this long.")); + wxStaticText* staticText30 = new wxStaticText( + box, ID_DEFAULT, + // context: Store at least ___ days of work + _("Store at least"), + wxDefaultPosition, wxDefaultSize, 0 + ); + m_txtNetConnectInterval = new wxTextCtrl( + box, ID_TXTNETCONNECTINTERVAL, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT + ); + wxStaticText* staticText31 = new wxStaticText( + box, ID_DEFAULT, + // context: Store at least ___ days of work + _("days and up to an additional"), + wxDefaultPosition, wxDefaultSize, 0 + ); + wxString tt_extra(_("Store additional tasks above the minimum level. Determines how much work is requested when contacting a project.")); + m_txtNetAdditionalDays = new wxTextCtrl( + box, ID_TXTNETADDITIONALDAYS, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT + ); + wxStaticText* staticText341 = new wxStaticText( + box, ID_DEFAULT, + // context: Store up to an additional ___ days of work + _("days of work"), + wxDefaultPosition, wxDefaultSize, 0 + ); + add_row_to_sizer2(box_sizer, + staticText30, tt_min, + m_txtNetConnectInterval, tt_min, + staticText31, tt_min, + m_txtNetAdditionalDays, tt_extra, + staticText341, tt_extra + ); +#endif +#if 0 box_sizer->Add( new wxStaticText(box, ID_DEFAULT, _("To suspend by time of day, see the \"Daily Schedules\" section."), wxDefaultPosition, wxDefaultSize, 0), 0, wxALL, 5 ); - +#endif box_sizer->AddSpacer(1); // Ensure staticText22 is fully visible on Mac - processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); + //processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); processorTabSizer->Add( box_sizer, 0, wxLEFT | wxRIGHT | wxEXPAND, STATICBOXBORDERSIZE ); - processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); + //processorTabSizer->AddSpacer( STATICBOXVERTICALSPACER ); processorTab->SetSizer( processorTabSizer ); processorTab->Layout(); diff --git a/clientgui/DlgAdvPreferencesBase.h b/clientgui/DlgAdvPreferencesBase.h index fe06690b249..94d3bc3be97 100644 --- a/clientgui/DlgAdvPreferencesBase.h +++ b/clientgui/DlgAdvPreferencesBase.h @@ -277,6 +277,14 @@ class CDlgAdvPreferencesBase : public wxDialog { wxWindow* first, wxWindow* second, wxWindow* third, wxWindow* fourth=NULL, wxWindow* fifth=NULL ); + // variant with separate tooltip per item + void add_row_to_sizer2(wxSizer* toSizer, + wxWindow* item1, wxString& tt1, + wxWindow* item2, wxString& tt2, + wxWindow* item3, wxString& tt3, + wxWindow* item4, wxString& tt4, + wxWindow* item5, wxString& tt5 + ); wxPanel* createProcessorTab(wxNotebook* notebook); wxPanel* createNetworkTab(wxNotebook* notebook); wxPanel* createDiskTab(wxNotebook* notebook); From 482da2ba4e0559aa357f27ee9c6a3011128d16f5 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sun, 14 Aug 2022 02:50:26 -0700 Subject: [PATCH 15/21] Disable other "while in use" options if "Suspend when computer is in use" is set. --- clientgui/DlgAdvPreferences.cpp | 57 ++++++++++++++++++++++++--------- clientgui/DlgAdvPreferences.h | 2 ++ 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 903ebea24ff..f2874554aea 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -277,6 +277,27 @@ void CDlgAdvPreferences::DisplayValue(double value, wxTextCtrl* textCtrl, wxChec textCtrl->Enable(); } +void CDlgAdvPreferences::EnableDisableNotInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value) { + if (doEnable) { + if (! textCtrl->IsEnabled()) { + textCtrl->Enable(); + DisplayValue(value, textCtrl); + } + } else { + textCtrl->Clear(); + textCtrl->Disable(); + } +} + +void CDlgAdvPreferences::EnableDisableNotInUseItems() { + bool doEnable = !(m_chkProcInUse->IsChecked()); + EnableDisableNotInUseItem(m_txtProcUseProcessors, doEnable, + defaultPrefs.max_ncpus_pct > 0.0 ? defaultPrefs.max_ncpus_pct : 100.0); + EnableDisableNotInUseItem(m_txtProcUseCPUTime, doEnable, defaultPrefs.cpu_usage_limit); + m_chkMaxLoad->Enable(doEnable); + EnableDisableNotInUseItem(m_txtMaxLoad, doEnable && m_chkMaxLoad->IsChecked(), defaultPrefs.suspend_cpu_usage); + EnableDisableNotInUseItem(m_txtMemoryMaxInUse, doEnable, defaultPrefs.ram_max_used_busy_frac*100.0); +} // read preferences from core client and initialize control values // @@ -452,16 +473,20 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { mask.clear(); // ######### proc usage page - m_txtProcUseProcessors->GetValue().ToDouble(&td); - prefs.max_ncpus_pct = RoundToHundredths(td); - mask.max_ncpus_pct=true; + if (m_txtProcUseProcessors->IsEnabled()) { + m_txtProcUseProcessors->GetValue().ToDouble(&td); + prefs.max_ncpus_pct = RoundToHundredths(td); + mask.max_ncpus_pct=true; + } m_txtProcUseProcessorsNotInUse->GetValue().ToDouble(&td); prefs.niu_max_ncpus_pct = RoundToHundredths(td); mask.niu_max_ncpus_pct=true; - - m_txtProcUseCPUTime->GetValue().ToDouble(&td); - prefs.cpu_usage_limit=RoundToHundredths(td); - mask.cpu_usage_limit=true; + + if (m_txtProcUseCPUTime->IsEnabled()) { + m_txtProcUseCPUTime->GetValue().ToDouble(&td); + prefs.cpu_usage_limit=RoundToHundredths(td); + mask.cpu_usage_limit=true; + } m_txtProcUseCPUTimeNotInUse->GetValue().ToDouble(&td); prefs.niu_cpu_usage_limit = RoundToHundredths(td); mask.niu_cpu_usage_limit = true; @@ -489,7 +514,7 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { } mask.suspend_if_no_recent_input = true; - if (m_chkMaxLoad->IsChecked()) { + if (m_txtMaxLoad->IsEnabled()) { m_txtMaxLoad->GetValue().ToDouble(&td); prefs.suspend_cpu_usage=RoundToHundredths(td); } else { @@ -593,11 +618,13 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { } mask.disk_max_used_pct=true; //Memory - m_txtMemoryMaxInUse->GetValue().ToDouble(&td); - td = RoundToHundredths(td); - td = td / 100.0; - prefs.ram_max_used_busy_frac=td; - mask.ram_max_used_busy_frac=true; + if (m_txtMemoryMaxInUse->IsEnabled()) { + m_txtMemoryMaxInUse->GetValue().ToDouble(&td); + td = RoundToHundredths(td); + td = td / 100.0; + prefs.ram_max_used_busy_frac=td; + mask.ram_max_used_busy_frac=true; + } // m_txtMemoryMaxOnIdle->GetValue().ToDouble(&td); td = RoundToHundredths(td); @@ -677,8 +704,8 @@ void CDlgAdvPreferences::UpdateControlStates() { m_chkGPUProcInUse->Enable(! m_chkProcInUse->IsChecked()); if (m_chkProcInUse->IsChecked()) m_chkGPUProcInUse->SetValue(true); - m_txtMaxLoad->Enable(m_chkMaxLoad->IsChecked()); m_txtMaxLoadNotInUse->Enable(m_chkMaxLoadNotInUse->IsChecked()); + EnableDisableNotInUseItems(); m_txtNoRecentInput->Enable(m_chkNoRecentInput->IsChecked()); // ######### disk and memory usage page @@ -752,7 +779,7 @@ bool CDlgAdvPreferences::ValidateInput() { } } - if (m_chkMaxLoad->IsChecked()) { + if (m_txtMaxLoad->IsEnabled()) { buffer = m_txtMaxLoad->GetValue(); if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) { ShowErrorMessage(invMsgLimit1_100, m_txtMaxLoad); diff --git a/clientgui/DlgAdvPreferences.h b/clientgui/DlgAdvPreferences.h index 220c6a90a29..d11b1278cbc 100644 --- a/clientgui/DlgAdvPreferences.h +++ b/clientgui/DlgAdvPreferences.h @@ -59,6 +59,8 @@ class CDlgAdvPreferences : public CDlgAdvPreferencesBase { void OnHelp(wxCommandEvent& event); void OnClear(wxCommandEvent& event); void DisplayValue(double value, wxTextCtrl* textCtrl, wxCheckBox* checkBox=NULL); + void EnableDisableNotInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value); + void EnableDisableNotInUseItems(); bool OKToShow() { return m_bOKToShow; } private: GLOBAL_PREFS prefs; From 73ec053fb6bbaf46a6f6f47c8dec6f2e1b6c4ec1 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sun, 14 Aug 2022 02:55:09 -0700 Subject: [PATCH 16/21] Add missing xgettext flag for non-format use of "%" symbol --- clientgui/DlgAdvPreferencesBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/clientgui/DlgAdvPreferencesBase.cpp b/clientgui/DlgAdvPreferencesBase.cpp index 89859d3aef5..ce23d3056b4 100644 --- a/clientgui/DlgAdvPreferencesBase.cpp +++ b/clientgui/DlgAdvPreferencesBase.cpp @@ -333,6 +333,7 @@ wxPanel* CDlgAdvPreferencesBase::createProcessorTab(wxNotebook* notebook) { box, ID_DEFAULT, _("Use at most"), wxDefaultPosition, wxDefaultSize, 0 ); m_txtProcUseProcessors = new wxTextCtrl(box, ID_TXTPROCUSEPROCESSORS, wxEmptyString, wxDefaultPosition, textCtrlSize, wxTE_RIGHT ); + /*xgettext:no-c-format*/ wxStaticText* staticText22 = new wxStaticText( box, ID_DEFAULT, _("% of the CPUs and at most"), wxDefaultPosition, wxDefaultSize, 0 ); From 22aa492fd1ccab5d1e7d440f6bd89e8ee67d7ac1 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sun, 14 Aug 2022 04:46:07 -0700 Subject: [PATCH 17/21] Fix typo in method names --- clientgui/DlgAdvPreferences.cpp | 14 +++++++------- clientgui/DlgAdvPreferences.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index f2874554aea..b5c4938eaff 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -277,7 +277,7 @@ void CDlgAdvPreferences::DisplayValue(double value, wxTextCtrl* textCtrl, wxChec textCtrl->Enable(); } -void CDlgAdvPreferences::EnableDisableNotInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value) { +void CDlgAdvPreferences::EnableDisableInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value) { if (doEnable) { if (! textCtrl->IsEnabled()) { textCtrl->Enable(); @@ -289,14 +289,14 @@ void CDlgAdvPreferences::EnableDisableNotInUseItem(wxTextCtrl* textCtrl, bool do } } -void CDlgAdvPreferences::EnableDisableNotInUseItems() { +void CDlgAdvPreferences::EnableDisableInUseItems() { bool doEnable = !(m_chkProcInUse->IsChecked()); - EnableDisableNotInUseItem(m_txtProcUseProcessors, doEnable, + EnableDisableInUseItem(m_txtProcUseProcessors, doEnable, defaultPrefs.max_ncpus_pct > 0.0 ? defaultPrefs.max_ncpus_pct : 100.0); - EnableDisableNotInUseItem(m_txtProcUseCPUTime, doEnable, defaultPrefs.cpu_usage_limit); + EnableDisableInUseItem(m_txtProcUseCPUTime, doEnable, defaultPrefs.cpu_usage_limit); m_chkMaxLoad->Enable(doEnable); - EnableDisableNotInUseItem(m_txtMaxLoad, doEnable && m_chkMaxLoad->IsChecked(), defaultPrefs.suspend_cpu_usage); - EnableDisableNotInUseItem(m_txtMemoryMaxInUse, doEnable, defaultPrefs.ram_max_used_busy_frac*100.0); + EnableDisableInUseItem(m_txtMaxLoad, doEnable && m_chkMaxLoad->IsChecked(), defaultPrefs.suspend_cpu_usage); + EnableDisableInUseItem(m_txtMemoryMaxInUse, doEnable, defaultPrefs.ram_max_used_busy_frac*100.0); } // read preferences from core client and initialize control values @@ -705,7 +705,7 @@ void CDlgAdvPreferences::UpdateControlStates() { if (m_chkProcInUse->IsChecked()) m_chkGPUProcInUse->SetValue(true); m_txtMaxLoadNotInUse->Enable(m_chkMaxLoadNotInUse->IsChecked()); - EnableDisableNotInUseItems(); + EnableDisableInUseItems(); m_txtNoRecentInput->Enable(m_chkNoRecentInput->IsChecked()); // ######### disk and memory usage page diff --git a/clientgui/DlgAdvPreferences.h b/clientgui/DlgAdvPreferences.h index d11b1278cbc..365e530f065 100644 --- a/clientgui/DlgAdvPreferences.h +++ b/clientgui/DlgAdvPreferences.h @@ -59,8 +59,8 @@ class CDlgAdvPreferences : public CDlgAdvPreferencesBase { void OnHelp(wxCommandEvent& event); void OnClear(wxCommandEvent& event); void DisplayValue(double value, wxTextCtrl* textCtrl, wxCheckBox* checkBox=NULL); - void EnableDisableNotInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value); - void EnableDisableNotInUseItems(); + void EnableDisableInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value); + void EnableDisableInUseItems(); bool OKToShow() { return m_bOKToShow; } private: GLOBAL_PREFS prefs; From 27aff32ff1ecb4fea6f8c378da5a4f37c35eea9b Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Sun, 14 Aug 2022 13:43:38 -0700 Subject: [PATCH 18/21] disable feature --- clientgui/DlgAdvPreferences.cpp | 57 ++++++++++++++++++++++++--------- clientgui/DlgAdvPreferences.h | 2 ++ 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 903ebea24ff..b5c4938eaff 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -277,6 +277,27 @@ void CDlgAdvPreferences::DisplayValue(double value, wxTextCtrl* textCtrl, wxChec textCtrl->Enable(); } +void CDlgAdvPreferences::EnableDisableInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value) { + if (doEnable) { + if (! textCtrl->IsEnabled()) { + textCtrl->Enable(); + DisplayValue(value, textCtrl); + } + } else { + textCtrl->Clear(); + textCtrl->Disable(); + } +} + +void CDlgAdvPreferences::EnableDisableInUseItems() { + bool doEnable = !(m_chkProcInUse->IsChecked()); + EnableDisableInUseItem(m_txtProcUseProcessors, doEnable, + defaultPrefs.max_ncpus_pct > 0.0 ? defaultPrefs.max_ncpus_pct : 100.0); + EnableDisableInUseItem(m_txtProcUseCPUTime, doEnable, defaultPrefs.cpu_usage_limit); + m_chkMaxLoad->Enable(doEnable); + EnableDisableInUseItem(m_txtMaxLoad, doEnable && m_chkMaxLoad->IsChecked(), defaultPrefs.suspend_cpu_usage); + EnableDisableInUseItem(m_txtMemoryMaxInUse, doEnable, defaultPrefs.ram_max_used_busy_frac*100.0); +} // read preferences from core client and initialize control values // @@ -452,16 +473,20 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { mask.clear(); // ######### proc usage page - m_txtProcUseProcessors->GetValue().ToDouble(&td); - prefs.max_ncpus_pct = RoundToHundredths(td); - mask.max_ncpus_pct=true; + if (m_txtProcUseProcessors->IsEnabled()) { + m_txtProcUseProcessors->GetValue().ToDouble(&td); + prefs.max_ncpus_pct = RoundToHundredths(td); + mask.max_ncpus_pct=true; + } m_txtProcUseProcessorsNotInUse->GetValue().ToDouble(&td); prefs.niu_max_ncpus_pct = RoundToHundredths(td); mask.niu_max_ncpus_pct=true; - - m_txtProcUseCPUTime->GetValue().ToDouble(&td); - prefs.cpu_usage_limit=RoundToHundredths(td); - mask.cpu_usage_limit=true; + + if (m_txtProcUseCPUTime->IsEnabled()) { + m_txtProcUseCPUTime->GetValue().ToDouble(&td); + prefs.cpu_usage_limit=RoundToHundredths(td); + mask.cpu_usage_limit=true; + } m_txtProcUseCPUTimeNotInUse->GetValue().ToDouble(&td); prefs.niu_cpu_usage_limit = RoundToHundredths(td); mask.niu_cpu_usage_limit = true; @@ -489,7 +514,7 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { } mask.suspend_if_no_recent_input = true; - if (m_chkMaxLoad->IsChecked()) { + if (m_txtMaxLoad->IsEnabled()) { m_txtMaxLoad->GetValue().ToDouble(&td); prefs.suspend_cpu_usage=RoundToHundredths(td); } else { @@ -593,11 +618,13 @@ bool CDlgAdvPreferences::SavePreferencesSettings() { } mask.disk_max_used_pct=true; //Memory - m_txtMemoryMaxInUse->GetValue().ToDouble(&td); - td = RoundToHundredths(td); - td = td / 100.0; - prefs.ram_max_used_busy_frac=td; - mask.ram_max_used_busy_frac=true; + if (m_txtMemoryMaxInUse->IsEnabled()) { + m_txtMemoryMaxInUse->GetValue().ToDouble(&td); + td = RoundToHundredths(td); + td = td / 100.0; + prefs.ram_max_used_busy_frac=td; + mask.ram_max_used_busy_frac=true; + } // m_txtMemoryMaxOnIdle->GetValue().ToDouble(&td); td = RoundToHundredths(td); @@ -677,8 +704,8 @@ void CDlgAdvPreferences::UpdateControlStates() { m_chkGPUProcInUse->Enable(! m_chkProcInUse->IsChecked()); if (m_chkProcInUse->IsChecked()) m_chkGPUProcInUse->SetValue(true); - m_txtMaxLoad->Enable(m_chkMaxLoad->IsChecked()); m_txtMaxLoadNotInUse->Enable(m_chkMaxLoadNotInUse->IsChecked()); + EnableDisableInUseItems(); m_txtNoRecentInput->Enable(m_chkNoRecentInput->IsChecked()); // ######### disk and memory usage page @@ -752,7 +779,7 @@ bool CDlgAdvPreferences::ValidateInput() { } } - if (m_chkMaxLoad->IsChecked()) { + if (m_txtMaxLoad->IsEnabled()) { buffer = m_txtMaxLoad->GetValue(); if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) { ShowErrorMessage(invMsgLimit1_100, m_txtMaxLoad); diff --git a/clientgui/DlgAdvPreferences.h b/clientgui/DlgAdvPreferences.h index 220c6a90a29..365e530f065 100644 --- a/clientgui/DlgAdvPreferences.h +++ b/clientgui/DlgAdvPreferences.h @@ -59,6 +59,8 @@ class CDlgAdvPreferences : public CDlgAdvPreferencesBase { void OnHelp(wxCommandEvent& event); void OnClear(wxCommandEvent& event); void DisplayValue(double value, wxTextCtrl* textCtrl, wxCheckBox* checkBox=NULL); + void EnableDisableInUseItem(wxTextCtrl* textCtrl, bool doEnable, double value); + void EnableDisableInUseItems(); bool OKToShow() { return m_bOKToShow; } private: GLOBAL_PREFS prefs; From 9ee282f2aedd168f03e5d76f775bf628fcee7316 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 1 Sep 2022 15:43:01 -0700 Subject: [PATCH 19/21] web: if not-in-use prefs undefined, use in-use values --- html/inc/prefs.inc | 22 ++++++++++++++++++---- html/user/add_venue.php | 1 + 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/html/inc/prefs.inc b/html/inc/prefs.inc index 66d11f0dd8c..c059b8ee76e 100644 --- a/html/inc/prefs.inc +++ b/html/inc/prefs.inc @@ -105,7 +105,7 @@ $not_in_use_prefs = [ tra("Keep some CPUs free for other applications. Example: 75% means use 6 cores on an 8-core CPU."), "niu_max_ncpus_pct", // xgettext:no-php-format - new NUM_SPEC(tra("% of the CPUs"), 1, 100, 100) + new NUM_SPEC(tra("% of the CPUs"), 1, 100, 0) ), new PREF_NUM( tra("Use at most") ."
Requires BOINC 7.20.3+", @@ -113,13 +113,13 @@ $not_in_use_prefs = [ tra("Suspend/resume computing every few seconds to reduce CPU temperature and energy usage. Example: 75% means compute for 3 seconds, wait for 1 second, and repeat."), "niu_cpu_usage_limit", // xgettext:no-php-format - new NUM_SPEC(tra("% of CPU time"), 1, 100, 100) + new NUM_SPEC(tra("% of CPU time"), 1, 100, 0) ), new PREF_OPT_NUM( tra("Suspend when non-BOINC CPU usage is above")."
Requires BOINC 7.20.3+", tra("Suspend computing when your computer is busy running other programs."), "niu_suspend_cpu_usage", - new NUM_SPEC("%", 0, 100, 25) + new NUM_SPEC("%", 0, 100, 0) ), new PREF_NUM( tra("Use at most"), @@ -422,9 +422,22 @@ function default_prefs_global() { return $p; } -// parse prefs from XML to a struct +// if not-in-use prefs undefined, copy from in-use // +function set_niu_prefs($prefs) { + if (!$prefs->niu_max_ncpus_pct) { + $prefs->niu_max_ncpus_pct = $prefs->max_ncpus_pct; + } + if (!$prefs->niu_cpu_usage_limit) { + $prefs->niu_cpu_usage_limit = $prefs->cpu_usage_limit; + } + if (!$prefs->niu_suspend_cpu_usage) { + $prefs->niu_suspend_cpu_usage = $prefs->suspend_cpu_usage; + } +} +// parse prefs from XML to a struct +// function prefs_parse_global($prefs_xml) { global $parse_result; $parse_result = default_prefs_global(); @@ -433,6 +446,7 @@ function prefs_parse_global($prefs_xml) { xml_set_element_handler($xml_parser, "element_start_global", "element_end_global"); xml_set_character_data_handler($xml_parser, "char_handler"); xml_parse($xml_parser, $prefs_xml, 1); + set_niu_prefs($parse_result); return $parse_result; } diff --git a/html/user/add_venue.php b/html/user/add_venue.php index 65379e1e3df..3a70a6f8686 100644 --- a/html/user/add_venue.php +++ b/html/user/add_venue.php @@ -87,6 +87,7 @@ if ($subset == "global") { $prefs = default_prefs_global(); + set_niu_prefs($prefs); } else { $prefs = default_prefs_project(); } From 28e9114fbab846edef64dad73f6cdc4297d0e635 Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Mon, 5 Sep 2022 00:28:27 -0700 Subject: [PATCH 20/21] client and manager: when parsing NIU prefs, immediately chanee 0 to 100. This eliminates ambiguity between "no limit" and "inherit from in use" --- client/cs_prefs.cpp | 24 +++++++++++------------- clientgui/DlgAdvPreferences.cpp | 2 ++ lib/prefs.cpp | 10 +++++----- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/client/cs_prefs.cpp b/client/cs_prefs.cpp index 82fc9e6ddd7..9ac10c217ee 100644 --- a/client/cs_prefs.cpp +++ b/client/cs_prefs.cpp @@ -711,21 +711,19 @@ void CLIENT_STATE::print_global_prefs() { // not in use // msg_printf(NULL, MSG_INFO, - "- When computer is not in use (defaults: same as in use)" + "- When computer is not in use" ); p = global_prefs.niu_max_ncpus_pct; - if (p) { - int n = (int)((host_info.p_ncpus * p)/100); - msg_printf(NULL, MSG_INFO, - "- max CPUs used: %d", n - ); - } - if (global_prefs.niu_cpu_usage_limit) { - msg_printf(NULL, MSG_INFO, - "- Use at most %.0f%% of the CPU time", - global_prefs.niu_cpu_usage_limit - ); - } + int n = (int)((host_info.p_ncpus * p)/100); + msg_printf(NULL, MSG_INFO, + "- max CPUs used: %d", n + ); + + msg_printf(NULL, MSG_INFO, + "- Use at most %.0f%% of the CPU time", + global_prefs.niu_cpu_usage_limit + ); + if (global_prefs.niu_suspend_cpu_usage > 0) { msg_printf(NULL, MSG_INFO, "- suspend if non-BOINC CPU load exceeds %.0f%%", diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index b5c4938eaff..8e03f9252d6 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -327,12 +327,14 @@ void CDlgAdvPreferences::ReadPreferenceSettings() { // 0 means "no restriction" but we don't use a checkbox here if (prefs.max_ncpus_pct == 0.0) prefs.max_ncpus_pct = 100.0; DisplayValue(prefs.max_ncpus_pct, m_txtProcUseProcessors); + if (prefs.niu_max_ncpus_pct == 0.0) prefs.niu_max_ncpus_pct = 100.0; DisplayValue(prefs.niu_max_ncpus_pct, m_txtProcUseProcessorsNotInUse); // cpu limit // 0 means "no restriction" but we don't use a checkbox here if (prefs.cpu_usage_limit == 0.0) prefs.cpu_usage_limit = 100.0; DisplayValue(prefs.cpu_usage_limit, m_txtProcUseCPUTime); + if (prefs.niu_cpu_usage_limit == 0.0) prefs.niu_cpu_usage_limit = 100.0; DisplayValue(prefs.niu_cpu_usage_limit, m_txtProcUseCPUTimeNotInUse); // on batteries diff --git a/lib/prefs.cpp b/lib/prefs.cpp index ab060cea4a3..6a781e18e19 100644 --- a/lib/prefs.cpp +++ b/lib/prefs.cpp @@ -537,7 +537,7 @@ int GLOBAL_PREFS::parse_override( continue; } if (xp.parse_double("niu_max_ncpus_pct", niu_max_ncpus_pct)) { - if (niu_max_ncpus_pct < 0) niu_max_ncpus_pct = 0; + if (niu_max_ncpus_pct <= 0) niu_max_ncpus_pct = 100; if (niu_max_ncpus_pct > 100) niu_max_ncpus_pct = 100; mask.niu_max_ncpus_pct = true; continue; @@ -604,10 +604,10 @@ int GLOBAL_PREFS::parse_override( continue; } if (xp.parse_double("niu_cpu_usage_limit", dtemp)) { - if (dtemp > 0 && dtemp <= 100) { - niu_cpu_usage_limit = dtemp; - mask.niu_cpu_usage_limit = true; - } + if (dtemp <= 0) dtemp = 100; + if (dtemp > 100) dtemp = 100; + niu_cpu_usage_limit = dtemp; + mask.niu_cpu_usage_limit = true; continue; } if (xp.parse_double("daily_xfer_limit_mb", dtemp)) { From f627b0905bc587483be1e29651433becabebf4ac Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Tue, 6 Sep 2022 05:15:49 -0700 Subject: [PATCH 21/21] Manager: fix handling when disabled items are enabled - replace code lost from commit 27aff32ff1 - restore previous values from global_prefs.xml or global_prefs_override.xml --- clientgui/DlgAdvPreferences.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/clientgui/DlgAdvPreferences.cpp b/clientgui/DlgAdvPreferences.cpp index 8e03f9252d6..6f09b317a38 100644 --- a/clientgui/DlgAdvPreferences.cpp +++ b/clientgui/DlgAdvPreferences.cpp @@ -292,11 +292,11 @@ void CDlgAdvPreferences::EnableDisableInUseItem(wxTextCtrl* textCtrl, bool doEna void CDlgAdvPreferences::EnableDisableInUseItems() { bool doEnable = !(m_chkProcInUse->IsChecked()); EnableDisableInUseItem(m_txtProcUseProcessors, doEnable, - defaultPrefs.max_ncpus_pct > 0.0 ? defaultPrefs.max_ncpus_pct : 100.0); - EnableDisableInUseItem(m_txtProcUseCPUTime, doEnable, defaultPrefs.cpu_usage_limit); + prefs.max_ncpus_pct > 0.0 ? prefs.max_ncpus_pct : 100.0); + EnableDisableInUseItem(m_txtProcUseCPUTime, doEnable, prefs.cpu_usage_limit); m_chkMaxLoad->Enable(doEnable); - EnableDisableInUseItem(m_txtMaxLoad, doEnable && m_chkMaxLoad->IsChecked(), defaultPrefs.suspend_cpu_usage); - EnableDisableInUseItem(m_txtMemoryMaxInUse, doEnable, defaultPrefs.ram_max_used_busy_frac*100.0); + EnableDisableInUseItem(m_txtMaxLoad, doEnable && m_chkMaxLoad->IsChecked(), prefs.suspend_cpu_usage); + EnableDisableInUseItem(m_txtMemoryMaxInUse, doEnable, prefs.ram_max_used_busy_frac*100.0); } // read preferences from core client and initialize control values @@ -748,10 +748,12 @@ bool CDlgAdvPreferences::ValidateInput() { double startTime, endTime; // ######### proc usage page - buffer = m_txtProcUseProcessors->GetValue(); - if(!IsValidFloatValueBetween(buffer, 0.0, 100.0)) { - ShowErrorMessage(invMsgLimit100, m_txtProcUseProcessors); - return false; + if (m_txtProcUseProcessors->IsEnabled()) { + buffer = m_txtProcUseProcessors->GetValue(); + if(!IsValidFloatValueBetween(buffer, 0.0, 100.0)) { + ShowErrorMessage(invMsgLimit100, m_txtProcUseProcessors); + return false; + } } buffer = m_txtProcUseProcessorsNotInUse->GetValue(); if(!IsValidFloatValueBetween(buffer, 0.0, 100.0)) { @@ -879,10 +881,12 @@ bool CDlgAdvPreferences::ValidateInput() { } } - buffer = m_txtMemoryMaxInUse->GetValue(); - if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) { - ShowErrorMessage(invMsgLimit1_100, m_txtMemoryMaxInUse); - return false; + if(m_txtMemoryMaxInUse->IsEnabled()) { + buffer = m_txtMemoryMaxInUse->GetValue(); + if(!IsValidFloatValueBetween(buffer, 1.0, 100.0)) { + ShowErrorMessage(invMsgLimit1_100, m_txtMemoryMaxInUse); + return false; + } } buffer = m_txtMemoryMaxOnIdle->GetValue();