Permalink
Browse files

Enable the powersafe overwrite assumption.

This change improves performance on certain kinds of transactions
such as UPDATEs by allowing SQLite to make stronger assumptions
about data integrity on the disk.

The powersafe overwrite assumption demands that when a byte is
written to a file and a power event occurs then the only bytes
that may have been modified are the ones that were being written.

In absense of the powersafe overwrite assumption, SQLite assumes
that a write of any range of bytes within a disk sector may
potentially cause the rest of the sector to be corrupted.  SQLite
needs to do extra work to compensate for this problem, which adds
overhead to certain transactions.

On flash devices, writing a byte causes the sector to be rewritten
somewhere else on the device.  Eventually the old sector may be
erased and reused.  The powersafe overwrite assumption therefore
holds as long as the flash device never leaves behind (observable)
half-written sectors in case of a power event.  This is a fairly
safe assumption to make.  Some flash devices apparently include
measures to ensure that the last write fully completes when
power is interrupted.  In any case, the window of opportunity
for corruption to occur is very small.

Bug: 6484633
Change-Id: I0b0ef664b3a2a0e85c6099f0130d0affc5562be5
  • Loading branch information...
1 parent c82acac commit 2d758ba484351cd86f3f551c3a788255d2e8d9d0 @j9brown j9brown committed May 11, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 dist/Android.mk
View
@@ -17,7 +17,7 @@ common_sqlite_flags := \
-DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 \
-DSQLITE_THREADSAFE=2 \
-DSQLITE_TEMP_STORE=3 \
- -DSQLITE_POWERSAFE_OVERWRITE=0 \
+ -DSQLITE_POWERSAFE_OVERWRITE=1 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_DEFAULT_AUTOVACUUM=1 \
-DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 \

0 comments on commit 2d758ba

Please sign in to comment.