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

Issue 323893002: [Android] Introduce libheap_profiler for memory profiling. (Closed)

Created:
6 years, 6 months ago by Primiano Tucci (use gerrit)
Modified:
6 years, 5 months ago
CC:
chromium-reviews, klundberg+watch_chromium.org, bulach+watch_chromium.org, yfriedman+watch_chromium.org, ilevy-cc_chromium.org, bulach, Philippe
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Visibility:
Public.

Description

[Android] Introduce libheap_profiler for memory profiling. libheap_profiler is a standalone, dependency free and efficient library aimed to profile memory allocations. In a nutshell it is a replacement for Android's libc.debug.malloc (which is terribly broken, see the BUG). This change introduces three new targets: - libheap_profiler.so: the snoopy library which tracks allocation info. - heap_dump: executable to dump the allocation info for a given process. - heap_profiler_unittests: because everybody loves unittests. Goals: - Be fast and efficient: the lib intended to be preloaded in the Zygote and trace bulky processes like Chrome. - Hook calls to mmap and malloc and grab stack traces associated to them. - Don't tie particularly to Android, so it can be reused later for Linux. - Be extensible, in the sense that allocations made by custom allocators, can be individually visible (instead of just all their mmaped arenas). - JSON output, as it is meant to be consumed by other tools, not humans. At the moment, this CL introduces support just for Android. BUG=382489 NOTRY=true Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=281542

Patch Set 1 #

Total comments: 8

Patch Set 2 : s/hdump/heap_dump/, simplify JSON, refactor heap_dump main #

Total comments: 20

Patch Set 3 : Remove EXPORT from API decl, not needed #

Total comments: 3

Patch Set 4 : Add integration tests + pasko comments #

Total comments: 8

Patch Set 5 : Address pasko@#13 + rebase against move trees in 323873004 #

Total comments: 24

Patch Set 6 : Nits #

Total comments: 21

Patch Set 7 : address bulach@ review #

Total comments: 8

Patch Set 8 : Test refactor (bulach@ + pasko@) #

Patch Set 9 : Fix gyp files #

Patch Set 10 : git cl format FTW #

Patch Set 11 : Fix gyp #

Total comments: 4

Patch Set 12 : typedef for bulach@ #

Total comments: 2

Patch Set 13 : Re-refactor test + git cl format #

Total comments: 7

Patch Set 14 : s/vma/alloc/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1717 lines, -0 lines) Patch
M tools/android/android_tools.gyp View 1 2 3 4 5 6 7 8 9 10 1 chunk +8 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/DEPS View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/heap_dump.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +301 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/heap_profiler.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +90 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/heap_profiler.c View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +397 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/heap_profiler.gyp View 1 2 3 4 5 6 7 8 1 chunk +74 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/heap_profiler_hooks_android.c View 1 2 3 4 5 6 7 8 1 chunk +209 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/heap_profiler_integrationtest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +179 lines, -0 lines 0 comments Download
A tools/android/heap_profiler/heap_profiler_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +456 lines, -0 lines 0 comments Download

Messages

Total messages: 45 (0 generated)
Primiano Tucci (use gerrit)
This is the most scary piece of black magic I ever wrote Egor, could you ...
6 years, 6 months ago (2014-06-09 16:50:19 UTC) #1
bulach
just random drive-by, this looks really promising!!! https://codereview.chromium.org/323893002/diff/1/tools/android/heap_profiler/hdump.c File tools/android/heap_profiler/hdump.c (right): https://codereview.chromium.org/323893002/diff/1/tools/android/heap_profiler/hdump.c#newcode27 tools/android/heap_profiler/hdump.c:27: // 3: ...
6 years, 6 months ago (2014-06-09 17:23:28 UTC) #2
Primiano Tucci (use gerrit)
Thanks Marcus! CC: +pliard, just FYI, you might need it in your "future life". Also, ...
6 years, 6 months ago (2014-06-09 19:10:53 UTC) #3
Primiano Tucci (use gerrit)
+torne@ for the linker magic in heap_profiler_hooks_android.c
6 years, 6 months ago (2014-06-10 12:42:22 UTC) #4
Torne
Dynamic linking trickery looks okay to me :)
6 years, 6 months ago (2014-06-10 12:59:07 UTC) #5
pasko
I like the approach, especially if used with release binaries!! I just took the first ...
6 years, 6 months ago (2014-06-10 16:59:53 UTC) #6
pasko
not lgtm Let's continue the review after we decide what to do about the comment ...
6 years, 6 months ago (2014-06-11 12:39:24 UTC) #7
Primiano Tucci (use gerrit)
https://codereview.chromium.org/323893002/diff/120001/tools/android/heap_profiler/heap_profiler_hooks_android.c File tools/android/heap_profiler/heap_profiler_hooks_android.c (right): https://codereview.chromium.org/323893002/diff/120001/tools/android/heap_profiler/heap_profiler_hooks_android.c#newcode133 tools/android/heap_profiler/heap_profiler_hooks_android.c:133: void* ret = real_malloc(byte_count); On 2014/06/11 12:39:24, pasko wrote: ...
6 years, 6 months ago (2014-06-11 13:44:45 UTC) #8
pasko
https://codereview.chromium.org/323893002/diff/120001/tools/android/heap_profiler/heap_profiler_hooks_android.c File tools/android/heap_profiler/heap_profiler_hooks_android.c (right): https://codereview.chromium.org/323893002/diff/120001/tools/android/heap_profiler/heap_profiler_hooks_android.c#newcode133 tools/android/heap_profiler/heap_profiler_hooks_android.c:133: void* ret = real_malloc(byte_count); By the way, memory can ...
6 years, 6 months ago (2014-06-11 16:06:36 UTC) #9
Primiano Tucci (use gerrit)
> By the way, memory can also be consumed by brk/sbrk. The question I am ...
6 years, 6 months ago (2014-06-11 17:54:23 UTC) #10
Primiano Tucci (use gerrit)
Egor, can you take another look ? I addressed the comments (you made some very ...
6 years, 6 months ago (2014-06-19 12:27:18 UTC) #11
pasko
thanks! Sounds promising, I'll take another dive tomorrow.
6 years, 6 months ago (2014-06-19 17:06:28 UTC) #12
pasko
one more pass through hooks heap_profiler.c: pending https://codereview.chromium.org/323893002/diff/80001/tools/android/heap_profiler/heap_profiler.gyp File tools/android/heap_profiler/heap_profiler.gyp (right): https://codereview.chromium.org/323893002/diff/80001/tools/android/heap_profiler/heap_profiler.gyp#newcode30 tools/android/heap_profiler/heap_profiler.gyp:30: 'target_name': 'heap_dump', ...
6 years, 6 months ago (2014-06-20 22:07:18 UTC) #13
Primiano Tucci (use gerrit)
Thanks https://codereview.chromium.org/323893002/diff/80001/tools/android/heap_profiler/heap_profiler.gyp File tools/android/heap_profiler/heap_profiler.gyp (right): https://codereview.chromium.org/323893002/diff/80001/tools/android/heap_profiler/heap_profiler.gyp#newcode30 tools/android/heap_profiler/heap_profiler.gyp:30: 'target_name': 'heap_dump', > really done? I meant the ...
6 years, 6 months ago (2014-06-23 14:00:32 UTC) #14
pasko
Looked through heap_profiler.c, I am actually quite impressed how elegant, logical and compact it is. ...
6 years, 6 months ago (2014-06-23 20:09:23 UTC) #15
Primiano Tucci (use gerrit)
Thanks for the review! Don't worry about the tests, as soon as bulach@ comes in ...
6 years, 6 months ago (2014-06-24 08:43:33 UTC) #16
bulach
lgtm for the tests, thanks! some nits and suggestions below: https://codereview.chromium.org/323893002/diff/240001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): https://codereview.chromium.org/323893002/diff/240001/tools/android/heap_profiler/heap_profiler_integrationtest.cc#newcode21 ...
6 years, 6 months ago (2014-06-24 10:45:14 UTC) #17
pasko
https://codereview.chromium.org/323893002/diff/220001/tools/android/heap_profiler/heap_profiler.c File tools/android/heap_profiler/heap_profiler.c (right): https://codereview.chromium.org/323893002/diff/220001/tools/android/heap_profiler/heap_profiler.c#newcode309 tools/android/heap_profiler/heap_profiler.c:309: insert_vma(del_end + 1, old_end, st, vma->flags); On 2014/06/24 08:43:33, ...
6 years, 6 months ago (2014-06-24 13:21:45 UTC) #18
Primiano Tucci (use gerrit)
Thanks both https://codereview.chromium.org/323893002/diff/220001/tools/android/heap_profiler/heap_profiler.c File tools/android/heap_profiler/heap_profiler.c (right): https://codereview.chromium.org/323893002/diff/220001/tools/android/heap_profiler/heap_profiler.c#newcode309 tools/android/heap_profiler/heap_profiler.c:309: insert_vma(del_end + 1, old_end, st, vma->flags); > ...
6 years, 6 months ago (2014-06-24 15:10:57 UTC) #19
bulach
still lgtm for tests, but some clarifications inline: https://codereview.chromium.org/323893002/diff/260001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): https://codereview.chromium.org/323893002/diff/260001/tools/android/heap_profiler/heap_profiler_integrationtest.cc#newcode135 tools/android/heap_profiler/heap_profiler_integrationtest.cc:135: TEST(HeapProfilerIntegrationTest, ...
6 years, 6 months ago (2014-06-25 11:19:33 UTC) #20
pasko
LGTM for: heap_profiler.{c,h} heap_profiler_hooks_android.c heap_profiler_integrationtest.cc Thanks and have fun profiling! https://codereview.chromium.org/323893002/diff/260001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): https://codereview.chromium.org/323893002/diff/260001/tools/android/heap_profiler/heap_profiler_integrationtest.cc#newcode25 ...
6 years, 6 months ago (2014-06-25 16:39:51 UTC) #21
Primiano Tucci (use gerrit)
https://codereview.chromium.org/323893002/diff/260001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): https://codereview.chromium.org/323893002/diff/260001/tools/android/heap_profiler/heap_profiler_integrationtest.cc#newcode25 tools/android/heap_profiler/heap_profiler_integrationtest.cc:25: // that this function will be part of the ...
6 years, 6 months ago (2014-06-26 09:00:55 UTC) #22
Primiano Tucci (use gerrit)
+brettw for DEPS Note: bsdtrees is going to be introduced by https://codereview.chromium.org/323873004/ (which got the ...
6 years, 6 months ago (2014-06-26 12:39:03 UTC) #23
bulach
lgtm, thanks! looks nicer. small suggestions, feel free to go ahead.. https://codereview.chromium.org/323893002/diff/340001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): ...
6 years, 6 months ago (2014-06-26 12:49:38 UTC) #24
Primiano Tucci (use gerrit)
https://codereview.chromium.org/323893002/diff/340001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): https://codereview.chromium.org/323893002/diff/340001/tools/android/heap_profiler/heap_profiler_integrationtest.cc#newcode64 tools/android/heap_profiler/heap_profiler_integrationtest.cc:64: void Initialize(void* (*outer_fn)(size_t), void* (*inner_fn)(size_t)) { On 2014/06/26 12:49:38, ...
6 years, 6 months ago (2014-06-26 13:38:17 UTC) #25
bulach
still lgtm, sorry I wasn't clear from the beginning.. https://codereview.chromium.org/323893002/diff/360001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): https://codereview.chromium.org/323893002/diff/360001/tools/android/heap_profiler/heap_profiler_integrationtest.cc#newcode146 tools/android/heap_profiler/heap_profiler_integrationtest.cc:146: ...
6 years, 6 months ago (2014-06-26 14:42:54 UTC) #26
Primiano Tucci (use gerrit)
https://codereview.chromium.org/323893002/diff/360001/tools/android/heap_profiler/heap_profiler_integrationtest.cc File tools/android/heap_profiler/heap_profiler_integrationtest.cc (right): https://codereview.chromium.org/323893002/diff/360001/tools/android/heap_profiler/heap_profiler_integrationtest.cc#newcode146 tools/android/heap_profiler/heap_profiler_integrationtest.cc:146: free(m2); On 2014/06/26 14:42:54, bulach wrote: > which would ...
6 years, 5 months ago (2014-06-27 09:34:29 UTC) #27
bulach
lgtm, thanks!
6 years, 5 months ago (2014-06-27 11:07:45 UTC) #28
Dai Mikurube (NOT FULLTIME)
Hi, I have some questions about naming and dumped results. https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c File tools/android/heap_profiler/heap_dump.c (right): https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c#newcode12 ...
6 years, 5 months ago (2014-07-02 04:49:52 UTC) #29
Primiano Tucci (use gerrit)
https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c File tools/android/heap_profiler/heap_dump.c (right): https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c#newcode12 tools/android/heap_profiler/heap_dump.c:12: // "num_allocs": 37542, # Number of virtual memory areas ...
6 years, 5 months ago (2014-07-02 07:43:28 UTC) #30
Dai Mikurube (NOT FULLTIME)
https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c File tools/android/heap_profiler/heap_dump.c (right): https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c#newcode12 tools/android/heap_profiler/heap_dump.c:12: // "num_allocs": 37542, # Number of virtual memory areas ...
6 years, 5 months ago (2014-07-02 09:39:32 UTC) #31
Primiano Tucci (use gerrit)
https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c File tools/android/heap_profiler/heap_dump.c (right): https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c#newcode12 tools/android/heap_profiler/heap_dump.c:12: // "num_allocs": 37542, # Number of virtual memory areas ...
6 years, 5 months ago (2014-07-02 09:49:53 UTC) #32
Dai Mikurube (NOT FULLTIME)
https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c File tools/android/heap_profiler/heap_dump.c (right): https://codereview.chromium.org/323893002/diff/400001/tools/android/heap_profiler/heap_dump.c#newcode12 tools/android/heap_profiler/heap_dump.c:12: // "num_allocs": 37542, # Number of virtual memory areas ...
6 years, 5 months ago (2014-07-02 10:04:58 UTC) #33
Dai Mikurube (NOT FULLTIME)
Ah, one additional request. Currently, we cannot be aware of the flag (indicating the "allocator" ...
6 years, 5 months ago (2014-07-03 07:23:26 UTC) #34
Primiano Tucci (use gerrit)
> Can we have the "flags" in the "stacks" attribute? "allocs" is usually so large. ...
6 years, 5 months ago (2014-07-03 10:11:22 UTC) #35
Dai Mikurube (NOT FULLTIME)
On 2014/07/03 10:11:22, Primiano Tucci wrote: > > Can we have the "flags" in the ...
6 years, 5 months ago (2014-07-04 05:37:06 UTC) #36
Primiano Tucci (use gerrit)
The CQ bit was checked by primiano@chromium.org
6 years, 5 months ago (2014-07-07 11:29:15 UTC) #37
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/primiano@chromium.org/323893002/440001
6 years, 5 months ago (2014-07-07 11:30:21 UTC) #38
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: chromium_presubmit on tryserver.chromium ...
6 years, 5 months ago (2014-07-07 14:09:07 UTC) #39
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 5 months ago (2014-07-07 14:11:35 UTC) #40
commit-bot: I haz the power
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium (http://build.chromium.org/p/tryserver.chromium/builders/chromium_presubmit/builds/78172)
6 years, 5 months ago (2014-07-07 14:11:36 UTC) #41
Primiano Tucci (use gerrit)
LGTM, Good job Primiano! http://goo.gl/i1oOf1 (No, I'm not insane, it's just to make the presubmit ...
6 years, 5 months ago (2014-07-07 15:28:04 UTC) #42
Primiano Tucci (use gerrit)
The CQ bit was checked by primiano@chromium.org
6 years, 5 months ago (2014-07-07 15:32:05 UTC) #43
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/primiano@chromium.org/323893002/440001
6 years, 5 months ago (2014-07-07 15:33:12 UTC) #44
commit-bot: I haz the power
6 years, 5 months ago (2014-07-07 15:34:46 UTC) #45
Message was sent while issue was closed.
Change committed as 281542

Powered by Google App Engine
This is Rietveld 408576698