Efficient ¡Concurrency ¡Support
for ¡
Computer ¡Vision ¡Applications
Robert ¡LiKamWa Lin ¡Zhong Rice ¡University
Starfish Efficient Concurrency Support for Computer Vision - - PowerPoint PPT Presentation
Starfish Efficient Concurrency Support for Computer Vision Applications Robert LiKamWa Lin Zhong Rice University 1 In the year 2020... 2 Continuous mobile vision Where did I place Remind me to Oh, I haven't
Efficient ¡Concurrency ¡Support
for ¡
Computer ¡Vision ¡Applications
Robert ¡LiKamWa Lin ¡Zhong Rice ¡University
In ¡the ¡year ¡2020...
2Where did I place my keys? Oh, I haven't talked to Fred recently...
3Remind me to tell Lin to let me graduate!
Continuous ¡mobile ¡vision
? ? ? ? ? ? ? ? ? ?
Continuous ¡mobile ¡vision
Insufficient ¡concurrency ¡support ¡for ¡vision!
Energy ¡consumption ¡overwhelms ¡wearable ¡battery!
Application Capture ¡Service Vision ¡ Headers
Vision ¡ Library
Application Capture ¡Service Vision ¡ Headers
Scale Face
Vision Library
7Vision Library Vision Library
We ¡need ¡efficient ¡concurrency ¡support!
Camera ¡is ¡overworked Computation ¡is ¡overworked
200+ ¡ms 200+ ¡ms 200+ ¡ms
Vision Library Vision Library Vision Library
Observations:
Face SURF Scale Scale Scale Face
Observations:
common ¡ primitives
Face SURF Scale Scale Scale Face
Observations:
common ¡ primitives
Share ¡computations, Reduce ¡redundancy
Key ¡Idea:
Proposal: ¡Split-‑process ¡design ¡for ¡centralized ¡control ¡
Scale SURF Face
Starfish ¡Core Service
12Vision ¡ Library
Starfish ¡Library Uses ¡vision ¡headers ¡ to ¡intercept ¡library ¡calls Starfish ¡Core ¡Service Executes, ¡tracks, ¡and ¡shares library ¡call ¡computations
Vision ¡ Library Starfish Library Starfish Library Starfish Library
Starfish ¡Core Service
13Vision ¡ Library Vision ¡ Library Starfish Library Starfish Library Starfish Library
Starfish
Split-‑process ¡library ¡solution ¡for ¡ efficient, ¡transparent ¡multi-‑app ¡service
First ¡Call Execute ¡call ¡(20-‑200 ¡ms) Store ¡results Subsequent ¡Call(s) Skip ¡execution (0 ¡ms) Retrieve ¡results
Starfish ¡Core
Vision ¡ Library Exec. Function ¡Cache Storage/Retrieval Function ¡Cache ¡ Arg ¡Search faceDetect(img) faceDetect(img) Vision ¡ Library Starfish Library Starfish Library Starfish Library
Starfish ¡Core
Function Cache
15Starfish
Share ¡computations, Reduce ¡redundancy
Cache ¡ Search Vision ¡ Library Vision ¡ Library Starfish Library Starfish Library Starfish Library
Timing ¡optimizations: + ¡Reuse ¡"Fresh ¡Frames” ¡to ¡promote ¡cache ¡hits + ¡Delay ¡call ¡return ¡to ¡encourage ¡device ¡sleep
Starfish ¡Core
Function Cache Cache ¡ Search Vision ¡ Library Vision ¡ Library Starfish Library Starfish Library Starfish Library
Starfish ¡Core
Function Cache
17Starfish Library Starfish Library Starfish Library
Cache ¡ Search Vision ¡ Library
+ ¡Promote ¡sharing ¡by ¡reusing ¡"Fresh ¡Frames” + ¡Maintain ¡code ¡privacy ¡by ¡delaying ¡call ¡return + ¡Manage ¡concurrent ¡requests ¡through ¡fine-‑grained ¡locks
Mitigating ¡ Split-‑Process ¡Overhead
Starfish ¡Core
18Starfish Library Starfish Library Starfish Library
Function Cache Cache ¡ Search Vision ¡ Library
Reduce ¡expense ¡of ¡argument ¡passing Avoid ¡library ¡object ¡modification
Split-‑Process ¡in ¡the ¡Literature
19Zero-‑copy Require ¡library ¡redesign ¡ Object ¡tracking Optimized ¡for ¡code ¡offload
Split-‑Process ¡Argument ¡Passing
20faceDetect( )
Goal: ¡Minimize ¡deep ¡copy ¡overhead
3.5 ¡ms
Shared ¡Memory Starfish ¡Library Starfish ¡Core
deep ¡copy is ¡expensive ¡
Vision ¡ Library Execution
1) ¡Protected ¡shallow ¡copy
21Issue ¡copy-‑on-‑write ¡(mprotect) ¡on ¡received ¡objects
faceDetect( )
Shared ¡Memory Starfish ¡Library Starfish ¡Core
Vision ¡ Library Execution CoW CoW
2) ¡Direct ¡output ¡marshalling
22Write ¡new ¡data ¡directly into ¡shared ¡memory
faceDetect( )
Shared ¡Memory Starfish ¡Library Starfish ¡Core
Vision ¡ Library Execution CoW CoW
malloc()
3) ¡Reuse ¡arguments ¡from ¡prior ¡calls
23Track, ¡reuse ¡previous ¡inputs/outputs
faceDetect( )
Shared ¡Memory Starfish ¡Library Starfish ¡Core
Vision ¡ Library Execution CoW CoW
malloc()
Argument ¡ Table (img, ¡shm_ptr)
(Usually) ¡Zero-‑Copy ¡Argument ¡Passing
24+ ¡Reduce ¡deep ¡copies ¡through ¡argument ¡reuse + ¡Reduce ¡allocation ¡through ¡buffer ¡reuse ¡
faceDetect( )
Shared ¡Memory Starfish ¡Library Starfish ¡Core
Vision ¡ Library Execution CoW CoW
malloc()
Argument ¡ Table (img, ¡shm_ptr)
Starfish ¡Optimizations
developers ¡& ¡users
by ¡relaxing ¡timing
Experimental ¡Platform
Benchmarks: 1) ¡Per-‑call ¡micro-‑benchmarks 2) ¡Multi-‑app ¡benchmarks
OMAP4430 ¡dual-‑core ¡Cortex-‑A9 ¡ pinned ¡to ¡600 ¡MHz OpenCV ¡+ ¡Android ¡+ ¡Google ¡Glass ¡ Monsoon ¡Power ¡Monitor
First ¡Call
Native : 21 ¡ms
Starfish : 24ms
Memory ¡optimizations ¡ cut ¡Starfish ¡overhead ¡in ¡half
0" 5" 10" 15" 20" 25" Receive&Outputs& Prepare&Outputs& Allocate&Outputs& Exec.&Function& Search&Cache& Send&Inputs& Prepare&Inputs&
Execution&time&(ms)&
Library'call'execution:'resize() resize()
Native& Starfish&Unopt.& Starfish&
First ¡Call
Native : 21 ¡ms
Starfish : 24ms
Second ¡Call
Native : 21 ¡ms
Starfish : 6 ¡ms ¡
Starfish ¡works ¡well ¡when native ¡function ¡execution ¡>> ¡5 ¡ms
0" 5" 10" 15" 20" 25" Receive&Outputs& Prepare&Outputs& Allocate&Outputs& Exec.&Function& Search&Cache& Send&Inputs& Prepare&Inputs&
Execution&time&(ms)&
Library'call'execution:'resize() resize()
Native& Starfish&Unopt.& Starfish&
Memory ¡optimizations ¡ cut ¡Starfish ¡overhead ¡in ¡half
Places ¡where ¡Starfish ¡fails
– Bad ¡for ¡fast ¡computations – Bad ¡with ¡large, ¡deep ¡arguments
– Random, ¡temporal, ¡external ¡dependencies – Functions ¡with ¡specific ¡parameters
29But ¡great ¡for ¡many ¡high-‑level ¡functions: Face ¡detect, ¡Corner ¡detect, ¡Image ¡resize
Starfish ¡vs. ¡Multi-‑App ¡Workload
30Scale Face Detect Face Recog If ¡Lin ¡then ¡That Social ¡Logger Facebook Google+ Twitter MySpace Whatsapp ... 0.3 ¡FPS
0" 0.5" 1" 1.5" 2" 2.5" 3" 3.5" 4" 4.5" 5" 1" 2" 3" 4" 5" 6" 7" 8" 9" 10" Frame&Rate& (FPS)& Number&of&App&Instances& Na/ve" Starfish"
When ¡running ¡multiple ¡apps, ¡ Starfish ¡achieves ¡higher ¡performance
31Higher ¡ is ¡ better
When ¡running ¡multiple ¡apps, Starfish ¡draws ¡single-‑app ¡power
320" 500" 1000" 1500" 2000" 2500" 1" 2" 3" 4" 5" 6" 7" 8" 9" 10" Power& Consump-on& (mW)& Number&of&App&Instances& Na.ve" Starfish"
Lower is ¡ better
When ¡running ¡multiple ¡apps, Starfish ¡draws ¡single-‑app ¡power
330" 500" 1000" 1500" 2000" 2500" 1" 2" 3" 4" 5" 6" 7" 8" 9" 10" Power& Consump-on& (mW)& Number&of&App&Instances& Na.ve" Starfish"
Starfish ¡achieves ¡efficient ¡concurrency ¡support! ¡
Starfish ¡Core
Function Cache
34Starfish
Share ¡computations, Reduce ¡redundancy
Cache ¡ Search Vision ¡ Library Vision ¡ Library Starfish Library Starfish Library Starfish Library
Continuing mobile ¡vision
Mitigating Analog Signal ¡Chain Bandwidth
Preserving User/Subject Privacy Designing Efficient Systems
Starfish: ¡ Share ¡computations, ¡Reduce ¡redundancy
36Transparent, ¡efficient ¡library ¡call ¡caching
frame ¡freshness ¡and ¡performance ¡preservation
minimal ¡deep ¡copy ¡and ¡small ¡cache ¡footprint
Google ¡Glass ¡Experiments:
Memory ¡optimizations ¡slash ¡overhead ¡in ¡half
Multi-‑app ¡workloads ¡draw ¡Single ¡app ¡ ¡power