Closed Bug 973777 Opened 10 years ago Closed 10 years ago

Breaking down the information of GrallocReporter

Categories

(Firefox OS Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
2.0 S4 (20june)

People

(Reporter: schiu, Assigned: schiu)

Details

Attachments

(3 files, 4 obsolete files)

The number which reported by GrallocReporter now is grand total of all GraphicBuffer consumption, which is hard to tell the information of individual GraphicBuffer. The reported number maybe can break down to the consumption of each allocated GraphicBuffer. Furthermore, the dimension and bpp can be presented in memory report, such that we can roughly know what a specific graphicbuffer is refering to.
Assignee: nobody → schiu
Provide the detail of gralloc buffer usage is good. 
How to use this memory tool is more important. As we talked during the meeting, please create bug for one click memory usage snapshot for memory analysis, like the following
a. run the tool to capture current memory report
b. reproduce something
c. stop the tool to capture another new memory report
d. display the difference between these two reports
Attached patch WIP: Gralloc reporter (obsolete) — Splinter Review
Due to the refactoring work in bug#959089, GrallocReport has been move to SharedBufferManagerParent.cpp from ShadowLayerUtilsGralloc.cpp. This patch is base on SharedBufferManagerParent and leverage the pid information to present the broken down information of gralloc usage.
Comment on attachment 8419267 [details] [diff] [review]
WIP: Gralloc reporter

Review of attachment 8419267 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ +62,5 @@
> +        (stride * height * 3 / 2);
> +
> +      nsPrintfCString gpath("gralloc/pid=%d/w=%d, h=%d, bpp=%d",
> +        pid, gb->getWidth(), height, bpp);
> +

Let me recap the comment further, Here I propose 2 appoaches to output the report, due to MOZ_COLLECT_REPORT doesn't accept non-literal string as its second argument: "path". The first one is adding a new macro which is similar to MOZ_COLLECT_REPORT, except it removes NS_LITERAL_CSTRING wrapping from "path". And the second one is calling the callback of aHandleReport(which called by MOZ_COLLECT_REPORT originally), such that we can pass a nsPrintfCString directly. We need to know the pros and cos of each approach, or if there exist a better way to do the job.
Attached file Example memory-reports
Attachment #8419267 - Attachment is obsolete: true
Attachment #8419267 - Flags: feedback?(khuey)
Comment on attachment 8426370 [details] [diff] [review]
WIP: breaking down the memory report of gralloc

Review of attachment 8426370 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ +67,5 @@
> +// Due to MOZ_COLLECT_REPORT doesn't accept non-literal string as path,
> +// just call the callback of aHandleReport(which called by MOZ_COLLECT_REPORT originally),
> +// such that we can pass a nsPrintfCString directly.
> +//
> +      rv = aHandleReport->Callback(EmptyCString(), gpath, KIND_OTHER, UNITS_BYTES, amount,

Here we call aHandleReport->Callback() instead of using MOZ_COLLECT_REPORT, because the macro cannot accept a non-literal string as its second argument. An alternative way is create another macro similar to MOZ_COLLECT_REPORT, and accept non-literal strings as its second argument, which similar to the way used in http://dxr.mozilla.org/mozilla-central/source/content/media/MediaStreamGraph.cpp#2790.
Hi Nicholas,

Could you please give me some advice about the way I breaking down the memory usage of gralloc in the WIP patch? Another thing also need your comment is: I use aHandleReport->Callback() instead of MOZ_COLLECT_REPORT, because the macro doesn't accept non-literal string as its second argument. Do you have any concern about my way?

Thanks.
Flags: needinfo?(n.nethercote)
Comment on attachment 8426370 [details] [diff] [review]
WIP: breaking down the memory report of gralloc

Review of attachment 8426370 [details] [diff] [review]:
-----------------------------------------------------------------

This looks good! Splitting up large about:memory buckets like this is often very useful.

::: gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ +44,5 @@
>    NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
>                              nsISupports* aData)
>    {
> +  map<base::ProcessId, SharedBufferManagerParent*>::iterator it;
> +  for (it = SharedBufferManagerParent::sManagers.begin(); it != SharedBufferManagerParent::sManagers.end(); it++) {

The indentation here doesn't look right.

@@ +57,5 @@
> +      int stride = gb->getStride();
> +      int height = gb->getHeight();
> +      int amount = bpp > 0 ?
> +        (stride * height * bpp) :
> +	// Specical case for BSP specific formats(mainly YUV formats, count it as normal YUV buffer)

"Special", and add a space after "formats", and add a period at the end, please.

@@ +61,5 @@
> +	// Specical case for BSP specific formats(mainly YUV formats, count it as normal YUV buffer)
> +        (stride * height * 3 / 2);
> +
> +      nsPrintfCString gpath("gralloc/pid=%d/w=%d, h=%d, bpp=%d",
> +        pid, gb->getWidth(), height, bpp);

Use "width" and "height" instead of "w" and "h". Also, in memory reports we usually have some kind of identifying name with parameters in parentheses, so something like this would be good:

> "gralloc/pid(%d)/buffer(width=%d, height=%d, bpp=%d)"

There may be a better word to use than "buffer".

@@ +65,5 @@
> +        pid, gb->getWidth(), height, bpp);
> +
> +// Due to MOZ_COLLECT_REPORT doesn't accept non-literal string as path,
> +// just call the callback of aHandleReport(which called by MOZ_COLLECT_REPORT originally),
> +// such that we can pass a nsPrintfCString directly.

Not using the macro is fine, and there's no need for this comment.

@@ +83,4 @@
>    }
>  
> +  return NS_OK;
> +  }

