Closed Bug 1505522 Opened 1 year ago Closed 1 year ago

Convert MemoryTelemetry.jsm to C++


(Core :: XPCOM, enhancement)

Not set



Tracking Status
firefox66 --- fixed


(Reporter: kmag, Assigned: kmag)


(Blocks 3 open bugs)


(Whiteboard: [overhead:30K])


(3 files)

The existing implementation has memory usage and performance issues which are hard to deal with in JS. By migrating to C++, we could make this code much more memory efficient, and also move the expensive data gathering to a background thread to avoid janking the main thread when we collect data.
Kris, as part of this work can you expand the tests [1] to make sure the values are actually measured? Chris H-C noted anything we gather without expiration should really have a test in bug 1511918, comment 4.

Several call sites assume that gatherMemory() does all of its work
synchronously. This is not true as it is, and will be even less true after my
subsequent patches.

This patch changes gatherMemory() to return a promise which resolves when all
of its in-process work is done, and changes two call sites to wait for it to
resolve before continuing.

One remaining call site, unfortunately, needs to return ping data
synchronously, and therefore cannot wait for async work to complete.
This has benefits both in terms of performance and memory usage. Aside from
the obvious savings of not loading additional JS scripts in every process,
this also allows us to move more of our expensive data collection work to a
background thread, where it doesn't risk janking both parent and content

MozReview-Commit-ID: 2A593R7bIKB
Bug 1505522: Part 1 - Wait for async reports from gatherMemory() to complete when assembling pings. r=chutten
Bug 1505522: Part 2 - Migrate MemoryTelemetry.jsm to C++. r=erahm,chutten
Bug 1505522: Part 3 - Remove unused getHeapAllocatedAsync method. r=erahm
Blocks: 1513392
Bug 1505522: Follow-up: Resolve gatherMemory() promise in release builds. r=me
Depends on: 1513864
Blocks: 1514372
You need to log in before you can comment on or make changes to this bug.