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

Side by Side Diff: third_party/tcmalloc/chromium/src/deep-memory-profiler.h

Issue 7865021: Deep-Memory-Profiler (DMP) implementation (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fixed bugs Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « base/allocator/allocator.gyp ('k') | third_party/tcmalloc/chromium/src/deep-memory-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #ifndef BASE_DEEP_MEMORY_PROFILER_H_
5 #define BASE_DEEP_MEMORY_PROFILER_H_
6
7 #include "addressmap-inl.h"
8 #include "heap-profile-table.h"
9
10 class DeepMemoryProfiler {
11 public:
12 typedef HeapProfileTable::Bucket Bucket;
13 typedef HeapProfileTable::AllocationMap AllocationMap;
14 typedef HeapProfileTable::AllocValue AllocValue;
15 typedef HeapProfileTable::Stats Stats;
16
17 DeepMemoryProfiler(HeapProfileTable* heap_profile, const char* prefix);
18 ~DeepMemoryProfiler();
19
20 // This replaces the same function in heap-profile-table.h
21 int FillOrderedProfile(char buf[], int size);
22 private:
23 struct PageState {
24 bool is_committed; // Currently, we use only this
25 bool is_present;
26 bool is_swapped;
27 bool is_shared;
28 bool is_mmap;
29 };
30
31 typedef AddressMap<PageState> PageStateMap;
32
33 // Functions for opening, seeking, reading /proc/pid/pagemap
34 void OpenPageMap();
35 bool PageMapSeek(uint64 addr);
36 bool PageMapRead(PageState* state);
37 uint64 GetCommittedSize(uint64 addr, uint64 size);
38
39 // This represents a single line of /proc/self/maps
40 struct RegionValue {
41 uint64 start;
42 uint64 end;
43 uint64 size;
44 uint64 committed_size;
45 uint64 recorded_size;
46 uint64 recorded_committed_size;
47 char permissions[5];
48 char filename[1000];
49 };
50
51 typedef AddressMap<RegionValue> RegionMap;
52 RegionMap* regions_; // Map of all regions
53 uint64 max_region_size_; // Max size of regions
54
55 struct RegionStats {
56 int64 virtual_bytes;
57 int64 committed_bytes;
58 };
59
60 struct GlobalStats {
61 RegionStats total;
62 RegionStats file_mapped;
63 RegionStats anonymous;
64 RegionStats other;
65 RegionStats record_mmap;
66 RegionStats record_tcmalloc;
67 };
68
69 void InitRegionStats(RegionStats* stats);
70 void RecordRegionStats(uint64 start, uint64 end, RegionStats* stats);
71 void GetGlobalStats();
72 static size_t GetRegionSize(const RegionValue& rv) { return rv.size; }
73 void RecordAllocInRegions(uint64 addr, uint64 size);
74
75 // Record the committed memory size of each allocations
76 static void RecordAlloc(const void* ptr, AllocValue* v,
77 DeepMemoryProfiler* deep_profiler);
78 void RecordAllAllocs();
79
80 struct BufferArgs {
81 char* buf;
82 int size;
83 int len;
84 };
85
86 static void WriteLeakyRegion(const void* ptr,
87 RegionValue* rv,
88 BufferArgs* buffer);
89 void WriteAllLeakyRegions();
90
91 void WriteMapsToFile(char buf[], int size);
92 int WriteBucket(const Bucket* b, char buf[], int bufsize);
93 void WriteBucketsToFile();
94
95 static int UnparseBucket(const Bucket& b,
96 char* buf, int buflen, int bufsize,
97 const char* extra,
98 Stats* profile_stats);
99
100 static int UnparseRegionStats(const RegionStats* stats, const char* name,
101 char* buf, int buflen, int bufsize);
102
103 int UnparseGlobalStats(char* buf, int buflen, int bufsize);
104
105 HeapProfileTable* heap_profile_;
106
107 int pagemap_fd_; // File descriptor of /proc/self/pagemap
108 int kpageflags_fd_; // File descriptor of /proc/kpageflags
109 pid_t most_recent_pid_; // Process ID of the last dump. This could change.
110 GlobalStats stats_; // Stats about total memory
111 PageStateMap* page_map_; // Map for holding status of allocations in page
112 int dump_count_; // The number of dumps
113 char* filename_prefix_; // Output file prefix
114 char* profiler_buffer_; // Buffer we use many times
115 bool recording_mmap_; // True if we are recording mmap, not tcmalloc
116 };
117
118 #endif // BASE_DEEP_MEMORY_PROFILER_H_
OLDNEW
« no previous file with comments | « base/allocator/allocator.gyp ('k') | third_party/tcmalloc/chromium/src/deep-memory-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698