mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 385834 don't do incremental vacuuming, makes fragmentation worse [was: places' sqlite file can get overly large, do incremental vacuuming] (r=sspitzer)
This commit is contained in:
parent
d717255ca2
commit
c4d846ebec
@ -151,10 +151,12 @@
|
|||||||
|
|
||||||
#endif // LAZY_ADD
|
#endif // LAZY_ADD
|
||||||
|
|
||||||
|
// check idle timer every 5 minutes
|
||||||
|
#define IDLE_TIMER_TIMEOUT (300 * PR_MSEC_PER_SEC)
|
||||||
|
|
||||||
|
// perform vacuum every 15 mins *** CURRENTLY DISABLED ***
|
||||||
// 15 minutes = 900 seconds = 900000 milliseconds
|
// 15 minutes = 900 seconds = 900000 milliseconds
|
||||||
#define VACUUM_IDLE_TIME_IN_MSECS (900000)
|
#define VACUUM_IDLE_TIME_IN_MSECS (900000)
|
||||||
// check every 5 minutes
|
|
||||||
#define VACUUM_TIMER_TIMEOUT (300 * PR_MSEC_PER_SEC)
|
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsNavHistory)
|
NS_IMPL_ADDREF(nsNavHistory)
|
||||||
NS_IMPL_RELEASE(nsNavHistory)
|
NS_IMPL_RELEASE(nsNavHistory)
|
||||||
@ -520,18 +522,12 @@ nsNavHistory::InitDB(PRBool *aDoImport)
|
|||||||
rv = mDBConn->ExecuteSimpleSQL(pageSizePragma);
|
rv = mDBConn->ExecuteSimpleSQL(pageSizePragma);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// Set the database up for incremental vacuuming.
|
if (!mIdleTimer) {
|
||||||
// if the database was created before we started doing
|
mIdleTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
||||||
// incremental vacuuming, this will have no effect.
|
|
||||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("PRAGMA auto_vacuum=2"));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
if (!mVacuumTimer) {
|
|
||||||
mVacuumTimer = do_CreateInstance("@mozilla.org/timer;1", &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
rv = mVacuumTimer->InitWithFuncCallback(VacuumTimerCallback, this,
|
rv = mIdleTimer->InitWithFuncCallback(IdleTimerCallback, this,
|
||||||
VACUUM_TIMER_TIMEOUT,
|
IDLE_TIMER_TIMEOUT,
|
||||||
nsITimer::TYPE_REPEATING_SLACK);
|
nsITimer::TYPE_REPEATING_SLACK);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
@ -3401,7 +3397,7 @@ nsNavHistory::AddDocumentRedirect(nsIChannel *aOldChannel,
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsNavHistory::PerformVacuumIfIdle()
|
nsNavHistory::OnIdle()
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
nsCOMPtr<nsIIdleService> idleService =
|
nsCOMPtr<nsIIdleService> idleService =
|
||||||
@ -3412,47 +3408,26 @@ nsNavHistory::PerformVacuumIfIdle()
|
|||||||
rv = idleService->GetIdleTime(&idleTime);
|
rv = idleService->GetIdleTime(&idleTime);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
// if we've been idle for more than VACUUM_IDLE_TIME_IN_MSECS
|
// If we've been idle for more than VACUUM_IDLE_TIME_IN_MSECS
|
||||||
// incrementally vacuum
|
// perform a vacuum.
|
||||||
if (idleTime > VACUUM_IDLE_TIME_IN_MSECS) {
|
if (idleTime > VACUUM_IDLE_TIME_IN_MSECS) {
|
||||||
PRInt32 vacuum;
|
|
||||||
nsCOMPtr<mozIStorageStatement> statement;
|
|
||||||
rv = mDBConn->CreateStatement(NS_LITERAL_CSTRING("PRAGMA auto_vacuum"),
|
|
||||||
getter_AddRefs(statement));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
PRBool hasResult;
|
|
||||||
rv = statement->ExecuteStep(&hasResult);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
NS_ENSURE_TRUE(hasResult, NS_ERROR_FAILURE);
|
|
||||||
vacuum = statement->AsInt32(0);
|
|
||||||
|
|
||||||
// if our database was created with incremental_vacuum,
|
|
||||||
// do incremental vacuuming
|
|
||||||
if (vacuum == 2) {
|
|
||||||
rv = mDBConn->ExecuteSimpleSQL(
|
|
||||||
NS_LITERAL_CSTRING("PRAGMA incremental_vacuum;"));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#if 0
|
#if 0
|
||||||
// Currently commented out because compression is very slow
|
// Currently commented out because compression is very slow
|
||||||
// see bug #390244 for more details
|
// see bug #390244 for more details
|
||||||
// if our database was created before incremental vacuuming
|
// if our database was created before incremental vacuuming
|
||||||
// do a full vacuum on idle
|
// do a full vacuum on idle
|
||||||
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("VACUUM;"));
|
rv = mDBConn->ExecuteSimpleSQL(NS_LITERAL_CSTRING("VACUUM;"));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void // static
|
void // static
|
||||||
nsNavHistory::VacuumTimerCallback(nsITimer* aTimer, void* aClosure)
|
nsNavHistory::IdleTimerCallback(nsITimer* aTimer, void* aClosure)
|
||||||
{
|
{
|
||||||
nsNavHistory* history = static_cast<nsNavHistory*>(aClosure);
|
nsNavHistory* history = static_cast<nsNavHistory*>(aClosure);
|
||||||
(void)history->PerformVacuumIfIdle();
|
(void)history->OnIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// nsIObserver *****************************************************************
|
// nsIObserver *****************************************************************
|
||||||
@ -3462,9 +3437,9 @@ nsNavHistory::Observe(nsISupports *aSubject, const char *aTopic,
|
|||||||
const PRUnichar *aData)
|
const PRUnichar *aData)
|
||||||
{
|
{
|
||||||
if (nsCRT::strcmp(aTopic, gQuitApplicationMessage) == 0) {
|
if (nsCRT::strcmp(aTopic, gQuitApplicationMessage) == 0) {
|
||||||
if (mVacuumTimer) {
|
if (mIdleTimer) {
|
||||||
mVacuumTimer->Cancel();
|
mIdleTimer->Cancel();
|
||||||
mVacuumTimer = nsnull;
|
mIdleTimer = nsnull;
|
||||||
}
|
}
|
||||||
if (mAutoCompleteTimer) {
|
if (mAutoCompleteTimer) {
|
||||||
mAutoCompleteTimer->Cancel();
|
mAutoCompleteTimer->Cancel();
|
||||||
|
@ -610,9 +610,9 @@ protected:
|
|||||||
// updating during import.
|
// updating during import.
|
||||||
nsresult CreateLookupIndexes();
|
nsresult CreateLookupIndexes();
|
||||||
|
|
||||||
nsresult PerformVacuumIfIdle();
|
nsCOMPtr<nsITimer> mIdleTimer;
|
||||||
nsCOMPtr<nsITimer> mVacuumTimer;
|
static void IdleTimerCallback(nsITimer* aTimer, void* aClosure);
|
||||||
static void VacuumTimerCallback(nsITimer* aTimer, void* aClosure);
|
nsresult OnIdle();
|
||||||
|
|
||||||
PRInt64 mTagRoot;
|
PRInt64 mTagRoot;
|
||||||
PRInt64 GetTagRoot();
|
PRInt64 GetTagRoot();
|
||||||
|
Loading…
Reference in New Issue
Block a user