diff options
author | Tiancong Wang <tcwang@google.com> | 2020-02-13 20:58:20 +0000 |
---|---|---|
committer | Tiancong Wang <tcwang@google.com> | 2020-02-13 20:58:20 +0000 |
commit | e617e3393dd24003aa976ece5050bb291070041c (patch) | |
tree | 35fa0fbaeaaddd9cc2a126a05eee3527b51e83a8 /deprecated/mem_tests/README.md | |
parent | 3c0fcaf157c060979b09c0d8e7a982ff5d1acdab (diff) | |
parent | 2a19d36a82a612f4a77249ac39b7a0b22c2bafc4 (diff) | |
download | toolchain-utils-e617e3393dd24003aa976ece5050bb291070041c.tar.gz |
Merging 18 commit(s) from Chromium's toolchain-utils am: 0ae38c8498 am: 2a19d36a82
Change-Id: If9b258fea573c36eed78a3f6657669ea1adb115d
Diffstat (limited to 'deprecated/mem_tests/README.md')
-rw-r--r-- | deprecated/mem_tests/README.md | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/deprecated/mem_tests/README.md b/deprecated/mem_tests/README.md new file mode 100644 index 00000000..44bf16c9 --- /dev/null +++ b/deprecated/mem_tests/README.md @@ -0,0 +1,52 @@ +# Memory tests + +## Usage + +These scripts are made to parse TCMalloc output in order to extract certain +info from them. + +In particular, these scripts rely on the error logging system for ChromeOS in +order to extract information. In order to use a script (e.g. `total_mem.py`), +you just have the command: + +``` +./total_mem.py FILENAME +``` + +where `FILENAME` is the name of the log file to be parsed. + +## Codebase Changes + +There are two ideas that motivate these changes: + +1. Turn on TCMalloc sampling. +2. Use perf to collect the sample information. + + +The following files have to be changed: + +in `chrome/browser/metrics/perf_provider_chrome_os`, add: + +``` +#include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" +``` + +Change the perf profiling interval to something small (60*1000 milliseconds). + +Inside DoPeriodicCollection, insert the following code: + +``` +std::string output; +char* chr_arr = new char[9999]; +MallocExtension::instance() ->GetHeapSample(&output); +MallocExtension::instance() ->GetStats(chr_arr, 9999); +LOG(ERROR) << "Output Heap Data: "; +LOG(ERROR) << output; +LOG(ERROR) << "Output Heap Stats: "; +output = ""; +for (unsigned int i = 0; i < strlen(chr_arr); i++) { + output += chr_arr[i]; +} +LOG(ERROR) << output; +delete[] chr_arr; +``` |