Closed Bug 605362 Opened 14 years ago Closed 14 years ago

Add (coarse-grained) memory reporters for shmem

Categories

(Core :: IPC, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
Tracking Status
fennec 2.0b3+ ---

People

(Reporter: cjones, Assigned: cjones)

Details

Attachments

(5 files)

I propose reporting

 shmem/allocated
 shmem/mapped

(lumping all the different shmem types, basic/sysv/android together) and the specific uses as, e.g.

 shmem/imagesurface
 shmem/ximage
 shmem/cgbitmap

Vlad, does that follow the spirit of the about:memory display?  Not sure how the various counts are expected to add up.

Let's have this bug cover the gross shmem usage, and report the breakdown in followups.  (This is most useful for mobile, and all the shmem we allocate there atm is for gfxSharedImageSurfaces.)
That looks fine -- the about:memory detailed display doesn't add up to any of the numbers, you sort of need a decoder ring to figure out which things are supposed to add up to any other things.  But that's fine, I'd rather have as much data as we can in there and do the analysis separately if we run into memory-related problems.
The way these patches work is, shmem/allocated reports the total shmem bytes actually allocated (by the system interfaces) by a process.  shmem/mapped returns the total bytes mapped, which might be more, less, or the same as the amount allocated (though in our usage so far, mapped >= allocated).  This allows us to see what has been allocated in the content process vs. chrome.
Comment on attachment 484239 [details] [diff] [review]
part 3: Add MemoryReporters for shmem.

er, 'static bool registered;' is missing a = false?
Attachment #484239 - Flags: review?(vladimir) → review+
Comment on attachment 484237 [details] [diff] [review]
part 1: Allocate page-aligned shmem segments in ShmImage, to match other allocators which more honestly report address space and system mem taken by alloc


>+/*static*/ size_t
>+SharedMemory::PageAlignedSize(size_t aSize)
>+{
>+  size_t pageSize = SystemPageSize();
>+  size_t nPagesNeeded = int(ceil(double(aSize) / double(pageSize)));

= size_t(ceil(...))?
Attachment #484237 - Flags: review?(joe) → review+
Comment on attachment 484238 [details] [diff] [review]
part 2: Track allocated sizes (in the allocating process) in all shmem backends

Why not track/store alloc size in SharedMemory? We do something similar in gfxASurface, fwiw.
Attachment #484238 - Flags: review?(joe) → review+
Attachment #484240 - Flags: review?(joe) → review+
(In reply to comment #8)
> Comment on attachment 484237 [details] [diff] [review]
> = size_t(ceil(...))?

Oop, yep.

(In reply to comment #9)
> Comment on attachment 484238 [details] [diff] [review]
> part 2: Track allocated sizes (in the allocating process) in all shmem backends
> 
> Why not track/store alloc size in SharedMemory? We do something similar in
> gfxASurface, fwiw.

Well, we're tracking allocs in SharedMemory.  I thought about making mAllocSize a member of SharedMemory, but the only thing I believe it buys us is being able to call DestroyedShmem() from ~SharedMemory.  I could make that change if you want.
Comment on attachment 485471 [details] [diff] [review]
part 5: Centralize more of the accounting

So we're no longer going to report things as unmapped or destroyed until the destructor is called?
Attachment #485471 - Flags: review?(joe) → review+
We don't (currently) support unmapping or destroying SharedMemorys separate from ~SharedMemory().
Requesting blocking because it's going to be hard to get memory usage info from users in the field without these patches.  Technically approval? is probably more appropriate.
tracking-fennec: --- → ?
tracking-fennec: ? → 2.0b3+
Status: NEW → ASSIGNED
Whiteboard: [fennec-checkin-postb2][has-patch]
Whiteboard: [fennec-checkin-postb2][has-patch]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: