summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Fyodor Kupolov <fkupolov@google.com> 2018-04-27 17:41:49 -0700
committer Fyodor Kupolov <fkupolov@google.com> 2018-04-30 22:45:42 +0000
commit2e2f01e4804fc245023b270d41aa017ae22b533c (patch)
tree88b2b0355b7c9b9f06e8a54d612ec23351eddf0b
parent1072d0d18a8701e5fac0d7e545aed7a620f706b3 (diff)
Use NORMAL synchronous mode for WAL journal mode
When synchronous is NORMAL (1), the SQLite database engine will still sync at the most critical moments, but less often than in FULL mode. With this change, the number of writes is reduced by 50%, more than 5x improvement in write performance, read performance is the same. Test: Manual + SQLiteDatabaseTest Bug: 76033286 Change-Id: I13526962bbaeae028a9c6cb668aa9f94bbc2a44d
-rw-r--r--core/res/res/values/config.xml14
1 files changed, 9 insertions, 5 deletions
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 62440880eb26..d95ae08460b7 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -1826,12 +1826,16 @@
<string name="db_default_sync_mode" translatable="false">FULL</string>
<!-- The database synchronization mode when using Write-Ahead Logging.
- FULL is safest and preserves durability at the cost of extra fsyncs.
- NORMAL sacrifices durability in WAL mode because syncs are only performed before
- and after checkpoint operations. If checkpoints are infrequent and power loss
- occurs, then committed transactions could be lost and applications might break.
+ From https://www.sqlite.org/pragma.html#pragma_synchronous:
+ WAL mode is safe from corruption with synchronous=NORMAL, and probably DELETE mode is safe
+ too on modern filesystems. WAL mode is always consistent with synchronous=NORMAL, but WAL
+ mode does lose durability. A transaction committed in WAL mode with
+ synchronous=NORMAL might roll back following a power loss or system crash.
+ Transactions are durable across application crashes regardless of the synchronous setting
+ or journal mode. The synchronous=NORMAL setting is a good choice for most applications
+ running in WAL mode.
Choices are: FULL, NORMAL, OFF. -->
- <string name="db_wal_sync_mode" translatable="false">FULL</string>
+ <string name="db_wal_sync_mode" translatable="false">NORMAL</string>
<!-- The Write-Ahead Log auto-checkpoint interval in database pages (typically 1 to 4KB).
The log is checkpointed automatically whenever it exceeds this many pages.