Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Mobile Software Development Framework: Adaptive Mobile Applications 10/23/2012 Y. Richard Yang.

Similar presentations


Presentation on theme: "1 Mobile Software Development Framework: Adaptive Mobile Applications 10/23/2012 Y. Richard Yang."— Presentation transcript:

1 1 Mobile Software Development Framework: Adaptive Mobile Applications 10/23/2012 Y. Richard Yang

2 2 Outline r Admin r Mobile cloud services m Push notification service m Track service m Storage service

3 3 Admin. r HW3 r Project ideas

4 Recap: Example Mobile Cloud Services r Push notification service r Location based service, e.g., m Track service (supporting location based services) r Storage services, e.g., m iCloud, Google Drive, Dropbox r Proxy service, e.g., m Kindle Split Browser m Recognition/synthesis services 4

5 Recap: Push Notification Service r A single persistent connection between Push Notification Service (PNS) and Mobile Device r Authorization m App register with PNS m Device app registers with PNS and forwards registration to PNS m App can send only to registrations r Scalability, fault tolerance, generality m Send only notification, does not hold data 5

6 Recap: Track Service  TC JoinTrackCollections (TC tCs[], bool removeDuplicates)  TC SortTracks (TC tC, SortAttribute attr)  TC TakeTracks(TC tC, int count)  TC GetSimilarTracks (TC tC, Track refTrack, float simThreshold)  TC GetPassByTracks (TC tC, Area[] areas)  TC GetCommonSegments(TC tC, float freqThreshold) Manipulation Creation  TC MakeCollection(GroupCriteria criteria, bool removeDuplicates) 6

7 API Usage: Ride-Sharing Application // get user’s most popular track in the morning TC myTC = MakeCollection(“name = Maya”, [0800 1000], true); TC myPopTC = SortTracks(myTC, FREQ); Track track = GetTracks(myPopTC, 0, 1); // find tracks of all fellow employees TC msTC = MakeCollection(“name.Employer = MS”, [0800 1000], true); // pick tracks from the community most similar to user’s popular track TC similarTC = GetSimilarTracks(msTC, track, 0.8); Track[] similarTracks = GetTracks(similarTC, 0, 20); // Verify if each track is frequently traveled by its respective owner User[] result = FindOwnersOfFrequentTracks(similarTracks);

8 Outline r Admin and recap r Mobile Cloud Services m Push notification service m Location based service m Storage service 8

9 Storage/Sync Service r Store content in cloud to be accessible by multiple selected devices r Deployed services, e.g., m iCloud m Google Drive https://developers.google.com/drive/integrate- android-uihttps://developers.google.com/drive/integrate- android-ui m DropBox 9

10 Storage/Sync Service Example: iCloud r Backend m Hosted by Windows Azure and Amazon AWS m Uses HTTPS to send to servers r Client storage models m Key Value Store m UIDocument m Core data r More details: see iCloud sessions m https://developer.apple.com/videos/wwdc/2012/?id =209 10

11 11 Problems Caused by Mobile Storage r Read miss m stalls progress (user has to wait for data) r Synchronization/consistency m user may see outdated data m user modification may generate conflicts

12 12 Approaches r Read miss m explicit user file selection m automatic hoarding/prediction, e.g., CODA, SEER r Synchronization/consistency m keep modification logs and develop merge tools, e.g., Bayou m efficient file comparisons and merging, e.g., rsync, LBFS

13 Amazon Silk Split-Browser r Dynamic split browsing m Intelligently partition work between local and Amazon cloud 13 http://www.extremetech.com/mobile/97587-amazon-silk-bridging-the-gap-between-desktop-and-tablet-web-browsers

14 Outline r Admin and recap r Adaptive mobile applications 14

15 15 Adaptive Mobile App: Bigger Picture device in-net proxy in-net service On-device app/sys adaptation Service partition Device-aware service delivery

16 Outline r Admin and recap r Adaptive mobile applications m Client adaptation 16

17 Example: iphone 5 17 http://www.anandtech.com/show/6324/the-iphone-5-performance-preview

18 18 CPU Power Consumption Model r The power consumption rate P of a CMOS processor satisfies where k is a constant, C the capacitance of the circuit, f the CPU frequency, and V the voltage r When the supply voltage V is lower, charging/discharging time is longer; thus frequency should be lower => P ~ O(V 3 )

19 19 CPU Power Model Discussion: what voltage to operate on? throughput