The indentation looks wrong here, too.
Attachment #8426370 - Flags: feedback+
BTW, you can copy+paste the text from about:memory. It's a lot easier than taking a screenshot :)
Flags: needinfo?(n.nethercote)
> How to use this memory tool is more important. As we talked during the
> meeting, please create bug for one click memory usage snapshot for memory
> analysis, like the following
> a. run the tool to capture current memory report
> b. reproduce something
> c. stop the tool to capture another new memory report
> d. display the difference between these two reports

I wasn't at the meeting, but I think we already have this covered: the tools/get_about_memory.py script lets you capture memory reports at arbitrary points in time, and then you can diff them in about:memory (in desktop Firefox) using the "Load and diff..." button.
Attachment #8426370 - Attachment is obsolete: true
Attachment #8426882 - Flags: review?(mtseng)
Comment on attachment 8426882 [details] [diff] [review]
Breaking down the memory report of gralloc

Review of attachment 8426882 [details] [diff] [review]:
-----------------------------------------------------------------

::: gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ +19,5 @@
>  #include "ui/PixelFormat.h"
>  #endif
>  #include "nsThreadUtils.h"
>  
> +#include "nsPrintfCString.h"

Don't put extra line between #include unless you have specific reason and put it to previous line of nsThreadUtils.h in order to maintain alphabetic order.

@@ +44,4 @@
>    NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
>                              nsISupports* aData)
>    {
> +  map<base::ProcessId, SharedBufferManagerParent*>::iterator it;

Many comments address by :njn seems not fix here. So I suggest fix the comment first or I'll send some duplicate comment.
Attachment #8426882 - Flags: review?(mtseng) → review-
And please ask me to review when the next version is put up. Thanks!
(In reply to Nicholas Nethercote [:njn] from comment #16)
> And please ask me to review when the next version is put up. Thanks!

Hi Nicholas,

We need to do peer review first inside our team, and then ask formal review. I may still need to modify some code to make it better, and will ask for your review after modification.

Thanks.
Attachment #8426882 - Attachment is obsolete: true
Attachment #8427654 - Flags: review?(n.nethercote)
Attachment #8427654 - Flags: review?(mtseng)
Comment on attachment 8427654 [details] [diff] [review]
Breaking down the memory report of gralloc

Review of attachment 8427654 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, thanks!

::: gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ +32,5 @@
>  namespace layers {
>  
> +map<base::ProcessId, SharedBufferManagerParent* > SharedBufferManagerParent::sManagers;
> +StaticAutoPtr<Monitor> SharedBufferManagerParent::sManagerMonitor;
> +int SharedBufferManagerParent::sBufferKey = 0;

Does this need to be atomic? (BTW, I realize it was like this prior to your patch, but while we are here...)

@@ +57,5 @@
> +        int height = gb->getHeight();
> +        int amount = bpp > 0 ?
> +          (stride * height * bpp) :
> +          // Special case for BSP specific formats (mainly YUV formats, count it as normal YUV buffer).
> +          (stride * height * 3 / 2);

Nit: this is typically a better style for multi-line ternary expressions:

> value = cond
>       ? a
>       : b;

@@ +70,5 @@
> +              "resource, with much less available than generic RAM. When it's exhausted, "
> +              "graphics performance can suffer. This value can be incorrect because of race "
> +              "conditions."),
> +            aData);
> +        if ( rv != NS_OK) {

Nit: No space before |rv|.
Attachment #8427654 - Flags: review?(n.nethercote) → review+
Comment on attachment 8427654 [details] [diff] [review]
Breaking down the memory report of gralloc

Review of attachment 8427654 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM
Attachment #8427654 - Flags: review?(mtseng) → review+
rebase to m+c, and carry r+
Attachment #8427654 - Attachment is obsolete: true
Attachment #8440401 - Flags: review+
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/517a7e48664a
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.0 S4 (20june)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: