+ All Categories
Home > Software > CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

Date post: 28-Nov-2014
Category:
Upload: farley-lai
View: 234 times
Download: 0 times
Share this document with a friend
Description:
 
Popular Tags:
30
University of Iowa | Mobile Sensing Laboratory CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications IPSN 2014 Farley Lai, Syed Shabih Hasan, Austin Laugesen, Octav Chipara Department of Computer Science
Transcript
Page 1: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory

CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing

Applications

IPSN 2014

Farley Lai, Syed Shabih Hasan, Austin Laugesen, Octav ChiparaDepartment of Computer Science

Page 2: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 2

Mobile Sensing Applications (MSAs)

CSense Toolkit

Speaker Models

Speech Recording VAD Feature

Extraction

HTTP Upload

SittingStandingWalkingRunning

Climbing Stairs…

Bluetooth Data

Collection

Feature Extraction

Activity Classification

Speaker Identification

Activity Recognition

Page 3: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 3

• Mobile sensing applications are difficult to implement on Android devices– concurrency – high frame rates – robustness

• Resource limitations and Java VM worsen these problems– additional cost of virtualization– significant overhead of garbage collection

Challenges

CSense Toolkit

Page 4: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 4

• Support for MSAs– SeeMon, Coordinator: constrained queries– JigSaw: customized pipelines CSense provides a high-level stream programming abstraction general and suitable for a broad range of MSAs

• CSense builds on prior data flow models– Synchronous data flows: static scheduling and optimizations

• e.g., StreamIt, Lustre– Async. data flows: more flexible but have lower performance

• e.g., Click, XStream/Wavescript

Related Work

CSense Toolkit

Page 5: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 5

• Programming model

• Compiler

• Run-time environment

• Evaluation

CSense Toolkit

CSense Toolkit

Page 6: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 6

• Applications modeled as Stream Flow Graphs (SFG)– builds on prior work on asynchronous data flow graphs – incorporates novel features to support MSA

Programming Model

CSense Toolkit

addComponent("audio", new AudioComponentC(rateInHz, 16));addComponent("rmsClassifier", new RMSClassifierC(rms));addComponent("mfcc", new MFCCFeaturesG(speechT, featureT))...link("audio", "rmsClassifier");toTap("rmsClassifier::below");link("rmsClassifier::above", "mfcc::sin");fromMemory("mfcc::fin");...

create components

wirecomponents

Page 7: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 7

• Goal: Reduce memory overhead introduced by garbage collection and copy operations

• Pass-by-reference semantics – allows for sharing data between components

• Explicit inclusion of memory management in SFGs – focuses programmer’s attention on memory operations– enables static analysis by tracking data exchanges globally– allows for efficient implementation

Memory Management

CSense Toolkit

Page 8: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 8

• Data flows from sources, through links, to taps

• Implementation:– sources implement memory pools that hold several frames– references counters used to track sharing of frames– taps decrement reference counters

Memory Management

CSense Toolkit

Audio data MFCCs Filenames

Page 9: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 9

• Goal: Expressive concurrency model that may be analyzed statically

• Components are partitioned into execution domains– components in the same domain are executed on a thread– frame exchanges between domains are mediated using shared queues

• Other data sharing between components are using a tuple space

• Concurrency is specified as constraints– NEW_DOMAIN / SAME_DOMAIN

– heuristic assignment of components to domains to minimize data exchanges between domains

• Static analysis may identify some data races

Concurrency Model

CSense Toolkit

Page 10: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 10CSense Toolkit

Concurrency Model

getComponent("audio").setThreading(Threading.NEW_DOMAIN);getComponent("httpPost").setThreading(Threading.NEW_DOMAIN);getComponent("mfcc").setThreading(Threading.SAME_DOMAIN);

Compiler transformation

Page 11: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 11

• Goal: Promote component reuse across MSAs• A rich type system that extends Java’s type system– most components use generic type systems– insight: frame sizes are essential in configuring components

• detect configuration errors / optimization opportunities

Type System

CSense Toolkit

VectorC energyT = TypeC.newFloatVector();energyT.addConstraint(Constraint.GT(8000)); energyT.addConstraint(Constraint.LT(24000));VectorC speechT = TypeC.newFloatVector(128);VectorC featureT = TypeC.newFloatVector(11);

Page 12: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 12

• Not all configurations may be implemented efficiently

Flow Analysis

CSense Toolkit

Constraints:energyT > 8000energyT < 24000speechT = 128featuresT = 11

energyT speechT

Inefficient 10,000 128