20 20 Dynamic Voltage Scaling r Basic idea: determining voltage according to program response time requirement r For normal applications, give reasonable response time r For multimedia applications, use the deadline to determine voltage

21 21 Architecture CPU monitoring scheduling speed scaling demand distribution scheduler speed adaptor profiler multimedia applications requirements time constraint

22 22 Demand Prediction  Online profiling and estimation: count number of cycles used by each job b 1 b 2 C min =b 0 b r =C max 1 b r-1 cumulative probability CDF F(x) = P [X  x]

23 23 Observations Demand distribution is stable or changes slowly

24 24 CPU Resource Allocation How many cycles to allocate to a multimedia job? Application should meet  percent of deadlines  each job meets deadline with probability   allocate C cycles, such that F (C ) =P [X  C ]   b 1 b 2 b 0 brbr 1 b r-1 cumulative probability F(x)F(x)  C

25 25 How Fast to Run the CPU?  Assume the strategy is to run job i at a fix (also called uniform) speed S i  Assume it needs C i cycles during a time duration of P i  Fact: since power is a convex function of frequency, if a job needs C cycles in a period P, then the optimal frequency is C/P, namely the lowest constant frequency.

26 26 Why Not Uniform Speed? Intuitively, uniform speed achieves - minimum energy if use the allocated exactly However, jobs use cycles statistically - often complete before using up the allocated - potential to save more energy  stochastic DVS

27 27 Stochastic DVS For each job 1.find speed S x for each allocated cycle x  time is 1/S x and energy is (1 - F(x))S 3 x such that

28 28 Example Speed Schedule 100 MHz200 MHz400 MHz cycle: speed: Job 1 2.5 x10 6 cycles speed (MHz) 100 400 200 Job 2 1.2 x10 6 cycles Observation: speed up the processor with increasing clock cycles

29 29 DVS speed A1 B1 A1 execution speed up within job context switch 1.Store speed for switched-out 2.New speed for switched-in switch back A2

30 30 Implementation Hardware: HP N5470 laptop –Athlon CPU (300, 500, 600, 700, 800, 1000MHz)  round speed schedule to upper bound process control block standard Linux scheduler DVS modules PowerNow speed scaling Soft real-time scheduling system call Extension to Linux kernel 2.4.18 716 lines of C code

31 31 Reduces power consumption However, limited due to few speed options Evaluation: Normalized Energy

32 32 Odyssey: An Example Client Architecture r Application indicates resource capabilities in its request to service r Operating system maintains/monitors available resources m no need to have each application re-implement the monitoring r An application registers a resource descriptor and an upcall event handler with the OS r OS notifies the application upon detecting resource changes r Application adjusts requests to the server

33 33 Client System Model

34 Outline r Admin and recap r Adaptive mobile applications m Client adaptation m Server adaptation 34

35 35 Server/Content Adaptation: Examples Objective: automating adaptation

36 36 Example: Adapting Audio Content r Send a lower resolution stream as the redundant information, e.g. nominal stream at 64 kbps and redundant stream at 13 kbps (such as GSM) 2 3

37 37 Example: Adapting Fidelity of Video/Image Content? r Potentially many dimensions m frame rate (for video) m image size m quality of image r Usage: e.g., data acceleration offered by many carriers

38 38 Frame Encoding: Block Transform Encoding DCT Zig-zag Quantize Run-length Code Huffman Code 011010001011101...

39 39 Discrete Cosine Transform F[u,v] = 4C(u)C(v) n2n2  n-1 j=0 k=0 f(j,k) cos (2j+1)u  2n (2k+1)v  2n cos where C(w) = 1  2 1 for w=0 for w=1,2,…,n-1 DCT is better at reducing redundancy than Discrete Fourier Transform but it is more computationally expensive

40 40 Basis Functions of DCT - An image is a superposition of basis functions - DCT computes the contribution of each basis function - F[u,v]: for the basis function at position [u, v] more detail

41 41 Example: MPEG Block Encoding original image DCT DC component AC components Quantize zigzag run-length and Huffman encoding of the stream 10011011100011... coded bitstream < 10 bits (0.55 bits/pixel) Discussion: how to generate different encoding rates?

42 42 Examples Uncompressed (262 KB) Compressed (22 KB, 12:1) Compressed (6 KB, 43:1)

43 Outline r Admin and recap r Adaptive mobile applications m Client adaptation m Server adaptation m Proxy and job partition 43

