Closed Bug 1577825 Opened 5 months ago Closed 2 months ago

SharedArrayBuffer memory is not accounted for


(Core :: JavaScript: GC, defect, P1)






(Reporter: jonco, Assigned: jonco)



(Whiteboard: [MemShrink:P2])


(2 files, 2 obsolete files)

The mapped memory used for shared array buffers is not currently reported to the GC memory accounting framework.

The priority flag is not set for this bug.
:jonco, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(jcoppeard)
Flags: needinfo?(jcoppeard)
Priority: -- → P1

Luke, at the moment I think these are only ever mapped into a single process (but may be shared between multiple runtimes). Is that correct? Are there any plans to change that?

Flags: needinfo?(luke)

Correct, and there is even an intention not to allow this.

Flags: needinfo?(luke)
Assignee: nobody → jcoppeard

This makes the hash table used for tracking ZoneAllocPolicy generic and able to track memory owned by other non-GC things. I'm not entirely sold on the 'other' naming but didn't really like any other alternative I could come up with. The idea is to use this for tracking the memory associated with shared array buffers in the next patch.

The challenge here is that the buffers can be shared between zones in different runtimes and also used by more than one SharedArrayBuffer JS object in a zone. The buffers can be large so we want to avoid double-counting. The patch stores a count of the number of SAB objects using a buffer in each zone in a hash table on the SharedArrayRawBuffer. Access is protected by the buffer's mutex to allow this to work when used by different runtimes. This is a bit more heavyweight that I'd have liked, but I figure creating and SAB objects is not going to be a super-hot code path.

Depends on D55533

Whiteboard: [MemShrink:P2]
See Also: → 1599659

I'll land the first patch now so it doesn't rot.

Keywords: leave-open
Pushed by
Refactor zone memory tracker to allow tracking non-GC thing pointers apart from ZoneAllocPolicy r=sfink

This adds zone methods to account for 'shared' memory, in the sense of shared between more than one GC thing in the zone. The hash map used to track allocations moves to the zone, and we don't have to take a lock. We do need to make the SAB finalizer run on the main thread however (but I think this was going to happen anyway with Lars' patch).

One complication is that the same allocation can be added to the zone with different sizes, when a SAB grows. So we track the size too and update the memory accounting when it increases.

Pushed by
Account for SharedArrayBuffer memory r=luke
Pushed by
Fix build bustage on Windows a=fix. On a CLOSED TREE
Attachment #9114513 - Attachment is obsolete: true
Attachment #9113007 - Attachment is obsolete: true
Closed: 2 months ago
Keywords: leave-open
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.