-
Notifications
You must be signed in to change notification settings - Fork 448
Prefs2
This document describes a new system for "computing preferences" in BOINC. This system lets users express, as a set of logical rules, how resource usage settings vary as a function of external factors.
Note: the motivation for this is discussed here; that document is otherwise deprecated.
The goals of this system include:
- Generality: allow the expression of any preferences.
- Extensibility: make it possible to add new external factors (such as the current cost of electricity) without modifying the client.
Various "settings" control and limit BOINC's use of computing, memory, storage, and network communication.
"Dynamic" settings can change in response to factors external to BOINC (such as time of day, non-BOINC CPU usage, etc.). These include:
CPU throttling fraction (0..1)
don't run any jobs
don't run GPU jobs. Optional GPU type (nvidia, amd, intel) and device #.
don't do file xfers
don't do any network communication at all
max download data rate
max upload data rate
max # of CPUs to use
max % of CPUs to use
max fraction of RAM to use
"Static" settings don't vary over time. These include:
ask before creating network connection
time between rescheduling jobs
max disk usage
max % of disk to use
min free disk space
don't verify image files
hang up modem connection when done
suspend (rather than quit) non-running jobs
when request work, ask for this much beyond min
keep at least this much work
The XML representation of setting groups:
<settings>
[ <max_ncpus_pct>x</max_ncpus_pct> ]
...
</settings>
<static_settings>
[ <disk_max_used_gb>x</disk_max_used_gb> ]
...
</static_settings>
All elements are optional; a group can define some elements but not others. If A and B are setting groups, the "overlay of A on B" is defined as A together with any elements in B that are not defined in A.
External factors are stored in a "prefs dictionary", which is a name -> value map. The following entries are maintained by the BOINC client:
time of day
system is running on batteries
whether a given application is running
fraction of CPU used for non-BOINC apps recently
number of MB of file transfer in last N days
system is running on AC power (Android)
system is running on USB power (Android)
WiFi network connection exists (Android)
system thinks user is active (Android)
battery charge level, 0..100 (Android)
battery temperature, Centigrade (Android)
In addition, external programs can add items to the dictionary, and update their values, via GUI RPCs. Hence the prefs system is extensible without modifying the client.
Values are doubles; Booleans are encoded as 0/1.
Preferences are expressed in terms of "conditions" that are the conjunction of a set of "terms".
Each term is an assertion about a dictionary item. There are three types of assertions:
- "greater than": the value of the item is greater than a number X.
- "nonzero": the value of the item is nonzero (i.e. Boolean true)
- "time range": the value of the item (usually "time") lies in a set of day/week intervals.
- "app_running": an app of the given name is running
A term can also have a "not" flag, which if set reverses its sense.
The XML representation of a term:
<term>
<item>item-name</item>
<type>x</type> // greater_than, nonzero, time_range, app_running
[<thresh>x</thresh>] // if greater than
[<time_range>...</time_range>] // if time range
</term>
The representation of a time range:
<time_range>
<start>x</start>
<end>y</end>
[
<day_of_week>
<day>x</day> // 0 .. 6
<start>x</start>
<end>y</end>
</day_of_week>
... other days of week
]
</time_range>
x and y are hours (0..24). The first start/end apply to all days. This is overwritten by day_of_week elements.
A "condition" is the conjunction ("and") of a set of terms, possibly negated. XML format:
<condition>
[<not/>]
<term> ... </term>
...
</condition>
The conjunction of an empty set of terms is true.
A "clause" is the combination of a condition and a dynamic setting group. XML format:
<clause>
<condition> ... </condition>
<settings> ... </settings>
<clause>
A "preference set" is a list of clauses. XML format:
<computing_prefs>
<clause> ... </clause>
...
<static_settings> ... <static_settings>
</computing_prefs>
The semantics are as follows. X is a dynamic setting group, initially empty. The clauses are processed in order. For each clause C, evaluate its condition. If the condition is true, overlay X with C's dynamic settings. At the conclusion, X is the dynamic settings to be enforced by the client.
The following says to use all the CPUs and 90% of the RAM if there has been no user input in 3 minutes, and to use 50% of the CPUs and 50% of the RAM otherwise:
<computing_prefs>
<clause>
<settings>
<max_ncpus_pct>50</max_ncpus_pct>
<ram_max_used_frac>.5</ram_max_used_frac>
</settings>
</clause>
<clause>
<condition>
<term>
<type>greater_than</type>
<item>idle_time</time>
<value>180</value>
</term>
</condition>
<settings>
<max_ncpus_pct>100</max_ncpus_pct>
<ram_max_used_frac>.9</ram_max_used_frac>
</settings>
</clause>
</computing_prefs>