Commit 08f18b2b0876fb0aa67e044ffb34a5006ec6a242

Authored by Geoffrey Challen
1 parent 1eccab3a

Rewrite key graf.

Showing 2 changed files with 37 additions and 46 deletions
introduction.tex
@@ -85,27 +85,29 @@ maybe { @@ -85,27 +85,29 @@ maybe {
85 } 85 }
86 \end{minted} 86 \end{minted}
87 87
88 -\vspace*{-0.2in} 88 +\vspace*{-0.1in}
89 89
90 -\caption{\textbf{Example \texttt{maybe} Statement}} 90 +\caption{\textbf{Example \texttt{maybe} Statement.} The programmer provides
  91 +multiple equivalent alternatives.}
91 \label{fig-example-maybe} 92 \label{fig-example-maybe}
92 93
93 -\vspace*{-0.2in} 94 +\vspace*{-0.1in}
94 95
95 \end{figure} 96 \end{figure}
96 97
97 In this paper, we present a novel a language construct for expressing 98 In this paper, we present a novel a language construct for expressing
98 -structured uncertainty: the \texttt{maybe} statement. \texttt{maybe}  
99 -statements allow programmers to express sets of equivalent alternatives for  
100 -both data and control-flow. Figure~\ref{fig-example-maybe} shows a simple  
101 -case of a \texttt{maybe} case statement applied to our earlier example.  
102 -Instead of being forced to choose, being forced to attempt to implement the  
103 -decision process, or even required to evaluate multiple alternatives, the  
104 -programmer is free to offer two or more alternatives that are different but  
105 -both correct, although one may be preferable. At runtime only one will be  
106 -used during any given execution, with the system both determining the energy  
107 -tradeoffs produced by multiple alternatives and activating energy-saving  
108 -alternatives when appropriate. 99 +structured uncertainty: the \texttt{maybe} statement. \texttt{maybe} allows
  100 +the programmer to express and structure their uncertainty by providing two or
  101 +more different \textit{alternatives} which together implement multiple
  102 +approaches to runtime adaptation, possibly by making the same
  103 +energy-performance or energy-accuracy tradeoffs described previously.
  104 +Figure~\ref{fig-example-maybe} shows how our earlier example can be easily
  105 +rewritten to use a \texttt{maybe} statement. However, unlike the previous
  106 +example \texttt{maybe} does rely on the developer to implement a decision
  107 +process or correctly anticipate the effects of each alternative. Instead, the
  108 +\texttt{maybe} system makes runtime choices about which alternative to use by
  109 +measuring the tradeoffs produced by each alternative and (in this case)
  110 +activating an energy-saving alternative when appropriate.
109 111
110 How that choice is made is discussed in the remainder of our paper. We begin 112 How that choice is made is discussed in the remainder of our paper. We begin
111 by providing a more complete description of the \texttt{maybe} statement in 113 by providing a more complete description of the \texttt{maybe} statement in
maybe.tex
1 \section{\texttt{\large maybe} Statement Semantics} 1 \section{\texttt{\large maybe} Statement Semantics}
2 \label{sec-maybe} 2 \label{sec-maybe}
3 3
4 -To begin, we provide a brief overview of the semantics of the \texttt{maybe}  
5 -statement, describing how it can express structured uncertainty in variable  
6 -values and runtime execution. We refer to each of the values a \texttt{maybe}  
7 -variable can take or paths a \texttt{maybe} code block can execute as an  
8 -\textit{alternative}. 4 +To begin we provide an overview of the \texttt{maybe} statements semantics,
  5 +describing how it structures uncertainty in variable values and runtime
  6 +execution. We refer to each of the values a \texttt{maybe} variable can take
  7 +or paths a \texttt{maybe} code block can execute as an \textit{alternative}.