Efficient 10,240 (128 * 80) 128

Page 13: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 13

• Not all configurations may be implemented efficiently

Flow Analysis

CSense Toolkit

Constraints:energyT > 8000energyT < 24000speechT = 128featuresT = 11

energyT speechT

Inefficient 10,000 128

Efficient 10,240 (128 * 80) 128

Mrms=1 Mmfcc=80

An efficient implementation exists whenMrms * energyT = Mmfcc * speechT

Page 14: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 14

• Goal: determine configurations have efficient frame conversions

• Problem may be formulated as an integer linear program– constraints: generated from type constraints– optimization: minimize total memory usage– solution: specifies frame sizes and multipliers for application

• An efficient frame conversion may not exist– the compiler relaxes conversion rules

Flow Analysis

CSense Toolkit

Page 15: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 15

• Static analysis:– composition errors, memory usage errors, race conditions

• Flow analysis: – whole-application configuration and optimization

• Stream Flow Graph transformations:– domain partitioning, type conversions, MATLAB component

coalescing

• Code generation:– Android application/service, MATLAB (C code + JNI stubs)

CSense Compiler

CSense Toolkit

Page 16: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 16

• Components exchange data using push/pull semantics• Runtime includes a scheduler for each domain– task queue + event queue– wake lock – for power management

CSense Runtime

CSense Toolkit

Scheduler1Task Queue

Event Queue

Scheduler2 Task Queue

Event Queue

Memory Pool

Page 17: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 17

• Micro benchmarks evaluate the runtime performance– synchronization primitives + memory management

• Implemented the MSA using CSense– Speaker identification– Activity recognition – Audiology application

• Setup– Galaxy Nexus, TI OMAP 4460 ARM [email protected] GHz, 1 GB– Android 4.2– MATLAB 2012b and MATLAB Coder 2.3

Evaluation

CSense Toolkit

Page 18: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 18

• Scheduler: memory management + synchronization primitives• Memory management options– GC: garbage collection– MP: memory pool

• Concurrent access to queues and memory pools– L: Java reentrant lock– C: CSense atomic variable based synchronization primitives

Producer-Consumer Benchmark

CSense Toolkit

Page 19: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | CSense Toolkit 19

Producer-Consumer Throughput

• Garbage collection overhead limits scalability• Concurrency primitives have a significant impact on performance

30%

13.8x

19x

Page 20: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 20

• Reentrant locks incurs GC due to implicit allocations• CSense runtime has low garbage collection overhead

Producer-Consumer GC Overhead

no garbage collection

(in this benchmark)

CSense Toolkit

Page 21: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 21

• Benefits of flow analysis• Runtime overhead

MFCC Benchmark

CSense Toolkit

Page 22: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 22

• Flow analysis eliminates unnecessary memory copy• Benefits of larger but efficient frame allocations– reduced number of component invocations and disk I/O

overhead– Increased cache locality

MFCC Benchmark CPU Usage

45% decrease

CSense Toolkit

Page 23: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 23

• Runtime overhead is low for a wide range of data rates

MFCC Runtime Overhead

1.83%

2.39%

CSense Toolkit

Page 24: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 24

• Programming model– efficient memory management– flexible concurrency model– rich type system

• Compiler– whole-application configuration & optimization– static and flow analyses

• Efficient runtime environment• Evaluation

– implemented three typical MSAs– benchmarks indicate significant performance improvements

• 19X throughput boost compared with naïve Java baseline• 45% CPU time reduced with flow analysis• Low garbage collection overhead

Conclusions

CSense Toolkit

Page 25: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 25

• National Science Foundation (NeTs grant #1144664 )

• Carver Foundation (grant #14-43555 )

Acknowledgements

CSense Toolkit

Page 26: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 26

• Runtime scheduler overhead of a complex 6-domain application that accesses both phone sensors and remote shimmer motes over bluetooth

ActiSense Benchmark

CSense Toolkit

Page 27: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 27

• Runtime scheduler overhead of a complex 6-domain application that accesses both phone sensors and remote shimmer motes over bluetooth

ActiSense Benchmark

CSense Toolkit

Page 28: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 28

• Overall domain scheduler overhead is small despite a longer pipeline

ActiSense CPU Usage

50 Hz

60 Hz

CSense Toolkit

Page 29: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 29

AudioSense

CSense Toolkit

Page 30: CSense: A Stream-Processing Toolkit for Robust and High-Rate Mobile Sensing Applications

University of Iowa | Mobile Sensing Laboratory | 30

AudioSense

CSense Toolkit


Recommended