Commit 48ed927642a671eb510a7deaac9be99f87c82446
1 parent
a880df4c
Working.
Showing
6 changed files
with
64 additions
and
59 deletions
certainty.tex
| ... | ... | @@ -62,18 +62,18 @@ developers to use \texttt{maybe} statements to prototype alternatives to |
| 62 | 62 | existing well-tested code. |
| 63 | 63 | |
| 64 | 64 | A final question concerns when a \texttt{maybe} alternative should be |
| 65 | -assessed. In some cases it may be appropriate for \textit{a posteriori} | |
| 65 | +evaluated. In some cases it may be appropriate for \textit{a posteriori} | |
| 66 | 66 | evaluation to happen immediately after execution. In others, it may be |
| 67 | -necessary to execute the same alternative over a period of time to perform a | |
| 68 | -fair comparison. As described previously, \texttt{evaluate} blocks can | |
| 69 | -indicate explicitly whether or not to continue evaluating the alternative, | |
| 70 | -and we are determining how to make a similar choice available to | |
| 71 | -\texttt{maybe} statements that do not use customized evaluation logic. In | |
| 72 | -addition, \texttt{evaluate} blocks can store state across multiple | |
| 73 | -alternative executions allowing them to evaluate not only micro- but also | |
| 74 | -macro-level decisions. In both cases, however, the \texttt{maybe} system | |
| 75 | -allows developers continuous per-statement control over alternative | |
| 76 | -evaluation and selection as described in more detail later in this section. | |
| 67 | +necessary to continue executing the same alternative over a period of time to | |
| 68 | +perform a fair comparison. As described previously, \texttt{evaluate} blocks | |
| 69 | +can indicate explicitly whether or not to continue evaluating the | |
| 70 | +alternative, and we are determining how to make a similar choice available to | |
| 71 | +\texttt{maybe} statements without \texttt{evaluate} blocks. In addition, | |
| 72 | +\texttt{evaluate} blocks can store state across multiple alternative | |
| 73 | +executions allowing them to evaluate not only micro- but also macro-level | |
| 74 | +decisions. In both cases, however, the \texttt{maybe} system allows | |
| 75 | +developers continuous per-statement control over alternative choice and | |
| 76 | +evaluation as described in more detail later in this section. | |
| 77 | 77 | |
| 78 | 78 | \subsection{\texttt{\large maybe} Alternative Testing} |
| 79 | 79 | |
| ... | ... | @@ -85,42 +85,40 @@ ways for the developer to guide and control any step in the process. |
| 85 | 85 | |
| 86 | 86 | \subsubsection{Runtime control} |
| 87 | 87 | |
| 88 | -To begin, we briefly outline how our Android prototype system implements the | |
| 89 | -\texttt{maybe} construct. We (1) rewrite each \texttt{maybe} code block to an | |
| 88 | +To begin, we briefly outline how our Android prototype implements the | |
| 89 | +\texttt{maybe} statement. We (1) rewrite each \texttt{maybe} code block to an | |
| 90 | 90 | \texttt{if-else} statement controlled by a call into the \texttt{maybe} |
| 91 | 91 | system and (2) generate a similar setter for each \texttt{maybe} variable. |
| 92 | 92 | Variable values and code branches are now all under the control of a separate |
| 93 | 93 | \texttt{maybe} service which can be deployed as a separate app or |
| 94 | -incorporated into the Android platform itself. It is responsible for | |
| 95 | -communicating with the global \texttt{maybe} server to retrieve adaptation | |
| 96 | -parameters for all \texttt{maybe}-enabled apps on the smartphone. When possible, | |
| 97 | -we avoid interprocess communication during each | |
| 98 | -\texttt{maybe} decision by caching decisions in the app. The local | |
| 99 | -\texttt{maybe} service pushes cache invalidation messages when that decision | |
| 100 | -changes. The | |
| 101 | -\texttt{maybe} service tracks when alternatives change, runs both generic and | |
| 102 | -app-specific alternative assessment logic when appropriate, and returns | |
| 103 | -testing results to the \texttt{maybe} server. | |
| 104 | - | |
| 105 | -Because unpredictable changes to variables at runtime could cause crashes or | |
| 106 | -incorrect program behavior, our \texttt{maybe} prototype currently only | |
| 107 | -changes the values of these variables when they are set using a | |
| 108 | -\texttt{maybe} statement. If the app wants to enable periodic readaptation of | |
| 109 | -certain global variables, such as the interval controlling a timer, it can do | |
| 110 | -so by periodically resetting the value using another \texttt{maybe} | |
| 111 | -statement. This ensures that \texttt{maybe} variables only change when the | |
| 112 | -developer expects them to. | |
| 94 | +incorporated into the Android platform. It is responsible for communicating | |
| 95 | +with the global \texttt{maybe} server to retrieve adaptation parameters for | |
| 96 | +all \texttt{maybe}-enabled apps on the smartphone. When possible, we avoid | |
| 97 | +interprocess communication during each \texttt{maybe} decision by caching | |
| 98 | +decisions in the app, with the \texttt{maybe} service delivering cache | |
| 99 | +invalidation messages when particular decisions change. The \texttt{maybe} | |
| 100 | +service tracks when alternative decisions change, runs \texttt{evaluate} | |
| 101 | +evaluation logic when appropriate, and returns testing results to the | |
| 102 | +\texttt{maybe} server. | |
| 103 | + | |
| 104 | +Because unpredictable runtime variable changes could cause crashes or | |
| 105 | +incorrect behavior, our prototype currently only changes variable values when | |
| 106 | +they are set using a \texttt{maybe} statement. If the app wants to enable | |
| 107 | +periodic readaptation of certain global variables, such as the interval | |
| 108 | +controlling a timer, it can do so by periodically resetting the value using | |
| 109 | +another \texttt{maybe} statement. This ensures that \texttt{maybe} variables | |
| 110 | +only change when the developer expects them to. | |
| 113 | 111 | |
| 114 | 112 | \subsubsection{Simulation or emulation} |
| 115 | 113 | |
| 116 | 114 | Pre-deployment simulation or emulation may provide a way to efficiently |
| 117 | -assess \texttt{maybe} blocks without involving users. Building simulation | |
| 115 | +assess \texttt{maybe} statements without involving users. Building simulation | |
| 118 | 116 | environments that accurately reflect all of the uncertainties inherent to |
| 119 | 117 | mobile systems programming, however, is difficult. To complicate matters, |
| 120 | 118 | \texttt{maybe} alternatives may depend on details of user interaction that |
| 121 | -are difficult to know a priori, particularly when new apps and app | |
| 122 | -functionalities are being investigated. So in most cases we believe that | |
| 123 | -post-deployment testing will still be required. | |
| 119 | +are difficult to know \textit{a priori}, particularly when new apps or | |
| 120 | +functionalities are being investigated. So in most cases we believe | |
| 121 | +post-deployment testing will be required. | |
| 124 | 122 | |
| 125 | 123 | However, pre-deployment testing may still be a valuable approach, particularly |
| 126 | 124 | when a large amount of uncertainties are present and a correspondingly-large |
| ... | ... | @@ -147,7 +145,7 @@ which \texttt{maybe} statements should be tested at any given time. |
| 147 | 145 | |
| 148 | 146 | Each time a \texttt{maybe} statement is reached or \texttt{maybe} variable is |
| 149 | 147 | set, the \texttt{maybe} system records: |
| 150 | - | |
| 148 | +% | |
| 151 | 149 | \begin{itemize} |
| 152 | 150 | |
| 153 | 151 | \item what \texttt{maybe} was reached; |
| ... | ... | @@ -165,7 +163,7 @@ and platform information; networking provider and conditions; location; |
| 165 | 163 | battery level; and so on. |
| 166 | 164 | |
| 167 | 165 | \end{itemize} |
| 168 | - | |
| 166 | +% | |
| 169 | 167 | This dataset is periodically uploaded to the \texttt{maybe} server by the |
| 170 | 168 | \texttt{maybe} service and used to drive the adaptation approaches discussed |
| 171 | 169 | next. | ... | ... |
discussion.tex
| ... | ... | @@ -17,7 +17,8 @@ While \texttt{maybe} is a powerful programming tool, it is important that it |
| 17 | 17 | be used sparingly. If objective dependencies exist between \texttt{maybe} |
| 18 | 18 | statements, the overall configuration space may expand exponentially, |
| 19 | 19 | complicating the process of determining the best alternatives described in |
| 20 | -Section~\ref{sec-certainty}. Compile-time analysis may be required to detect | |
| 20 | +Section~\ref{sec-certainty}. (A similar problem exists with nested | |
| 21 | +\texttt{maybe} statements.) Compile-time analysis may be required to detect | |
| 21 | 22 | dependencies between \texttt{maybe} statements and ensure that downstream |
| 22 | 23 | optimization remains feasible. |
| 23 | 24 | ... | ... |
include/start.tex
| ... | ... | @@ -27,8 +27,8 @@ |
| 27 | 27 | |
| 28 | 28 | \usepackage[all]{hypcap} |
| 29 | 29 | |
| 30 | -\setlist[itemize]{leftmargin=*,partopsep=5pt} | |
| 31 | -\setlist[enumerate]{leftmargin=*,partopsep=5pt} | |
| 30 | +\setlist[itemize]{leftmargin=*,topsep=2pt,itemsep=-0.5ex,partopsep=1ex,parsep=1ex} | |
| 31 | +\setlist[enumerate]{leftmargin=*,topsep=2pt,itemsep=-0.5ex,partopsep=1ex,parsep=1ex} | |
| 32 | 32 | |
| 33 | 33 | \paperheight 11in |
| 34 | 34 | \paperwidth 8.5in | ... | ... |
introduction.tex
| ... | ... | @@ -47,15 +47,15 @@ if (plugged == false && batteryLevel < 10) { |
| 47 | 47 | } |
| 48 | 48 | \end{minted} |
| 49 | 49 | |
| 50 | -\vspace*{-0.1in} | |
| 50 | +\vspace*{-0.2in} | |
| 51 | 51 | |
| 52 | -\caption{\textbf{Typical Error-Prone Energy Adaptation.} The threshold is | |
| 53 | -arbitrary and the attempt to conserve energy succeed only at certain times, | |
| 52 | +\caption{\small\textbf{Typical Error-Prone Energy Adaptation.} The threshold is | |
| 53 | +arbitrary and the attempt to conserve energy may succeed only at certain times, | |
| 54 | 54 | only for certain users, only on certain devices, or never.} |
| 55 | 55 | |
| 56 | 56 | \label{fig-example-if} |
| 57 | 57 | |
| 58 | -\vspace*{-0.1in} | |
| 58 | +\vspace*{-0.2in} | |
| 59 | 59 | |
| 60 | 60 | \end{figure} |
| 61 | 61 | |
| ... | ... | @@ -87,7 +87,7 @@ maybe { |
| 87 | 87 | |
| 88 | 88 | \vspace*{-0.1in} |
| 89 | 89 | |
| 90 | -\caption{\textbf{Example \texttt{maybe} Statement.} The programmer provides | |
| 90 | +\caption{\small\textbf{Example \texttt{maybe} Statement.} The programmer provides | |
| 91 | 91 | multiple equivalent alternatives. The system determines how to choose between |
| 92 | 92 | them at runtime.} |
| 93 | 93 | ... | ... |
maybe.tex
| ... | ... | @@ -30,13 +30,13 @@ maybe { |
| 30 | 30 | |
| 31 | 31 | \end{minted} |
| 32 | 32 | |
| 33 | -\vspace*{-0.2in} | |
| 33 | +\vspace*{-0.1in} | |
| 34 | 34 | |
| 35 | -\caption{\textbf{More \texttt{maybe} Statements}} | |
| 35 | +\caption{\small\textbf{More \texttt{maybe} Statements}} | |
| 36 | 36 | |
| 37 | 37 | \label{fig-maybeexamples} |
| 38 | 38 | |
| 39 | -\vspace*{-0.2in} | |
| 39 | +\vspace*{-0.1in} | |
| 40 | 40 | |
| 41 | 41 | \end{figure} |
| 42 | 42 | |
| ... | ... | @@ -67,12 +67,18 @@ statement providing syntactic sugar. \texttt{maybe} function annotations |
| 67 | 67 | allow uncertainty to be expressed at the function level, with the |
| 68 | 68 | alternatives consisting of multiple function definitions with identical |
| 69 | 69 | signatures. Finally, \texttt{maybe} blocks that require custom evaluation |
| 70 | -logic can include an \texttt{evaluate} statement following the main | |
| 71 | -\texttt{maybe} block, as shown in the final example. \texttt{evaluate} blocks | |
| 72 | -provide app-specific \textit{a posteriori} logic to evaluate the selected | |
| 73 | -alternative. The \texttt{evaluate} block must return a single JSON object | |
| 74 | -with two components: (1) a positive integer \texttt{score}, with smaller | |
| 75 | -being better; (2) and a boolean \texttt{repeat} indicating whether the system | |
| 76 | -must use the same alternative next time. Hints and custom evaluation logic | |
| 77 | -can also be applied to other types of \texttt{maybe} statements through | |
| 78 | -annotations. | |
| 70 | +logic can include an \texttt{evaluate} block as shown in the final example. | |
| 71 | +\texttt{evaluate} blocks provide app-specific \textit{a posteriori} logic to | |
| 72 | +evaluate the selected alternative. The \texttt{evaluate} block must return a | |
| 73 | +single JSON object with two components: (1) a positive integer | |
| 74 | +\texttt{score}, with smaller being better; (2) and a boolean \texttt{repeat} | |
| 75 | +indicating whether the system must use the same alternative next time. Hints | |
| 76 | +and custom evaluation logic can also be applied to other types of | |
| 77 | +\texttt{maybe} statements through annotations. | |
| 78 | + | |
| 79 | +While it should be possible to nest \texttt{maybe} statements, it may require | |
| 80 | +compiler support to provide guarantees about how \texttt{maybe} decisions are | |
| 81 | +maintained across multiple code blocks. As we gain more experience with our | |
| 82 | +rewrite-based prototype, described next in Section~\ref{sec-certainty}, we | |
| 83 | +will revisit the question of nesting in future compiler-driven \texttt{maybe} | |
| 84 | +systems. | ... | ... |
paper.tex