Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(545)

Unified Diff: sql/connection.cc

Issue 1327063002: [tracing] Add sqlite memory statistics to tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index 3f37b90cc71fd059b4eef51ad6a79d47608a1b4b..2c570f26a15419fbe7277498a8873ee58bb603ab 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -19,6 +19,8 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/synchronization/lock.h"
+#include "base/trace_event/memory_dump_manager.h"
+#include "base/trace_event/process_memory_dump.h"
#include "sql/statement.h"
#include "third_party/sqlite/sqlite3.h"
@@ -217,6 +219,39 @@ bool Connection::ShouldIgnoreSqliteError(int error) {
return current_ignorer_cb_->Run(error);
}
+bool Connection::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
+ base::trace_event::ProcessMemoryDump* pmd) {
+ if (args.level_of_detail ==
+ base::trace_event::MemoryDumpArgs::LevelOfDetail::LOW)
+ return true;
+
+ int cache_size, dummy_int;
+ sqlite3_db_status(db_, SQLITE_DBSTATUS_CACHE_USED, &cache_size, &dummy_int,
Primiano Tucci (use gerrit) 2015/09/30 10:26:56 why not dumping also the high watermarks (your dum
ssid 2015/10/02 17:06:10 The high water mark is not tracked by the sqlite l
+ 0 /* resetFlag */);
+ int schema_size;
+ sqlite3_db_status(db_, SQLITE_DBSTATUS_SCHEMA_USED, &schema_size, &dummy_int,
+ 0 /* resetFlag */);
+ int statement_size;
+ sqlite3_db_status(db_, SQLITE_DBSTATUS_STMT_USED, &statement_size, &dummy_int,
+ 0 /* resetFlag */);
+
+ base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(
+ base::StringPrintf("sqlite/connection_%p", this));
+ dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ cache_size + schema_size + statement_size);
+ dump->AddScalar("cache_size",
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ cache_size);
+ dump->AddScalar("schema_size",
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ schema_size);
+ dump->AddScalar("statement_size",
+ base::trace_event::MemoryAllocatorDump::kUnitsBytes,
+ statement_size);
+ return true;
+}
+
// static
void Connection::SetErrorIgnorer(Connection::ErrorIgnorerCallback* cb) {
CHECK(current_ignorer_cb_ == NULL);
@@ -288,9 +323,13 @@ Connection::Connection()
update_time_histogram_(NULL),
query_time_histogram_(NULL),
clock_(new TimeSource()) {
+ base::trace_event::MemoryDumpManager::GetInstance()->RegisterDumpProvider(
+ this);
}
Connection::~Connection() {
+ base::trace_event::MemoryDumpManager::GetInstance()->UnregisterDumpProvider(
+ this);
Close();
}

Powered by Google App Engine
This is Rietveld 408576698