Fast Transaction Logging for Smartphones Hao Luo , University of Nebraska Lincoln Hong Jiang , University of Texas Arlington Zhichao Yan , University of Texas Arlington Yaodong Yang , University of Nebraska Lincoln 1
Outline • Introduction • Logging Overhead in Mobile Databases • Design of xLog • Evaluation • Conclusion 2
Introduction • The smartphones and tablets have become ubiquitous. • Storage subsystem impacts the application performance. • Database • File system 3
Introduction • Database engines has become a crucial part of data management in mobile systems. • SQLite • LevelDB • Mobile databases employ logging to ensure data persistency • Atomicity • Consistency • Durability 4
Introduction • Journal of journaling (JOJ) anomaly drastically slows down the mobile databases • Breaks the sequential pattern of log I/O • Writes more data. 5
Transaction Commit Path Memory A DB file Log file 6
Transaction Commit Path Memory A’ DB file Log file 7
Transaction Commit Path Memory A’ Upon Txn Commit DB file Log file 8
Transaction Logging • Value Logging • Logs after-image of the database pages • Used by SQLite • Command Logging • Logs transaction logic (e.g., SQL query) • Used by LevelDB 9
SQLite Write Ahead Log • Logs modified database pages. • Header + modified pages • 4KB page size • fsync() upon transaction commit. 10
LevelDB Logging • Logs transaction logic. • Put(): kTypeValue + key + value • Delete(): kTypeDeletion + key • fsync() upon commit (in synchronous mode) 11
Logging Overhead • To assess the overhead of logging in mobile devices, we set up a simple benchmark test • 4 byte key, 100 byte value • 1000 insertion • Sequential / Random key order • Samsung Galaxsy S4 • Run the benchmark on different configurations • DB engine: SQLite, LevelDB • File system: Ext4, F2FS 12
Logging Overhead 13
Log File Size Log File Size (KB) 3500 3000 2500 2000 1500 1000 500 0 Seq Rnd Seq Rnd LevelDB SQLite Ext4 F2FS 14
Log File Size • Log record size • SQLite: header + key + value (130 Byte) • LevelDB: header + modified pages (several KB) • SQLite’s value logging writes significantly more data to the log files. 15
Data Written to Log File Data Written to Log File (KB) 8000 7000 6000 5000 4000 3000 2000 1000 0 Seq Rnd Seq Rnd LevelDB SQLite Ext4 F2FS 16
Data Written to Log File • File system block • Data are flushed at file system block boundaries. • Usually 4KB in mobile devices. 17
Data Written to Device Data Written to Device (KB) 30000 25000 20000 15000 10000 5000 0 Seq Rnd Seq Rnd LevelDB SQLite Ext4 F2FS 18
qNVRAM • Nearly non-volatile memory in smartphones • Takes advantage of battery-backed nature of mobile devices. • Data survive almost all the failure conditions. • Application crash • Kernel panic • Hard reset 19
xLog xLog Service Process App App qNVRAM Log file buffer Android Binder 20
Evaluation • Microbenchmark • Raw performance of the xLog • Different log record size 21
Micro-benchmark Performance 22
Micro-benchmark Write Amplification 23
Evaluation • Micro-benchmark • Raw performance of the xLog • Different log record size • Macro-benchmark • Transaction latency of LevelDB • xLog v.s. write()+fsync() • Different size of value 24
Evaluation 3000 Logging Other 2417 2500 Average Latency ( µ s) 2174 2104 2050 2000 1500 1000 500 278 265 231 192 0 100 400 800 1600 100 400 800 1600 xLog write()+fsync() Value Size (Byte) 25
Conclusion • In this paper we present xLog, a fast transaction logging service that uses qNVRAM as a buffer, for Android smartphones. • xLog logs up to 77x times faster than the tranditional logging scheme • xLog drastically reduces the write amplification from 122x to 1.6x. 26
Thank you! Q & A 27
Recommend
More recommend