forked from davidpanderson/science_united
-
Notifications
You must be signed in to change notification settings - Fork 0
/
su_compute_prefs.inc
107 lines (100 loc) · 3.91 KB
/
su_compute_prefs.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2017 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
// return XML for default prefs w/ given setting
//
// called when we're about to set or modify the prefs in the DB
//
function compute_prefs_xml($preset) {
$now = time();
return "<global_preferences>
<mod_time>$now</mod_time>
<preset>$preset</preset>
</global_preferences>
";
}
define('PREFS_MAX',
"<max_ncpus_pct>100</max_ncpus_pct>
<cpu_usage_limit>100</cpu_usage_limit>
<run_on_batteries>0</run_on_batteries>
<run_if_user_active>1</run_if_user_active>
<run_gpu_if_user_active>1</run_gpu_if_user_active>
<idle_time_to_run>3</idle_time_to_run>
<suspend_if_no_recent_input>0</suspend_if_no_recent_input>
<work_buf_min_days>0.1</work_buf_min_days>
<work_buf_additional_days>0.5</work_buf_additional_days>
<cpu_scheduling_period_minutes>60</cpu_scheduling_period_minutes>
<disk_interval>180</disk_interval>
<disk_max_used_gb>0</disk_max_used_gb>
<disk_min_free_gb>1</disk_min_free_gb>
<disk_max_used_pct>90</disk_max_used_pct>
<ram_max_used_busy_pct>70</ram_max_used_busy_pct>
<ram_max_used_idle_pct>90</ram_max_used_idle_pct>
<leave_apps_in_memory>1</leave_apps_in_memory>
<vm_max_used_pct>75</vm_max_used_pct>
");
define('PREFS_STANDARD',
"<max_ncpus_pct>50</max_ncpus_pct>
<cpu_usage_limit>100</cpu_usage_limit>
<run_on_batteries>0</run_on_batteries>
<run_if_user_active>1</run_if_user_active>
<run_gpu_if_user_active>0</run_gpu_if_user_active>
<idle_time_to_run>3</idle_time_to_run>
<suspend_if_no_recent_input>0</suspend_if_no_recent_input>
<suspend_cpu_usage>25</suspend_cpu_usage>
<work_buf_min_days>0.1</work_buf_min_days>
<work_buf_additional_days>0.5</work_buf_additional_days>
<cpu_scheduling_period_minutes>60</cpu_scheduling_period_minutes>
<disk_interval>180</disk_interval>
<disk_max_used_gb>0</disk_max_used_gb>
<disk_min_free_gb>1</disk_min_free_gb>
<disk_max_used_pct>90</disk_max_used_pct>
<ram_max_used_busy_pct>50</ram_max_used_busy_pct>
<ram_max_used_idle_pct>90</ram_max_used_idle_pct>
<leave_apps_in_memory>1</leave_apps_in_memory>
<vm_max_used_pct>75</vm_max_used_pct>
");
define('PREFS_LOW_POWER',
"<max_ncpus_pct>25</max_ncpus_pct>
<cpu_usage_limit>100</cpu_usage_limit>
<run_on_batteries>0</run_on_batteries>
<run_if_user_active>1</run_if_user_active>
<run_gpu_if_user_active>0</run_gpu_if_user_active>
<idle_time_to_run>3</idle_time_to_run>
<suspend_if_no_recent_input>10</suspend_if_no_recent_input>
<suspend_cpu_usage>25</suspend_cpu_usage>
<work_buf_min_days>0.1</work_buf_min_days>
<work_buf_additional_days>0.5</work_buf_additional_days>
<cpu_scheduling_period_minutes>60</cpu_scheduling_period_minutes>
<disk_interval>180</disk_interval>
<disk_max_used_gb>0</disk_max_used_gb>
<disk_min_free_gb>1</disk_min_free_gb>
<disk_max_used_pct>90</disk_max_used_pct>
<ram_max_used_busy_pct>50</ram_max_used_busy_pct>
<ram_max_used_idle_pct>90</ram_max_used_idle_pct>
<leave_apps_in_memory>1</leave_apps_in_memory>
<vm_max_used_pct>75</vm_max_used_pct>
");
// expand the presets in a set of prefs
//
function expand_compute_prefs($prefs) {
$prefs = str_replace("<preset>standard</preset>", PREFS_STANDARD, $prefs);
$prefs = str_replace("<preset>low_power</preset>", PREFS_LOW_POWER, $prefs);
$prefs = str_replace("<preset>max</preset>", PREFS_MAX, $prefs);
return $prefs;
}
?>