[MIC] msg-service-db: Speed up SQLite3 insertion operations while running MIC command 37/129537/1
authorGeunsik Lim <geunsik.lim@samsung.com>
Wed, 17 May 2017 01:14:54 +0000 (10:14 +0900)
committerGeunsik Lim <geunsik.lim@samsung.com>
Wed, 17 May 2017 01:14:54 +0000 (10:14 +0900)
commit7d07e8d040a8ef3b9e0240fea606fba7f5c53571
tree97a89ee8daec63d41cc7b1a7e3dc3cddc62ebe19
parentfcb6ef20954db28f58d27c243fd628c13e96e22b
[MIC] msg-service-db: Speed up SQLite3 insertion operations while running MIC command

This commit is to speed up exeuction time of a MIC operation.

The "INSERT INTO ..." operation has been taken more than 8 seconds
when we run MIC command to make a Tizen platform image on the below system environment.
 - CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
 - Memory: DDR3 8GiB
 - OS: Ubuntu 14.04.5 LTS

We don't need to keep the synchronous operation in case that we only
run insertion commands without any data modification such as MODIFY
and DELETE statement.

@To maintainer:
----------------
First, Note that  the number of  insertion commands results in more synchronization
cost in kernel space. For example, the more we call a write(2) syscall,
the more  Linux kernel calls submit_bio(9) and futex_wait(9) kernel function.
Disabling a synchronous operation will cause SQLite3 to not wait on data to
reach the disk surface, which will make write operations appear to be much
faster.

Second, Note that you have to check frequently if the version of SQLite3 is state-of-the-art.
As we all know, the existing bugs is often fixed in the latest version of SQLite3.

@Evaluation:
----------------
 - How to do unit-test:
   $ cd ./msg-service
   $ time sqlite3 ./mybenchmark.db < ../msg-service-db.sql

 - Before this patch:
real 0m8.277s
user 0m0.038s
sys 0m0.074s

 - After this patch:
real 0m0.116s
user 0m0.018s
sys 0m0.003s

@Reference:
----------------
 - Pragma statements supported by SQLite, https://www.sqlite.org/pragma.html

Change-Id: I85b181b16c54c97eac6216292ae7f288452139f7
Signed-off-by: Geunsik Lim <geunsik.lim@samsung.com>
config/msg-service-db.sql