Commit 4e09b79657562f025a16ca78355295582cfd41a8
1 parent
390e2adc
Trimming examples.
Showing
2 changed files
with
72 additions
and
140 deletions
related.tex
| @@ -16,27 +16,22 @@ separation of cross-cutting concerns in software. The programmer can express | @@ -16,27 +16,22 @@ separation of cross-cutting concerns in software. The programmer can express | ||
| 16 | cross cutting concerns in stand alone modules, or aspects. Aspects are | 16 | cross cutting concerns in stand alone modules, or aspects. Aspects are |
| 17 | composed of advice, which specifies a computation to be performed as well as | 17 | composed of advice, which specifies a computation to be performed as well as |
| 18 | points in the program at which that computation should be performed. | 18 | points in the program at which that computation should be performed. |
| 19 | -Aspects are integrated into a program through a weaving step that integrates | ||
| 20 | -the aspects into the codebase. Support for dynamic weaving~\cite{weaving} is | ||
| 21 | -also available. | ||
| 22 | - | ||
| 23 | Abstractly, aspects provide an interesting framework on top of which we could | 19 | Abstractly, aspects provide an interesting framework on top of which we could |
| 24 | realize \texttt{maybe} blocks. At runtime, different aspects could be weaved | 20 | realize \texttt{maybe} blocks. At runtime, different aspects could be weaved |
| 25 | depending on the framework decisions. Aspects would also allow ``chained'' | 21 | depending on the framework decisions. Aspects would also allow ``chained'' |
| 26 | \texttt{maybe} blocks through the use of multiple join points and point-cuts. | 22 | \texttt{maybe} blocks through the use of multiple join points and point-cuts. |
| 27 | -Unfortunately, dynamic weaving and unweaving can be expensive, requiring the | ||
| 28 | -use of a JIT. Fundamentally, however, the goals of AOP and the \texttt{maybe} | ||
| 29 | -statement differ, with AOP focusing on modularity and \texttt{maybe} focused | ||
| 30 | -on increasing runtime flexibility in the face of uncertainty. | 23 | +Fundamentally, however, the goals of AOP and the \texttt{maybe} statement |
| 24 | +differ, with AOP focusing on modularity and \texttt{maybe} focused on | ||
| 25 | +increasing runtime flexibility in the face of uncertainty. | ||
| 31 | 26 | ||
| 32 | \texttt{maybe} shares similaries with language-based approaches to managing | 27 | \texttt{maybe} shares similaries with language-based approaches to managing |
| 33 | energy consumption in wireless sensor networks such as | 28 | energy consumption in wireless sensor networks such as |
| 34 | Eon~\cite{sensys07-eon} and Levels~\cite{sensys07-levels}. However, these | 29 | Eon~\cite{sensys07-eon} and Levels~\cite{sensys07-levels}. However, these |
| 35 | approaches still require programmers to express certainty by associating code | 30 | approaches still require programmers to express certainty by associating code |
| 36 | -with particular energy states, rather than allowing the runtime system to | ||
| 37 | -determine which energy states are appropriate as the \texttt{maybe} system | ||
| 38 | -would be able to do. \texttt{maybe} can also enable adaptation driven by | ||
| 39 | -goals other than energy management. | 31 | +with particular energy states, rather than allowing the system to determine |
| 32 | +which energy states are appropriate as the \texttt{maybe} system would do. | ||
| 33 | +\texttt{maybe} can also enable adaptation driven by goals other than energy | ||
| 34 | +management. | ||
| 40 | 35 | ||
| 41 | Enabling more adaptive mobile systems is a challenge with a long history dating | 36 | Enabling more adaptive mobile systems is a challenge with a long history dating |
| 42 | back to work on systems such as Odyssey~\cite{odyssey-sosp97}. However, a | 37 | back to work on systems such as Odyssey~\cite{odyssey-sosp97}. However, a |
usage.tex
| @@ -2,158 +2,95 @@ | @@ -2,158 +2,95 @@ | ||
| 2 | \label{sec-usage} | 2 | \label{sec-usage} |
| 3 | 3 | ||
| 4 | The \texttt{maybe} system is inspired by our frustrations building smartphone | 4 | The \texttt{maybe} system is inspired by our frustrations building smartphone |
| 5 | -apps and confronting the uncertainties of mobile systems programming. In this | ||
| 6 | -section we describe several ways to use the \texttt{maybe} system drawn from | ||
| 7 | -our own experiences, including for a smartphone service, a smartphone app, an | ||
| 8 | -M2M app utilizing smartphones, and within the Android platform itself. | 5 | +apps that confront the uncertainties inherent to mobile systems programming. |
| 6 | +In this section we describe several examples of how to use the \texttt{maybe} | ||
| 7 | +statement drawn from our own experiences. | ||
| 9 | 8 | ||
| 10 | \subsection{PocketParker App} | 9 | \subsection{PocketParker App} |
| 11 | 10 | ||
| 12 | -\begin{comment} | ||
| 13 | - | ||
| 14 | -\begin{figure}[t] | ||
| 15 | - \begin{minted}[fontsize=\footnotesize]{java} | ||
| 16 | -string detectParkingEvent() { | ||
| 17 | - maybe { | ||
| 18 | - // Use app-specific algorithm | ||
| 19 | - } or { | ||
| 20 | - // Use Google Play services | ||
| 21 | - } | ||
| 22 | -} | ||
| 23 | - \end{minted} | ||
| 24 | - | ||
| 25 | - \vspace*{-0.2in} | ||
| 26 | - \caption{\textbf{Activity recognition using \texttt{maybe}.} \texttt{maybe} | ||
| 27 | - expresses the uncertainty of whether to use our customized app-specific | ||
| 28 | -parking detection algorithm or rely on the Google Play services framework | ||
| 29 | -activity recognition.} | ||
| 30 | - | ||
| 31 | - \label{fig-activityrecognition} | ||
| 32 | - \vspace*{-0.1in} | ||
| 33 | -\end{figure} | ||
| 34 | - | ||
| 35 | -\end{comment} | ||
| 36 | - | ||
| 37 | -PocketParker~\cite{ubicomp14-pocketparker} estimates the availability of | ||
| 38 | -parking spaces in parking lots. It does this by automatically detecting users | ||
| 39 | -of the app parking in, and departing from parking lots. To | ||
| 40 | -detect these events without the need for explicit user input, we used the | ||
| 41 | -accelerometer of the user's smartphone to detect whether a user is driving or | ||
| 42 | -walking. Based on the detected activity and past histories, we could infer | ||
| 43 | -whether a user had parked her car or departed. We needed to do this in | ||
| 44 | -an energy efficient way so that the battery on the user's phone would not | ||
| 45 | -drain because of our app. We developed a custom activity recognition | ||
| 46 | -algorithm to determine the user's activity from the accelerometer values | ||
| 47 | -sampled during the last time interval. In order to reduce battery | ||
| 48 | -consumption, we duty cycled the sampling of the accelerometer. | ||
| 49 | - | ||
| 50 | -Towards the end of our development, Google released their own activity | ||
| 51 | -recognition API as a part of their Google Play Services framework. We had to | ||
| 52 | -conduct several small-scale tests to determine the better of the two | ||
| 53 | -algorithms in terms of energy consumption and accuracy. There was no clear | ||
| 54 | -winner between the two and we decided to use the Google's API as it was a third | ||
| 55 | -party library with an actively maintained codebase. | ||
| 56 | -Supporting both algorithms, switching between them at runtime, and assessing | ||
| 57 | -the resulting impact would have required a significant development effort. | 11 | +PocketParker~\cite{ubicomp14-pocketparker} estimates parking lot availability |
| 12 | +by using the smartphone's accelerometer to detect users entering and leaving | ||
| 13 | +parking spots. To do this is an energy-efficient manner, we initially | ||
| 14 | +developed a custom activity recognition algorithm that duty-cycled the | ||
| 15 | +accelerometer to conserve energy. Towards the end of our development, Google | ||
| 16 | +released their own activity recognition API as a part of their Google Play | ||
| 17 | +Services framework. Based on several small-scale tests there was no clear | ||
| 18 | +winner when comparing the two algorithms, and so we decided to use Google's | ||
| 19 | +implementation to offload the maintenance burden. Supporting both algorithms, | ||
| 20 | +switching between them at runtime, and assessing the resulting impact on a | ||
| 21 | +larger user population would have required a significant amount of | ||
| 22 | +development effort. | ||
| 58 | 23 | ||
| 59 | Such runtime decisions fit naturally into the \texttt{maybe} framework. | 24 | Such runtime decisions fit naturally into the \texttt{maybe} framework. |
| 60 | -Instead of having to choose based on small-scale local testing, the \texttt{maybe} | ||
| 61 | -system can gradually transition an application's users from mature, but | ||
| 62 | -inexpensive to maintain application logic to a potentially immature system-wide | ||
| 63 | -library implementation. As the library implementation matures and improves, the | ||
| 64 | -\texttt{maybe} system can conduct repeated testing and | ||
| 65 | -move more users over to the third-party implementation. For some | ||
| 66 | -users and on some devices, the third-party implementation may never | ||
| 67 | -outperform the app-specific algorithm, in which cases both alternatives can | ||
| 68 | -coexist safely. | 25 | +Instead of having to choose based on small-scale local testing, the |
| 26 | +\texttt{maybe} system can manage the transition from a mature but | ||
| 27 | +app-specific and expensive to maintain algorithm to a potentially-immature | ||
| 28 | +but canonical library implementation. As the library implementation improves | ||
| 29 | +and begins to out-perform the hand-tuned alternative, the \texttt{maybe} | ||
| 30 | +system can conduct repeated testing and move more users over to the library | ||
| 31 | +implementation. For some users or on some devices, the library implementation | ||
| 32 | +may never outperform the app-specific algorithm, in which cases | ||
| 33 | +\texttt{maybe} allows both alternatives to coexist safely while ensuring that | ||
| 34 | +each user enjoys whichever approach is most effective for them. | ||
| 69 | 35 | ||
| 70 | \subsection{\texttt{\large PhoneLab} Conductor} | 36 | \subsection{\texttt{\large PhoneLab} Conductor} |
| 71 | 37 | ||
| 72 | -\begin{comment} | ||
| 73 | - | ||
| 74 | -\begin{figure}[t] | ||
| 75 | - \begin{minted}[fontsize=\footnotesize]{java} | ||
| 76 | -maybe { | ||
| 77 | - // policy A | ||
| 78 | -} or { | ||
| 79 | - // policy B | ||
| 80 | -} or { | ||
| 81 | - // policy C | ||
| 82 | -} better { | ||
| 83 | - if (lostLogLines > 0) { | ||
| 84 | - return Integer.MAX_VALUE; | ||
| 85 | - } else { | ||
| 86 | - return w1*bytesOverCellular + w2*energy; | ||
| 87 | - } | ||
| 88 | -} | ||
| 89 | - \end{minted} | ||
| 90 | - | ||
| 91 | - \caption{\textbf{\PhoneLab{} Conductor Upload Logic Using \texttt{maybe}.}} | ||
| 92 | - | ||
| 93 | - \label{fig-upload} | ||
| 94 | -\end{figure} | ||
| 95 | - | ||
| 96 | -\end{comment} | ||
| 97 | - | ||
| 98 | \PhoneLab{} is a large scale smartphone platform testbed at the University at | 38 | \PhoneLab{} is a large scale smartphone platform testbed at the University at |
| 99 | Buffalo~\cite{phonelab-sensemine13,phonelab-url}. We leverage the Android | 39 | Buffalo~\cite{phonelab-sensemine13,phonelab-url}. We leverage the Android |
| 100 | \texttt{logcat} subsystem as a data collection mechanism---experiment apps | 40 | \texttt{logcat} subsystem as a data collection mechanism---experiment apps |
| 101 | write their data into a system-wide log buffer and we collect and upload this | 41 | write their data into a system-wide log buffer and we collect and upload this |
| 102 | data on their behalf. | 42 | data on their behalf. |
| 103 | 43 | ||
| 104 | -We developed an app called \PhoneLab{} Conductor for this purpose. Due to the | ||
| 105 | -uncertainties we faced when developing this tool, we developed a specialized | 44 | +We developed an app called the \PhoneLab{} Conductor for this purpose which |
| 45 | +provides a good example of custom \texttt{maybe} evaluation logic. The goal | ||
| 46 | +of our app is to collect data reliably while minimizing energy consumption, | ||
| 47 | +storage usage, and metered data usage. With the \texttt{maybe} statement | ||
| 48 | +branching between multiple policies for uploading data---such as always | ||
| 49 | +waiting until the user reaches a plug, or always initiating an upload once | ||
| 50 | +the storage allocated is 50\% full---the evaluation logic would provide the | ||
| 51 | +lowest possible score if data had been lost, or otherwise a score combining | ||
| 52 | +the multiple attributes the app is trying to minimize. | ||
| 53 | + | ||
| 54 | +Due to the uncertainties we faced during development, we implemented a | ||
| 106 | configuration interface that periodically retrieves parameters from our | 55 | configuration interface that periodically retrieves parameters from our |
| 107 | -servers and uses them to reconfigure variable components of the app. This | ||
| 108 | -allows us to control aspects of program behavior such as the amount of storage | ||
| 109 | -space we use on each device for log buffers, how often we check for updates, | 56 | +server and uses them to reconfigure variable components of the app. This |
| 57 | +allows us to control aspects of program behavior such as the amount of | ||
| 58 | +storage space we use on each device for logs, how often we check for updates, | ||
| 110 | and how to decide whether to upload data. Several of these features have | 59 | and how to decide whether to upload data. Several of these features have |
| 111 | proven essential after deployment---for example, when an upload policy that | 60 | proven essential after deployment---for example, when an upload policy that |
| 112 | -worked on an earlier version of Android abruptly stopped working on a newer | ||
| 113 | -version. Development of this app would have been considerably easier using | ||
| 114 | -\texttt{maybe}, which could automate the process of pushing policies to clients | ||
| 115 | -in an energy-efficient way, and enable much more fine-grained and goal-driven adaptation than we are currently performing. | ||
| 116 | - | ||
| 117 | -The \PhoneLab{} Conductor also provides a good example of custom | ||
| 118 | -\texttt{maybe} evaluation logic. The primary goal of our app is to collect | ||
| 119 | -data reliably while minimizing energy consumption, storage usage, and metered | ||
| 120 | -data usage. With the \texttt{maybe} statement branching between multiple | ||
| 121 | -policies for uploading data---such as always waiting until the user reaches a | ||
| 122 | -plug, or always initiating an upload once the storage allocated is 50\% | ||
| 123 | -full---the evaluation logic would provide the lowest possible score if data | ||
| 124 | -had been lost, or otherwise a score combining the multiple attributes the app is | ||
| 125 | -trying to minimize. | 61 | +worked previously abruptly stopped working on a newer Androiod version. |
| 62 | +Development of this app would have been considerably easier using | ||
| 63 | +\texttt{maybe}, which could automate the process of pushing policies to | ||
| 64 | +clients in an energy-efficient way, and enable per-user goal-driven | ||
| 65 | +adaptation. | ||
| 126 | 66 | ||
| 127 | -\subsection{Navjack Sensing Platform} | ||
| 128 | 67 | ||
| 129 | -% 12 Oct 2014 : GWA : Code example here is just too gross. Definitely not | ||
| 130 | -% going to use it. | 68 | +\subsection{Navjack Sensing Platform} |
| 131 | 69 | ||
| 132 | The Navjack project is exploring hijacking in-car navigation devices built | 70 | The Navjack project is exploring hijacking in-car navigation devices built |
| 133 | from repurposed smartphones~\cite{sustain-hotmobile14} and deployed in | 71 | from repurposed smartphones~\cite{sustain-hotmobile14} and deployed in |
| 134 | personal vehicles to enable city-scale sensing. Volunteers install a device | 72 | personal vehicles to enable city-scale sensing. Volunteers install a device |
| 135 | that acts as a dedicated navigational aid and car performance monitor but | 73 | that acts as a dedicated navigational aid and car performance monitor but |
| 136 | -also senses data both while the car is moving and stationary, utilizing the | ||
| 137 | -car's battery for power, the car's driver for maintenance, and new | ||
| 138 | -inexpensive machine-to-machine (M2M) data plans offered by cellular carriers | ||
| 139 | -for telemetry. | ||
| 140 | - | ||
| 141 | -Navjack's goal is to produce high-quality data in response to queries without | ||
| 142 | -draining the car's battery, while consuming as little cellular data as | ||
| 143 | -possible. Many uncertainties specific to this app complicate the process. | ||
| 144 | -Some car cigarette lighters and USB charging docks provide power while the | ||
| 145 | -vehicle is off, while some do not. Users drive their vehicles for different | ||
| 146 | -durations and at different frequencies. Furthermore, cellular coverage varies, | ||
| 147 | -altering the energy-per-bit required to offload data. All of these factors | ||
| 148 | -complicate post-deployment adaptation. | ||
| 149 | - | ||
| 150 | -\texttt{maybe} statements in Navjack can be used to control the rate at which | ||
| 151 | -data is sampled, the set of sensors that are used, and the conditions under | ||
| 152 | -which uploads are attempted. This app provides an example of an adaptation | ||
| 153 | -state space that can potentially get quite large, and so it may provide a | ||
| 154 | -good chance to evaluate our ability to perform pre-deployment simulations to | ||
| 155 | -reduce the state space and success of post-deployment clustering techniques | ||
| 156 | -to identify differences between users that impact app alternative choices. | 74 | +also continuously collects sensor data, utilizing the car's battery for |
| 75 | +power, the car's driver for maintenance, and inexpensive machine-to-machine | ||
| 76 | +(M2M) data plans for telemetry. | ||
| 77 | + | ||
| 78 | +Navjack's goal is to produce high-quality data in response to queries while | ||
| 79 | +minimizing cellular data usage and car battery energy consumption. Many | ||
| 80 | +uncertainties specific to this app complicate the process. Some car cigarette | ||
| 81 | +lighters and USB charging docks provide power while the vehicle is off, while | ||
| 82 | +some do not. Users drive their vehicles for different durations and at | ||
| 83 | +different frequencies. Cellular coverage varies, altering the energy-per-bit | ||
| 84 | +required to offload data. All of these factors complicate post-deployment | ||
| 85 | +adaptation. | ||
| 86 | + | ||
| 87 | +\texttt{maybe} statements in Navjack can be used to control the sampling | ||
| 88 | +rate, the set of sensors that are used, and the conditions under which | ||
| 89 | +uploads are attempted. This app provides an example of an adaptation state | ||
| 90 | +space that can potentially get quite large, and so it may provide a good | ||
| 91 | +chance to evaluate both our ability to perform pre-deployment simulations to | ||
| 92 | +reduce the state space and the success of post-deployment clustering | ||
| 93 | +techniques to identify salient user differences. | ||
| 157 | 94 | ||
| 158 | \subsection{Android Platform Services} | 95 | \subsection{Android Platform Services} |
| 159 | 96 |