README
1Usage
2-----
3
4These scripts are made to parse TCMalloc output in order to extract certain
5info from them.
6
7In particular, these scripts rely on the error logging system for ChromeOS in
8order to extract information. In order to use a script (e.g. total_mem.py), you
9just have the command:
10
11./total_mem.py FILENAME
12
13where FILENAME is the name of the log file to be parsed.
14
15Codebase Changes
16----------------
17
18There are two ideas that motivate these changes:
19
201- Turn on TCMalloc sampling.
212- Use perf to collect the sample information.
22
23The following files have to be changed:
24
25in chrome/browser/metrics/perf_provider_chrome_os:
26
27add:
28 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
29
30Change the perf profiling interval to something small (60*1000 milliseconds).
31
32inside DoPeriodicCollection, insert the following code:
33
34 std::string output;
35 char* chr_arr = new char[9999];
36 MallocExtension::instance() ->GetHeapSample(&output);
37 MallocExtension::instance() ->GetStats(chr_arr, 9999);
38 LOG(ERROR) << "Output Heap Data: ";
39 LOG(ERROR) << output;
40 LOG(ERROR) << "Output Heap Stats: ";
41 output = "";
42 for (unsigned int i = 0; i < strlen(chr_arr); i++) {
43 output += chr_arr[i];
44 }
45 LOG(ERROR) << output;
46 delete[] chr_arr;
47