Commit ccc76472 authored by Victor Costan's avatar Victor Costan Committed by Commit Bot

sql: Use 64-bit integers to collect SQLite memory usage.

The MemoryDumpProvider API uses 64-bit integers. For consistency, use
SQLite's 64-bit API (sqlite_status64) to obtain memory usage statistics
from SQLite.

This CL also documents the SQLite build configuration setting assumed by
the memory usage reporting code. The value needed by the memory
reporting code is (currently) the default. However, the SQLite
docs [1] recommend a different value, so documenting our needs makes it
less likely that we'll accidentally end up with an incorrect
configuration.

Change-Id: I15217e11bce8d167dce65db345ddf78d21148144
Reviewed-on: https://chromium-review.googlesource.com/1146293Reviewed-by: default avatarChris Mumford <cmumford@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577260}
parent 1490393e
......@@ -24,10 +24,10 @@ SqlMemoryDumpProvider::~SqlMemoryDumpProvider() = default;
bool SqlMemoryDumpProvider::OnMemoryDump(
const base::trace_event::MemoryDumpArgs& args,
base::trace_event::ProcessMemoryDump* pmd) {
int memory_used = 0;
int memory_high_water = 0;
int status = sqlite3_status(SQLITE_STATUS_MEMORY_USED, &memory_used,
&memory_high_water, 1 /*resetFlag */);
sqlite3_int64 memory_used = 0;
sqlite3_int64 memory_high_water = 0;
int status = sqlite3_status64(SQLITE_STATUS_MEMORY_USED, &memory_used,
&memory_high_water, /* resetFlag= */ 1);
if (status != SQLITE_OK)
return false;
......@@ -40,10 +40,10 @@ bool SqlMemoryDumpProvider::OnMemoryDump(
base::trace_event::MemoryAllocatorDump::kUnitsBytes,
memory_high_water);
int dummy_high_water = -1;
int malloc_count = -1;
status = sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &malloc_count,
&dummy_high_water, 0 /* resetFlag */);
sqlite3_int64 dummy_high_water = -1;
sqlite3_int64 malloc_count = -1;
status = sqlite3_status64(SQLITE_STATUS_MALLOC_COUNT, &malloc_count,
&dummy_high_water, /* resetFlag= */ 0);
if (status == SQLITE_OK) {
dump->AddScalar("malloc_count",
base::trace_event::MemoryAllocatorDump::kUnitsObjects,
......
......@@ -56,6 +56,13 @@ config("chromium_sqlite3_compile_options") {
# TODO(pwnall): Upstream the ability to use this define.
"SQLITE_MMAP_READ_ONLY=1",
# Needed by the SQL MemoryDumpProvider.
#
# Setting this to 1 is needed to collect the information reported by
# sqlite3_status64(SQLITE_STATUS_MEMORY_USED). Without this setting, the API
# still exists, but does not work as promised.
"SQLITE_DEFAULT_MEMSTATUS=1",
# By default SQLite pre-allocates 100 pages of pcache data, which will not
# be released until the handle is closed. This is contrary to Chromium's
# memory-usage goals.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment