Bug 1126129 - Only enable SQLite tracing when the right environment variable is set. r=asuth, a=sledru
authorBen Turner <bent.mozilla@gmail.com>
Mon, 26 Jan 2015 19:38:49 -0800
changeset 243073 e26bc7acea8e
parent 243072 8b4f59c3ae71
child 243074 f9d1601a87b1
push id4382
push userryanvm@gmail.com
push date2015-01-28 14:58 +0000
treeherdermozilla-beta@f35aa2298df8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth, sledru
bugs1126129
milestone36.0
Bug 1126129 - Only enable SQLite tracing when the right environment variable is set. r=asuth, a=sledru
storage/src/mozStorageConnection.cpp
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -642,23 +642,27 @@ Connection::initializeInternal(nsIFile* 
 {
   // Properly wrap the database handle's mutex.
   sharedDBMutex.initWithMutex(sqlite3_db_mutex(mDBConn));
 
 #ifdef PR_LOGGING
   if (!gStorageLog)
     gStorageLog = ::PR_NewLogModule("mozStorage");
 
-  ::sqlite3_trace(mDBConn, tracefunc, this);
+  // SQLite tracing can slow down queries (especially long queries)
+  // significantly. Don't trace unless the user is actively monitoring SQLite.
+  if (PR_LOG_TEST(gStorageLog, PR_LOG_DEBUG)) {
+    ::sqlite3_trace(mDBConn, tracefunc, this);
 
-  nsAutoCString leafName(":memory");
-  if (aDatabaseFile)
-    (void)aDatabaseFile->GetNativeLeafName(leafName);
-  PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Opening connection to '%s' (%p)",
-                                      leafName.get(), this));
+    nsAutoCString leafName(":memory");
+    if (aDatabaseFile)
+      (void)aDatabaseFile->GetNativeLeafName(leafName);
+    PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Opening connection to '%s' (%p)",
+                                        leafName.get(), this));
+  }
 #endif
 
   int64_t pageSize = Service::getDefaultPageSize();
 
   // Set page_size to the preferred default value.  This is effective only if
   // the database has just been created, otherwise, if the database does not
   // use WAL journal mode, a VACUUM operation will updated its page_size.
   nsAutoCString pageSizeQuery(MOZ_STORAGE_UNIQUIFY_QUERY_STR