wiki:Prefs2

Version 1 (modified by davea, 5 years ago) (diff)

--

Computing preferences, version 2

Static and dynamic prefs

"Dynamic" prefs are parameters that limit BOINC activity, and that change in response to various factors. Examples include limits on #CPUs, RAM usage, network usage, etc.

Prefs dictionary

The "prefs dictionary" is a name -> value map, containing values that can affect dynamic prefs. Examples:

  • "idle_time": # seconds since last user input
  • "time": time of day
  • "on_batteries": whether system is running on batteries
  • "exclusive_app_running": whether an exclusive app is running
  • "non_boinc_cpu_usage": fraction of CPU used for non-BOINC apps recently

These values are updated by the client.

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.

Preference terms

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 terms:

  • "greater than": the value of the item is greater than a threshold X.
  • "nonzero": the value of the item is nonzero (i.e. a true Boolean)
  • "time range": the value of the item (a time value) lies in a set of time intervals.

A term can also have a "negate" flag, which if set reverses its sense.

The XML representation of a term is

<prefs_term>
   <item>item-name</item>
   <term_type>x</term_type>     // 0 = greater than, 1 = nonzero, 2 = time range
   [<negate/>]
   [<thresh>x</thresh>]         // if greater than
   [time range]                 // if time range
</prefs_term>

and the representation of a time range is

<time_range>
   <start_hour>x</start_hour>
   <end_hour>y</end_hour>
   [
   <day>
      <day_of_week>x</day_of_week>
      <start_hour>x</start_hour>
      <end_hour>y</end_hour>
   <day>

Conditions

A "condition" is the conjunction ("and") of a set of terms, possibly negated. XML format:

<prefs_condition>
   [<negate/>]
   <prefs_term> ... </pref_term>
   ...
</prefs_condition>

Clauses

A "clause" is the combination of a condition and a set of dynamic prefs. XML format:

<prefs_clause>
   <prefs_condition> ... </prefs_condition>
   <dynamic_settings> ... </dynamic_settings>
<prefs_clause>

Preference sets

A "preference set" is a list of clauses. XML format:

<computing_prefs>
   <prefs_clause> ... </prefs_clause>
   ...
</computing_prefs>

The semantics are as follows. We maintain a set X of dynamic settings, initially empty. the clauses are processed in order. For each clause C, we evaluate its condition. If the condition is true, we overwrite X with C's dynamic settings. At the conclusion, X is the dynamic settings to be enforced.