48
Enhancement of Open Source Monitoring Tool for Small Footprint Databases Sukh Deo Under the guidance of Prof. Deepak B. Phatak Dept. of CSE IIT Bombay October 30, 2013 Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint Databases October 30, 2013 1 / 48

Enhancement of Open Source Monitoring Tool for … of Open Source Monitoring Tool for Small Footprint Databases Sukh Deo Under the guidance of Prof. Deepak B. Phatak Dept. of CSE IIT

  • Upload
    lynhu

  • View
    227

  • Download
    3

Embed Size (px)

Citation preview

Enhancement of Open Source Monitoring Tool for SmallFootprint Databases

Sukh Deo

Under the guidance of

Prof. Deepak B. PhatakDept. of CSEIIT Bombay

October 30, 2013

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 1 / 48

Table of contents

IntroductionMotivationIntroduction of Small Footprint DatabasesIntroduction of Monitoring Tool

Small Footprint DatabasesBerkeley DBPerst DBSQLite DBComparison among Berkeley DB, Perst DB, and SQLite DBJournal Mode in SQLite and Shadow Paging

Monitoring Tools for Mobile DevicesIOzoneAndroBenchMobiBench

Problem Statement and Proposals

Conclusion and Future Work

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 2 / 48

Motivation

Todays mobile devices are multifunctional devices

Mobile devices are siblings of personal computers

People want to use many applications on mobile device

Mobile device has some limitations

Small memoryBattery issues

Enhance the performance of small footprint databases and monitoringtool

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 3 / 48

Small footprint databases

Called lightweight databases or embedded databases

Specially designed for mobile devices

People want to use many applications on mobile device

Mobile devices require such types of database that uses small memoryand low power

Example, Berkeley DB, Perst DB, SQLite, and etc.

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 4 / 48

Monitoring Tool

In mobile device, each application generates the specific load

Measures the load of each application that are running on mobiledevice

For finding the correct load of application, we have to analyze datatypes and file system of executing application.

For measure the performance of mobile device, we need mobilebenchmarking tool

Example, IOzone, AndroBench, and MobiBench

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 5 / 48

Literature Survey on Small Footprint Databases

Berkeley Database

Berkeley DB is an embedded database

Open source and written in C language

Used to store the data, key/value technique

Example, to store the user name and password

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 7 / 48

Access method in Berkeley DB

B+tree

Hash

Fixed or variable length record

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 8 / 48

Limitations

It does not support RDBMS

It has no schema

It stores only the record key/value technique, so that we cannotcompare the data other than key value

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 9 / 48

Perst DB

Perst Database is an open source embedded databases, based on Javaobject oriented architecture

Feature are:

B.treeR-tree indexSpecialized versions of collections for thick indices and bit indices

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 10 / 48

Limitation

It is application specific database for storing real object information

Example, we can use Perst DB for restaurant searching application,because we can access and store information using making object

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 11 / 48

SQLite DB

Due to limitation of small memory, it does not provides all the featureof RDBMS

Some other features that are not present in RDBMS are zeroconfiguration, self-content, and server-less database

It has a schema, thus we can design our own tables as we want

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 12 / 48

Comparison among Berkeley DB, Perst DB, and SQLiteDB

SQLite is a native database. It has a schema, so that we can designour own tables as we want

Berkeley DB is an embedded database. It stores the data bykey/value schema

Perst DB is an object oriented, application specific database forstoring real object information

We cannot really compare properly, because each has some specialproperty

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 13 / 48

Architecture of SQLite

Figure: Architecture of SQLiteSukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 14 / 48

Journal Mode of SQLite

Rollback journal

Write-Ahead Log(WAL) Mode

OFF Mode

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 15 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 16 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 17 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 18 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 19 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 20 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 21 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 22 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 23 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 24 / 48

Rollback journal

Figure: commit process

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 25 / 48

Write-Ahead Log(WAL) Mode

The WAL approach inverts of Rollback journal

The original content is preserved in the database file and the changesare appended into a separate WAL file

COMMIT can happen without ever writing to the original database

Allows readers to continue operating from the original unaltereddatabase while changes are simultaneously being committed into theWAL

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 26 / 48

Write-Ahead Log(WAL) Mode

Advantage

WAL provides more concurrency as readers do not block writers and awriter does not block readersWAL uses fewer fsync() operations and is thus less vulnerable toproblems on systems where the fsync() system call is broken

Disadvantage

All processes using a database must be on the same host computer.WAL does not work over a network file systemWAL might be very slightly slower than the traditional rollback-journalapproach in applications that do mostly reads and seldom writeThere is the extra operation of check pointing

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 27 / 48