44 Example Benefit of Cloud (RTT -> Server) 44

45 Example: MAUI 45 Maui server Smartphone Application Client Proxy Profiler Solver Maui Runtime Server Proxy Profiler Solver Maui Runtime Application RPC Maui Controller

46 How Does a Programmer Use MAUI? r Goal: make it dead-simple to MAUI-ify apps m Build app as a standalone phone app m Add.NET attributes to indicate “remoteable” m Follow a simple set of rules

47 Maui server Smartphone Application Client Proxy Profiler Solver Maui Runtime Server Proxy Profiler Solver Maui Runtime Application RPC Maui Controller Intercepts Application Calls Synchronizes State Chooses local or remote Handles Errors Provides runtime information

48 Profiler Callgraph Execution Time State size Network Latency Network Bandwidth Device Profile CPU Cycles Network Power Cost Network Delay Computational Delay Computational Power Cost Computational Delay Annotated Callgraph

49 B 900 mJ 15ms C 5000 mJ 3000 ms 1000mJ 25000 mJ D 15000 mJ 12000 ms 10000 mJ A Computation energy and delay for execution Energy and delay for state transfer A sample callgraph

50 FindMatch 900 mJ InitializeFace Recognizer 5000 mJ 1000mJ 25000 mJ DetectAndExtract Faces 15000 mJ 10000 mJ User Interface Cheaper to do local

51 FindMatch 900 mJ InitializeFace Recognizer 5000 mJ 1000mJ 25000 mJ DetectAndExtract Faces 15000 mJ 10000 mJ User Interface Cheaper to do local

52 FindMatch InitializeFace Recognizer 1000mJ DetectAndExtract Faces User Interface 20900mJ Cheaper to offload

53 MAUI Implementation r Platform m Windows Mobile 6.5 m.NET Framework 3.5 m HTC Fuze Smartphone m Monsoon power monitor r Applications m Chess m Face Recognition m Arcade Game m Voice-based translator

54 Questions r How much can MAUI reduce energy consumption? r How much can MAUI improve performance? r Can MAUI Run Resource-Intensive Applications?

55 Big savings even on 3G An order of magnitude improvement on Wi-Fi Face Recognizer

56 Improvement of around an order of magnitude Face Recognizer

57 Up to 40% energy savings on Wi-Fi Solver would decide not to offload Arcade Game

58 CPU Intensive even on a Core 2 Duo PC Can be run on the phone with MAUI Translator

59 DoLevel HandleMissiles DoFrame HandleEnemies HandleBonuses 11KB + missiles missiles *Missiles take around 60 bytes each 11KB + missiles Required state is smaller Complexity increases with # of missiles

60 DoLevel HandleMissiles DoFrame HandleEnemies HandleBonuses *Missiles take around 60 bytes each  Zero Missiles  Low latency (RTT < 10ms) Computation cost is close to zero Offload starting at DoLevel

61 DoLevel HandleMissiles DoFrame HandleEnemies HandleBonuses *Missiles take around 60 bytes each  5 Missiles  Some latency (RTT = 50ms) Most of the computation cost Very expensive to offload everything Little state to offload Only offload Handle Missiles

62 62

63  Adapt to:  Network Bandwidth/Latency Changes  Variability on method’s computational requirements  Experiment:  Modified off the shelf arcade game application  Physics Modeling (homing missiles)  Evaluated under different latency settings

64 64

65 65  The CODA system assumes that modifications are kept as logs (CML)  a user sends the logs to the servers to update  If the storage of a client is limited, it may not be able to save logs  then upon reconnection, the cache manager needs to find the difference between the stored file and its local cached copy  same problem exists for the rsync tool !  Question: how to efficiently compare the differences of two remote files (when the network connection is slow)?

66 66  Break Files into chunks and transfer only modified chunks  Fixed chunk size does not work well  why?

67 67  Compute hash value of every 48 byte block  if the hash value equals to a magic value, it is a chunk boundary

68 68 Bayou: Managing Update Conflicts r Basic idea: application specific conflict detection and update r Two mechanisms for automatic conflict detection and resolution m dependency check m merge procedure http://zoo.cs.yale.edu/classes/cs422/2011/bib/terry95managing.p df


Download ppt "1 Mobile Software Development Framework: Adaptive Mobile Applications 10/23/2012 Y. Richard Yang."

Similar presentations


Ads by Google