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

Side by Side Diff: sql/process_memory_dump_provider.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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "sql/process_memory_dump_provider.h"
6
7 #include "base/trace_event/memory_dump_manager.h"
8 #include "base/trace_event/process_memory_dump.h"
9 #include "third_party/sqlite/sqlite3.h"
10
11 namespace sql {
12
13 // static
14 ProcessMemoryDumpProvider* ProcessMemoryDumpProvider::GetInstance() {
15 return Singleton<ProcessMemoryDumpProvider,
16 LeakySingletonTraits<ProcessMemoryDumpProvider>>::get();
17 }
18
19 ProcessMemoryDumpProvider::ProcessMemoryDumpProvider() {}
20
21 ProcessMemoryDumpProvider::~ProcessMemoryDumpProvider() {}
22
23 bool ProcessMemoryDumpProvider::OnMemoryDump(
24 const base::trace_event::MemoryDumpArgs& args,
25 base::trace_event::ProcessMemoryDump* pmd) {
26 int dummy_high_water = -1;
27 int status;
28 int memory_used = -1;
29 status = sqlite3_status(SQLITE_STATUS_MEMORY_USED, &memory_used,
30 &dummy_high_water, 0 /* resetFlag */);
Primiano Tucci (use gerrit) 2015/09/30 10:26:56 ditto: report also the high water mark. Also, dumm
ssid 2015/10/02 17:06:10 I was actually dumping the high water using differ
31 if (status != SQLITE_OK)
32 return false;
33
34 int scratch_size = -1;
35 status = sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &scratch_size,
36 &dummy_high_water, 0 /* resetFlag */);
37 if (status != SQLITE_OK)
38 return false;
39
40 base::trace_event::MemoryAllocatorDump* dump =
41 pmd->CreateAllocatorDump("sqlite");
42 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
43 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
44 memory_used + scratch_size);
45
46 dump->AddScalar("scratch_size",
47 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
48 scratch_size);
49 dump->AddScalar("sqlite_malloc_size",
Primiano Tucci (use gerrit) 2015/09/30 10:26:56 sqlite_ prefix here seems redundant. This is alrea
ssid 2015/10/02 17:06:10 removed this since it was actually the total.
50 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
51 memory_used);
52 dump->AddScalar("high_water_malloc",
Primiano Tucci (use gerrit) 2015/09/30 10:26:56 I'd call this malloc_high_wmark_size if you to kee
ssid 2015/10/02 17:06:10 Done.
53 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
54 sqlite3_memory_highwater(1 /*resetFlag */));
55
56 int cache_page_count = -1;
57 status = sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &cache_page_count,
58 &dummy_high_water, 0 /* resetFlag */);
59 if (status == SQLITE_OK) {
60 dump->AddScalar("cache_pages",
61 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
Primiano Tucci (use gerrit) 2015/09/30 10:26:56 Hmm not sure the number of pages is really relevan
ssid 2015/10/02 17:06:10 hm no. I don't find any way to get the sizes. I re
Primiano Tucci (use gerrit) 2015/10/06 16:21:21 Maybe check with OWNERS. If that is actually using
62 cache_page_count);
63 }
64
65 int malloc_count = -1;
66 status = sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &malloc_count,
67 &dummy_high_water, 0 /* resetFlag */);
68 if (status == SQLITE_OK) {
69 dump->AddScalar("malloc_count",
70 base::trace_event::MemoryAllocatorDump::kUnitsObjects,
71 malloc_count);
72 }
73
74 const char* system_allocator_name =
75 base::trace_event::MemoryDumpManager::GetInstance()
76 ->system_allocator_pool_name();
77 if (system_allocator_name) {
78 pmd->AddSuballocation(dump->guid(), system_allocator_name);
Primiano Tucci (use gerrit) 2015/09/30 10:26:56 Are you sure that all the scratch + pagecache are
ssid 2015/10/02 17:06:10 Sorry about the scratch, I misunderstood. Yes sqli
79 }
80 return true;
81 }
82
83 } // namespace sql
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698