Closed Bug 1568821 Opened 1 year ago Closed 1 year ago

Make memory counters track the retained bytes

Categories

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

task

Tracking

()

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: jonco, Assigned: jonco)

References

Details

Attachments

(3 files)

To allow us to do bug 1566864 we need to track the retained memory, that is the amount of memory allocated at the start of a collection that has not been freed by the GC. (This is different to the total allocated bytes because more memory can be allocated by the mutator during an incremental GC.)

To do this requires that we indicate to memory tracking methods whether a change was the result of sweeping.

The main idea here is to pass a |wasSwept| parameter to memory tracking methods that remove memory. We know what to pass for GC heap size because this always goes through HeapSize::removeGCArena(). Getting this right for malloc memory is the subject of a later patch.

Now we're calculating retained size here we can remove the same calculation from Statistics. I had to add a flag to say whether a zone was collected in the last collection so that we know which zones to add to add up. I checked that this produced the same result as the original calculation.

Depends on D39387

Now ensure that we know whether malloc memory was freed by the collector or the mutator. Most of the time we can get the |wasSwept| state from from the FreeOp, so mostly this is passing the FreeOp through in more places. That's not always possible though since some code uses the runtime's default FreeOp, so this switches that over

Depends on D39392

Attachment #9080687 - Attachment description: Bug 1568821 - Add retained bytes count to memory tracking classes and use this to track retained GC bytes r=sfink? → Bug 1568821 - Add retained bytes count to memory tracking classes and use this to track retained GC bytes r=sfink
Attachment #9080692 - Attachment description: Bug 1568821 - Use retained bytes for telemetry and replace the original calculation r=sfink? → Bug 1568821 - Use retained bytes for telemetry and replace the original calculation r=sfink
Attachment #9080693 - Attachment description: Bug 1568821 - Pass wasSwept parameter when freeing malloc memory r=sfink? → Bug 1568821 - Pass wasSwept parameter when freeing malloc memory r=sfink
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/aed3a913f9e0
Add retained bytes count to memory tracking classes and use this to track retained GC bytes r=sfink
https://hg.mozilla.org/integration/autoland/rev/47a2920eadfd
Use retained bytes for telemetry and replace the original calculation r=sfink
https://hg.mozilla.org/integration/autoland/rev/1934fb86120c
Pass wasSwept parameter when freeing malloc memory r=sfink
You need to log in before you can comment on or make changes to this bug.