Bug 575667 - split about:memory reporting into more detailed sections for SQLite
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Thu, 22 Jul 2010 10:08:59 -0700
changeset 48084 c4720f6b9be428082f5ece624c63726a9ef692ac
parent 48083 0eee576149df2c8cee028b950a77c1a00707d224
child 48085 0dc03dd97a06de3f653ff076c932446853066c90
push id14564
push usersdwilsh@shawnwilsher.com
push dateThu, 22 Jul 2010 17:09:24 +0000
treeherdermozilla-central@c4720f6b9be4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs575667
milestone2.0b3pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 575667 - split about:memory reporting into more detailed sections for SQLite r=vlad a=vlad
db/sqlite3/src/sqlite.def
storage/src/mozStorageService.cpp
--- a/db/sqlite3/src/sqlite.def
+++ b/db/sqlite3/src/sqlite.def
@@ -147,16 +147,17 @@ EXPORTS
         sqlite3_result_value
         sqlite3_rollback_hook
         sqlite3_set_authorizer
         sqlite3_set_auxdata
         sqlite3_shutdown
         sqlite3_sleep
         sqlite3_snprintf
         sqlite3_sql
+        sqlite3_status
         sqlite3_step
         sqlite3_stmt_status
         sqlite3_thread_cleanup
         sqlite3_total_changes
         sqlite3_trace
         sqlite3_transfer_bindings
         sqlite3_unlock_notify
         sqlite3_update_hook
--- a/storage/src/mozStorageService.cpp
+++ b/storage/src/mozStorageService.cpp
@@ -59,36 +59,59 @@
 #include "nsIMemoryReporter.h"
 
 #include "mozilla/FunctionTimer.h"
 
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
+//// Memory Reporting
+
+static PRInt64
+GetStorageSQLitePageCacheMemoryUsed(void *)
+{
+  int current, high;
+  int rc = ::sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &current, &high,
+                            0);
+  return rc == SQLITE_OK ? current : 0;
+}
+
+static PRInt64
+GetStorageSQLiteOtherMemoryUsed(void *)
+{
+  int pageCacheCurrent, pageCacheHigh;
+  int rc = ::sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &pageCacheCurrent,
+                            &pageCacheHigh, 0);
+  return rc == SQLITE_OK ? ::sqlite3_memory_used() - pageCacheCurrent : 0;
+}
+
+NS_MEMORY_REPORTER_IMPLEMENT(StorageSQLitePageCacheMemoryUsed,
+                             "storage/sqlite/pagecache",
+                             "Memory in use by SQLite for the page cache",
+                             GetStorageSQLitePageCacheMemoryUsed,
+                             nsnull)
+
+NS_MEMORY_REPORTER_IMPLEMENT(StorageSQLiteOtherMemoryUsed,
+                             "storage/sqlite/other",
+                             "Memory in use by SQLite for other various reasons",
+                             GetStorageSQLiteOtherMemoryUsed,
+                             nsnull)
+
+////////////////////////////////////////////////////////////////////////////////
 //// Service
 
 NS_IMPL_THREADSAFE_ISUPPORTS2(
   Service,
   mozIStorageService,
   nsIObserver
 )
 
 Service *Service::gService = nsnull;
 
-static PRInt64 GetStorageSQLiteMemoryUsed(void *) {
-  return sqlite3_memory_used();
-}
-
-NS_MEMORY_REPORTER_IMPLEMENT(StorageSQLiteMemoryUsed,
-                             "storage/sqlite",
-                             "Memory in use by SQLite",
-                             GetStorageSQLiteMemoryUsed,
-                             nsnull)
-
 Service *
 Service::getSingleton()
 {
   if (gService) {
     NS_ADDREF(gService);
     return gService;
   }
 
@@ -110,17 +133,18 @@ Service::getSingleton()
 
   gService = new Service();
   if (gService) {
     NS_ADDREF(gService);
     if (NS_FAILED(gService->initialize()))
       NS_RELEASE(gService);
   }
 
-  NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLiteMemoryUsed));
+  NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLitePageCacheMemoryUsed));
+  NS_RegisterMemoryReporter(new NS_MEMORY_REPORTER_NAME(StorageSQLiteOtherMemoryUsed));
 
   return gService;
 }
 
 nsIXPConnect *Service::sXPConnect = nsnull;
 
 already_AddRefed<nsIXPConnect>
 Service::getXPConnect()