Skip to content

Commit

Permalink
Bug 1834043 - Add a configure option to disable Sqlite auxiliary file…
Browse files Browse the repository at this point in the history
…s persistence. r=glandium,tjr

Not using a pref because Storage has connections using helper threads and the
main thread, thus we prefer to avoid mutex costs for a pref we'll likely not
use in Firefox. Also using a "once" pref would require some coordination because
Storage may try to lazy init once prefs from different threads concurrently,
causing potential deadlocks.

Differential Revision: https://phabricator.services.mozilla.com/D183724
  • Loading branch information
mak77 committed Aug 1, 2023
1 parent f104bcd commit ae32ce0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion browser/config/mozconfigs/win32/mingwclang
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ ac_add_options --with-toolchain-prefix=i686-w64-mingw32-
ac_add_options --disable-warnings-as-errors
mk_add_options "export WIDL_TIME_OVERRIDE=0"

# This replicates Tor's configuration
# These replicate Tor's configuration
ac_add_options --enable-proxy-bypass-protection
ac_add_options --enable-disk-remnant-avoidance

# These aren't supported on mingw at this time
ac_add_options --disable-webrtc # Bug 1393901
Expand Down
3 changes: 2 additions & 1 deletion browser/config/mozconfigs/win64/mingwclang
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ ac_add_options --with-toolchain-prefix=x86_64-w64-mingw32-
ac_add_options --disable-warnings-as-errors
mk_add_options "export WIDL_TIME_OVERRIDE=0"

# This replicates Tor's configuration
# These replicate Tor's configuration
ac_add_options --enable-proxy-bypass-protection
ac_add_options --enable-disk-remnant-avoidance

# These aren't supported on mingw at this time
ac_add_options --disable-webrtc # Bug 1393901
Expand Down
2 changes: 2 additions & 0 deletions storage/BaseVFS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ int BaseCheckReservedLock(sqlite3_file* pFile, int* pResOut) {
}

int BaseFileControl(sqlite3_file* pFile, int op, void* pArg) {
#if defined(MOZ_SQLITE_PERSIST_AUXILIARY_FILES)
// Persist auxiliary files (-shm and -wal) on disk, because creating and
// deleting them may be expensive on slow storage.
// Only do this when there is a journal size limit, so the journal is
Expand All @@ -96,6 +97,7 @@ int BaseFileControl(sqlite3_file* pFile, int op, void* pArg) {
*static_cast<int*>(pArg) = 1;
return SQLITE_OK;
}
#endif
BaseFile* p = (BaseFile*)pFile;
return p->pReal->pMethods->xFileControl(p->pReal, op, pArg);
}
Expand Down
4 changes: 4 additions & 0 deletions storage/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ if CONFIG["MOZ_THUNDERBIRD"] or CONFIG["MOZ_SUITE"]:
# will need to change it here as well.
DEFINES["SQLITE_MAX_LIKE_PATTERN_LENGTH"] = 50000

# Disable auxiliary files persistence if requested.
if not CONFIG["MOZ_AVOID_DISK_REMNANT_ON_CLOSE"]:
DEFINES["MOZ_SQLITE_PERSIST_AUXILIARY_FILES"] = 1

LOCAL_INCLUDES += [
"/dom/base",
"/third_party/sqlite3/src",
Expand Down
16 changes: 16 additions & 0 deletions toolkit/moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -2707,6 +2707,22 @@ set_config("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)
set_define("MOZ_NEW_NOTIFICATION_STORE", True, when=new_notification_store)


# Auxiliary files persistence on application close
# ==============================================================

option(
"--enable-disk-remnant-avoidance",
help="Prevent persistence of auxiliary files on application close",
)


set_config(
"MOZ_AVOID_DISK_REMNANT_ON_CLOSE",
True,
when="--enable-disk-remnant-avoidance",
)


# Glean SDK Integration Crate
# ==============================================================

Expand Down

0 comments on commit ae32ce0

Please sign in to comment.