9 8
10 \begin{figure}[t] 9 \begin{figure}[t]
11 \begin{minted}[fontsize=\footnotesize]{java} 10 \begin{minted}[fontsize=\footnotesize]{java}
@@ -89,38 +88,30 @@ annotations. @@ -89,38 +88,30 @@ annotations.
89 We will return to post-mortem evaluation 88 We will return to post-mortem evaluation
90 in Section~\ref{sec-certainty}. 89 in Section~\ref{sec-certainty}.
91 90
92 -\subsection{Programming With \texttt{\large maybe}} 91 +\subsection{Discussion}
93 92
94 We have yet to determine how well programmers will be able to use the new 93 We have yet to determine how well programmers will be able to use the new
95 \texttt{maybe} construct. At some level, \texttt{maybe} statements are 94 \texttt{maybe} construct. At some level, \texttt{maybe} statements are
96 -similar to the common \texttt{if-else} construct. At the bottom of the  
97 -statement, the programmer may not be sure which block was executed. Of  
98 -course, with \texttt{if-else} blocks it can be determined which block was  
99 -executed by examining the branch conditions. When working with the  
100 -\texttt{maybe} statement, the developer must set a variable inside each  
101 -\texttt{maybe} block if downstream code depends on which alternative was  
102 -chosen, as in Figure~\ref{fig-maybeexamples}. Alternatively, programmers may  
103 -use a \texttt{maybe} variable to select a policy, and employ the traditional  
104 -\texttt{if-else} construct to direct control flow based on the \texttt{maybe}  
105 -variable.  
106 -  
107 -\subsection{When Not To Use \texttt{\large maybe}}  
108 -% 10/13 by OK:  
109 -% We don't discuss dependencies between maybe statements anywhere else, so I'm  
110 -% killing the ref here. It's still true that we're creating an exponential  
111 -% search space of possibilities; so the same text is getting re-purposed for  
112 -% that. 95 +similar to the common \texttt{if-else} construct in that at the bottom of the
  96 +statement the programmer may not be sure which block was executed. However,
  97 +while with \texttt{if-else} blocks it can be determined which block was
  98 +executed by examining the branch conditions, \texttt{maybe} statements
  99 +require developers record which alternative was used if downstream code
  100 +depends on the decision. Alternatively, programmers may use a \texttt{maybe}
  101 +variable to select a policy and employ traditional \texttt{if-else}
  102 +statements to direct control flow based on the \texttt{maybe} variable.
  103 +
113 While \texttt{maybe} is a powerful programming tool, it is important that it 104 While \texttt{maybe} is a powerful programming tool, it is important that it
114 -be used sparingly. In the case where no dependencies exist between the 105 +be used sparingly. In the case where dependencies exist between the
115 alternatives expressed by separate \texttt{maybe} statements, each 106 alternatives expressed by separate \texttt{maybe} statements, each
116 -\texttt{maybe} expands the overall configuration space exponentially and 107 +\texttt{maybe} may expand the overall configuration space exponentially which
117 makes the resulting process of determining the best alternative much more 108 makes the resulting process of determining the best alternative much more
118 complicated. Compile-time analysis may be required to ensure that downstream 109 complicated. Compile-time analysis may be required to ensure that downstream
119 optimization remains feasible. 110 optimization remains feasible.
120 111
121 The most important guideline for when \textit{not} to use \texttt{maybe} 112 The most important guideline for when \textit{not} to use \texttt{maybe}
122 usage is when a decision is not app-specific, and should instead be 113 usage is when a decision is not app-specific, and should instead be
123 -made by a library or service. As an example, \texttt{maybe} should 114 +refactored into a library or service. As an example, \texttt{maybe} should
124 not be used to decide which networking interface to use to send a packet. 115 not be used to decide which networking interface to use to send a packet.
125 To the degree that 116 To the degree that
126 one app shares the same objectives as others---say, to minimize latency---a 117 one app shares the same objectives as others---say, to minimize latency---a
@@ -128,10 +119,8 @@ service should be performing adaptation on behalf of all apps using the @@ -128,10 +119,8 @@ service should be performing adaptation on behalf of all apps using the
128 merged network interfaces, possibly through the use of its own internal 119 merged network interfaces, possibly through the use of its own internal
129 \texttt{maybe} statements. 120 \texttt{maybe} statements.
130 121
131 -\subsection{Other Approaches to Adaptation}  
132 -  
133 -Note that structured uncertainty is not randomness. The \texttt{maybe}  
134 -statement indicates that during any given execution one alternative may be  
135 -better than the others---even if the developer or system are not sure which  
136 -alternative to use. 122 +Finally, note that structured uncertainty is not randomness. The
  123 +\texttt{maybe} statement indicates that during any given execution one
  124 +alternative may be better than the others---even if the developer or system
  125 +are not sure which alternative to use.
137 126