18
SQL Statement Logging for Making SQLite Truly Lite Jong-Hyeok Park, Gihwan Oh, Sang-Won Lee

SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

Page 1: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

SQL Statement Logging for Making SQLite Truly Lite

Jong-Hyeok Park, Gihwan Oh, Sang-Won Lee

Page 2: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Outline

▶About SQLite

▶Motivation

▪ Problem Definition

▪ Why Logical Logging?

▶SQLite/SSL

▪ Architecture and Implementation

▶Performance Evaluation

▶Conclusion

Page 3: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

De-facto standard mobile DBMS

Productivity

Solid transactional support

Lightweight codebase

Page 4: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

SQLite is NOT LITE

INSERT INTO chat VALUES ( “hi” );

UPDATE chat SET msg = “hello”where rid = 1;

Auto-Commit

Force-Write

Block Interface

Journaling

File system Metatdata

Huge Write

Amplification

“Hi”

Durability &

Atomicity

Block Interface

Flash Storage (e.g. SD Card, UFS)

Journal fileSQLite Database Files

(per Application)

SQLite (Library)

B-tree module

insert/delete/update/

tx_begin/tx_commit/tx_abort

Buffer Cache

pagepage page page

Durability Performance Life span

Page 5: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Physical Aries-style

PhysiologicalLogical

Method Page-wise Delta SQL statement

Scheme Vanilla SQLite SQLite/PPL [VLDB 15] SQLite/SSL

Log Size

Recovery

[Gray 90] J. Gray and A. Router. Transaction Processing: Concepts and Techniques. Morgan Kaufmann, 1933.

[VLDB 15 ] G. Oh, S. Kim, S.-W. Lee, and B. Moon. SQLite Optimization with Phase Change Memory for Mobile Applications.

Proceedings of VLDB Endowment,8(12), Aug. 2015.

Alternative Logging Mechanisms [Gray 90]

Page 6: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Why We Revisit Logical Logging?

[CSUR 83] T. H¨arder and A. Reuter. Principles of Transaction-Oriented Database Recovery. ACM Computing Survey, 15(4):287–317, 1983.

[ICDE 14] N. Malviya, A. Weisberg, S. Madden, and M. Stonebraker. Rethinking Main Memory OLTP Recovery. In IEEE 30th International

Conference on Data Engineering (ICDE 2014), pages 604–615, 2014.

< Sequence of page-write request in SQLite >Technical

Preconditions

Single User

Strong Update

Locality

Transaction

Consistent

Checkpoint

Mechanism

[Gray 90, CSUR 83, ICDE 14]

Page 7: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Why Logical Logging? (2)

< SQLite WAL Mechanism>Technical

Preconditions

Single User

Strong Update

Locality

Transaction

Consistent

Checkpoint

Mechanism

[Gray 90, CSUR 83, ICDE 14]

WAL Mode

Database File WAL File

P1_new

- TX Completion -

Pn_new

fsync()

P1_new

Pn_new

fsync()

Checkpoint

WAL File FULL

[CSUR 83] T. H¨arder and A. Reuter. Principles of Transaction-Oriented Database Recovery. ACM Computing Survey, 15(4):287–317, 1983.

[ICDE 14] N. Malviya, A. Weisberg, S. Madden, and M. Stonebraker. Rethinking Main Memory OLTP Recovery. In IEEE 30th International

Conference on Data Engineering (ICDE 2014), pages 604–615, 2014.

Page 8: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Why Logical Logging? (3)

▶ Byte Addressable

▶ Avoid I/O Stack

▶ Enable to realize full potential of Logical Logging

Applications

Flash Storage(e.g. eMMC, SD card)

DRAM PCM

Unified Memory System

Mmap( )

Byte-addressable

DIMM Interface

Block I/O Interface

Host

Storage

Non Volatile Memory & Logical Logging

UMS Architecture UMS Board [RSP 14]

Page 9: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Design of SQLite/SSL

Flash Storage(e.g. SD Card)

WAL journal

file

SQLite Database Files

(per Application)

Buffer CacheDRAM

Mobile Application

SQLite(Library)

B-tree module

insert/delete/update/

tx_begin/tx_commit/tx_abort

No-force commit policy

No-steal buffer policy

SQL Interface

Update Pages in Buffer Cache

Vanilla SQLite SSL Extension

Statement Log File

(Flash-Only Case)

NVRAM:

PCM /

NVDIMM

Byte-addressable

mmap() interface

(in case of flash) Call msync()

Statement Log Buffer