OFF Mode

OFF mode journal used when no need of page replacement technique

Example, while playing the game no need of such page replacementtechnique, because that time only speed matter. So that, we can useOFF mode journal

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 28 / 48

Shadow paging

Database maintains two images per page during the transaction, i.e.,shadow page and a new page

The shadow page is remain same the duration of the transaction

The new page will be changed when a transaction performs a writeoperation

To commit modification, it modifies all pointers to old (shadow) pageto now point to new page, and frees the shadow page

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 29 / 48

Literature Survey on Monitoring Tool

Literature Survey on Monitoring Tool

IOzone

AndroBench

MobiBench

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 31 / 48

IOzone

IOzone is benchmark tool for file system

It is not open source tool

Used by computer vendors to measures the IO performance ofaccessing read, write, fread, and fwrite operations of a single file

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 32 / 48

Limitations

It does not include fsync(). So , that we cannot measure theperformance of SQLite

In Android devices, there is no way of getting the superuserpermission in user level for remounting and unmounting file, butIOzone need to superuser permission. So, it cannot measure theperformance of Android devices

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 33 / 48

AndroBench

AndroBench is a storage benchmarking tool for Android mobiledevices

It is not open source tool

It measures the sequential and random IO performance andthroughput of various SQLite transaction, i.e., insert, delete, andupdate

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 34 / 48

Structure of AndroBench

Figure: Setting tab

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 35 / 48

Limitations

It has no method to measure the performance of fsync() call

It does not allow changing synchronization option such as O SYNC,O DIRECT, and Mmap

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 36 / 48

MobiBench

Mobibench is a storage performance benchmarking tool

It combines both characteristics of IOzone and AndroBench

It is implemented in two versions, first one shell application andsecond one is Android application

It is implemented in C

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 37 / 48

Measure Tab of MobiBench

Figure: measure tab

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 38 / 48

Setting Tab of MobiBench

Figure: measure tab

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 39 / 48

Problem Statement and Proposal

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 40 / 48

Problem on SQLite

flash memory has two critical drawbacks

A segment, blocks of flash memory, need to be erased before they canbe rewrittenThe life of each memory block is limited to 10,00,000 writes

SQLite uses rollback journal or write ahead logging, which areupdatein place approach

Due to erase first than update, it decrease the performance

Rollback journal does not provides to overcome the above twomention problem of flash memory

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 41 / 48

Proposal

Shadow paging is better solution

No need to erase immediately, we simply update the data in free space

After commit, it modifies all pointers to old (shadow) page to nowpoint to new page and garbage collector will collect the old page

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 42 / 48

Possible optimization on MobiBench

Problem on MobiBench

MobiBench has no procedure to analyze the IO characteristics of Hotand Cold chunkIt has no procedures to measure shadow paging techniqueMobiBench is developed by Kisung Lee(kisungleehanyang.ac.kr),Sooman Jeong (77smarthanyang.ac.kr), and Jungwoo Hwang(tearoseshanyang.ac.kr).I communicated to them. They replied that we can modified the sourcecode.

ProposalSince, MobiBench is open source benchmarking tool, we can add amodule that will measure the performance of Shadow paging

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 43 / 48

Conclusion

We have discussed Small footprint database, i.e., Berkeley DB, PerstDB, and SQLite

We found that SQLite gives better performance

We have discussed architecture and journal mode of SQLite, i.e.,rollback, WAL, and OFF mode

We have also discussed possible way to optimize the performance ofSQLite, i.e., Shadow paging

We have discussed different monitoring tool, i.e., IOzone,AndroBench, and MobiBench

We found that Mobibench give better performance

We proposed to add a modules in MobiBench for measure theperformance of Shadow paging

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 44 / 48

Future work

Implement shadow paging in SQLite

Change the source code of MobiBench, so that we can compare theperformance between shadow paging and WAL

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 45 / 48

Thank You

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 46 / 48

Mobibench Source code

Line of code: 3782

Classes: Total 63 classes. There are 45 classes for IO analysis, 15classes for managing the user view, and three classes for analysis thedatabase behaviour.

We have to add some classes for IO and databases analysis formeasure the performance of shadow paging.

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 47 / 48

References

https://www.sqlite.org/

http://dl.acm.org/

http://www.mcobject.com/perst

http://www.it.iitb.ac.in/arndg/dokuwiki/images/5/5d/Stage2Report.pdf

Sukh Deo (IIT Bombay) Enhancement of Open Source Monitoring Tool for Small Footprint DatabasesOctober 30, 2013 48 / 48