[MIC] Speed up SQLite3 insertion operations while running MIC command 04/127304/1 accepted/tizen/unified/20170428.033153 submit/tizen/20170428.000009
authorGeunsik Lim <geunsik.lim@samsung.com>
Thu, 27 Apr 2017 04:25:12 +0000 (13:25 +0900)
committerGeunsik Lim <geunsik.lim@samsung.com>
Thu, 27 Apr 2017 04:25:12 +0000 (13:25 +0900)
The "INSERT INTO ..." operation has been taken more than 25 minutes
(total time is 51 minutes) 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.

@To maintainer:
----------------
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. But if you lose power in the middle of a transaction, your database
file might go corrupt. So, Please do not use this approach unconsciously
in the mobile devices that is powered by battery.

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 ./tel-plugin-packetservice/resources/ivi
   $ time sqlite3 ./mybenchmark.db < ../dnet_db.sql

 - Before this patch:
   real  3m22.701s
   user  0m0.258s
   sys 0m3.143s

 - After this patch:
   real  0m0.028s
   user  0m0.005s
   sys 0m0.024s

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

Change-Id: I2f3c79b5c4303c4414f8aa6d539ec898df25c89f
Signed-off-by: Geunsik Lim <geunsik.lim@samsung.com>
resources/3g/dnet_db_init.sql
resources/dnet_db.sql
resources/dnet_db_data.sql
resources/dnet_db_upgrade_24_30.sql
resources/ivi/dnet_db_init.sql
resources/lte/dnet_db_init.sql
resources/tv/dnet_db_init.sql

index 47856e5f8510aa5b8c57f75e2231230555c659c7..662deaa1cbddcc2f9d529752b21c12365e7aaef4 100644 (file)
@@ -1,3 +1,9 @@
+PRAGMA journal_mode = PERSIST;
+PRAGMA synchronous = OFF;
+PRAGMA locking_mode = EXCLUSIVE;
+PRAGMA temp_store = MEMORY;
+PRAGMA cache_size=-5000;
+
 INSERT INTO "pdp_profile" VALUES(1,'Cosmote Wireless Internet','internet',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,261,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(2,'Cosmote Mms','mms',0,NULL,NULL,2,2,'10.10.10.20:8080','http://mmsc.cosmote.gr:8002',300,NULL,NULL,NULL,NULL,NULL,NULL,261,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(3,'Vf Mobile Internet','internet.vodafone.gr',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,262,1,0,1,1,0,0,1);
index 4b0b806dd2b98c6c8becf63824692b42b631712c..2eaf7aa3cf84ccb544e7c73f4ef779f4a4744390 100644 (file)
@@ -1,4 +1,8 @@
 PRAGMA journal_mode = PERSIST;
+PRAGMA synchronous = OFF;
+PRAGMA locking_mode = EXCLUSIVE;
+PRAGMA temp_store = MEMORY;
+PRAGMA cache_size=-5000;
 
 DROP TABLE IF EXISTS "fd_blacklist";
 CREATE TABLE fd_blacklist(
index 3844a6310b258ad09658b845e7db3fe2aa076d87..1a4a24d3d2fb487101beedf29fb6f3110adc5ea9 100644 (file)
@@ -1,3 +1,9 @@
+PRAGMA journal_mode = PERSIST;
+PRAGMA synchronous = OFF;
+PRAGMA locking_mode = EXCLUSIVE;
+PRAGMA temp_store = MEMORY;
+PRAGMA cache_size=-5000;
+
 INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (1, 'Samsung 3G', '45001');
 INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (2, 'Vodafone.de', '26202');
 INSERT INTO "network_info" (network_info_id, network_name, mccmnc) VALUES (3, 'Vodafone.uk', '23415');
index 173dad6af31a6cebdba27ab303d67f15829387b3..e2aa7ffbb62e1b735d979f1f6f6e9b3d95a0f227 100644 (file)
@@ -1,3 +1,9 @@
+PRAGMA journal_mode = PERSIST;
+PRAGMA synchronous = OFF;
+PRAGMA locking_mode = EXCLUSIVE;
+PRAGMA temp_store = MEMORY;
+PRAGMA cache_size=-5000;
+
 DROP TABLE IF EXISTS "pdp_profile_upgrade";
 CREATE TABLE pdp_profile_upgrade(
        profile_id           INTEGER PRIMARY KEY,
index a033b548c28b77a088c1e3d94e150524e8054af3..64b3a4f8bbfcba2971409131afef753f444c1ce0 100644 (file)
@@ -1,3 +1,9 @@
+PRAGMA journal_mode = PERSIST;
+PRAGMA synchronous = OFF;
+PRAGMA locking_mode = EXCLUSIVE;
+PRAGMA temp_store = MEMORY;
+PRAGMA cache_size=-5000;
+
 INSERT INTO "pdp_profile" VALUES(1,'Cosmote Wireless Internet','internet',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,261,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(2,'Cosmote Mms','mms',0,NULL,NULL,2,2,'10.10.10.20:8080','http://mmsc.cosmote.gr:8002',300,NULL,NULL,NULL,NULL,NULL,NULL,261,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(3,'Vf Mobile Internet','internet.vodafone.gr',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,262,1,0,1,1,0,0,1);
index 6fc1c232ee187cbf26790c44c43a59e09ac90347..a864bcb00291617d3406dd8cb4e8cd18d2daa750 100644 (file)
@@ -1,3 +1,9 @@
+PRAGMA journal_mode = PERSIST;
+PRAGMA synchronous = OFF;
+PRAGMA locking_mode = EXCLUSIVE;
+PRAGMA temp_store = MEMORY;
+PRAGMA cache_size=-5000;
+
 INSERT INTO "pdp_profile" VALUES(1,'Cosmote Wireless Internet','internet',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,261,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(2,'Cosmote Mms','mms',0,NULL,NULL,2,2,'10.10.10.20:8080','http://mmsc.cosmote.gr:8002',300,NULL,NULL,NULL,NULL,NULL,NULL,261,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(3,'Vf Mobile Internet','internet.vodafone.gr',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,262,1,0,1,1,0,0,1);
index 5ebf6f0ed63c9b940634f7ff36e1b3ce2f54be55..c3c54f93fbbe0aa590b5d9ab5f52b854502a9248 100644 (file)
@@ -1,3 +1,9 @@
+PRAGMA journal_mode = PERSIST;
+PRAGMA synchronous = OFF;
+PRAGMA locking_mode = EXCLUSIVE;
+PRAGMA temp_store = MEMORY;
+PRAGMA cache_size=-5000;
+
 INSERT INTO "pdp_profile" VALUES(1,'Cosmote Wireless Internet','internet',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,261,1,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(2,'Cosmote Mms','mms',0,NULL,NULL,2,2,'10.10.10.20:8080','http://mmsc.cosmote.gr:8002',300,NULL,NULL,NULL,NULL,NULL,NULL,261,2,0,1,1,0,0,1);
 INSERT INTO "pdp_profile" VALUES(3,'Vf Mobile Internet','internet.vodafone.gr',0,NULL,NULL,2,2,NULL,NULL,300,NULL,NULL,NULL,NULL,NULL,NULL,262,1,0,1,1,0,0,1);