(SLB)

Statement Log Area

(SLA)page page page

Page 10: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

SLA = reset & No WAL file

• Crashed during Normal shutdown

Create WAL journal file

SLA = reset & WAL = reset

• Crashed during Initialization

• Crashed after WAL-Checkpoint

No need to recovery

SLA = reset & WAL = in-use

• Crashed after SSL-Checkpoint

Copy latest pages in

WAL to DB file

SLA = in-use

• Crashed prior to SSL-Checkpoint

• Crashed during SSL-Checkpoint

Re-executes

SQL statement in SLA

Recovery

Page 11: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Performance Evaluation

UMS-Board : PCM as SLA log device

• Reduce # of Checkpoints

• Reduce # of Writes

• No worse than Vanilla SQLite even in fully random workloads

• In terms of recovery time, acceptable in practice (less than 1sec)

Andro Bench Gmail Kakao Talk Facebook Browser Random-ATwitter Random-B

0.2 1.2 1.7 3.2 3.2 5.2 13

38.7

WAL SQLite/PPL SQLite/SSL

I/O Time (sec)

B

369x 8x

A

Page 12: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

52.4

22.8

79.9

30.5

49

142.2

8.6 7.2

2112.6 16.7

35.4

0

20

40

60

80

100

120

140

160

AndroBench Gmail KakaoTalk Facebook Browser Twitter

WAL SQLite/SSL

Performance Evaluation (2)

PC : SD Card as SLA log device

I/O Time (sec)

• In Flash-only, 2 ~ 6 times better

• Demonstrate that SQLite/SSL is quite effective without NVM

I/O Time (sec)

Page 13: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

AndroBench Gmail KakaoTalk Facebook Browser Twitter

WAL SQLite/SSL

Recovery Performance

• Acceptable in practice

• Worst-case scenario : SLA = in-use (FULL)

Performance Evaluation (3)보충자료

Recovery Time (sec)

Page 14: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Conclusion

▶Transaction-consistent checkpoint in SQLite: WAL journaling can be naturally extended for TCC

SQLite/SSL demonstrates that logical logging can

be fully and effectively realized in mobile DBMSs

▶UFS with MRAM

▶Add competitive edges to domestic storage

devices and mobile platforms

▶Emerging NVMs: Byte-addressability makes SSL more attractive

Future Works

▶ Key observation about mobile workloads: Short transactions with strong update locality

Page 15: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Q&A

Page 16: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

RecoveryBackup Slide

SLA = reset & No WAL file

• Crashed during Normal shutdown

Create WAL journal file

SLA = reset & WAL = reset

• Crashed during Initialization

• Crashed after WAL-Checkpoint

No need to recovery

SLA = reset & WAL = in-use

• Crashed after SSL-Checkpoint

Copy latest pages in

WAL to DB file

SLA = in-use

• Crashed prior to SSL-Checkpoint

• Crashed during SSL-Checkpoint

Re-executes

SQL statement in SLA

Page 17: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

UMS Board PC

ProcessorXilinx Zynq-7030

dual ARM Cotex-A9 1GHz Intel Core i7-3770 3.40 GHz

DRAM 1GB 12 GB

PCM 512 MB -

Storage SD Card : MB-MSBGA

File system EXT4

Linux Kernel 3.9.0 Xilinx kernel 4.6 kernel

Performance Evaluation

Experimental Setup

Backup Slide

Page 18: SQL Statement Logging for Making SQLite Truly Litesigfast.or.kr/nvramos/nvramos18/presentation/8성균관대 -이상원.pdf · arder and A. Reuter. Principles of Transaction-Oriented

Trace Androbench Gmail KakaoTalk Facebook Browser Twitter

# of Files 1 1 1 11 6 17

DB size (MB) 0.19 0.74 0.45 1.95 2.51 6.08

Total # of TXs

(Batch + Auto)

3,081

(2+3,079)

984

(806+178)

4,342

(432+3,910)

1,281

(262+1,019)

1,522

(1,439+29)

2,022

(17+2,005)

Total # of SQLs

(Batch + Auto)

3,082

(3+3,079)

10,579

(10,419+178)

8,469

(4,559+3,910)

3,082

(2,063+1,019)

4,493

(4,464+29)

10,291

(448+2,005)

Page writes / T X 3.38 8.58 3.58 3.11 3.88 1.40

Avg. size of update

SQL stmt/TX (B)215 1,913 1,094 1,094 8,304 506

Performance Evaluation

Mobile Workloads

Backup Slide