Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Enable the powersafe overwrite assumption.
Browse files Browse the repository at this point in the history
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
Jeff Brown committed May 11, 2012
1 parent c82acac commit 2d758ba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dist/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 2d758ba

Please sign in to comment.