Closed Bug 1683669 Opened 3 years ago Closed 3 years ago

DMD reports heap-unclassified memory in mozilla::dom::FontFace::GetUnicodeRangeAsCharacterMap for Google sites

Categories

(Core :: Layout: Text and Fonts, defect)

defect

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: whimboo, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

(Keywords: memory-footprint)

Attachments

(2 files)

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:86.0) Gecko/20100101 Firefox/86.0 ID:20201218095607

As attached a DMD report of a web content process that holds gmail.google.com, and docs.google.com. The memory report shows about 15% of heap unclassified memory.

Here an excerpt from about:memory:

830.88 MB (100.0%) -- explicit
├──278.97 MB (33.57%) -- window-objects
│  ├──114.65 MB (13.80%) -- top(https://mail.google.com/mail/u/0/#inbox..., id=82)
│  ├───85.10 MB (10.24%) -- top(https://docs.google.com/document/d/%ID%/edit#, id=151)
│  ├───78.82 MB (09.49%) -- top(https://docs.google.com/document/d/%ID%/edit#, id=536)
├──201.26 MB (24.22%) -- dmd
│  ├──176.00 MB (21.18%) ── live-block-table
│  ├───25.26 MB (03.04%) -- stack-traces
│  │   ├──12.78 MB (01.54%) ── used
│  │   ├───9.48 MB (01.14%) ── unused
│  │   └───3.00 MB (00.36%) ── table
│  └────0.00 MB (00.00%) ── dead-block-list
├──122.66 MB (14.76%) ── heap-unclassified

And this seems to mostly fall into the following bucket:

   #01: nsTArrayInfallibleAllocator::ResultTypeProxy nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_RelocateUsingMemutils>::EnsureCapacity<nsTArrayInfallibleAllocator>(unsigned long, unsigned long) (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0x4bbbd6)
    #02: gfxSparseBitSet::SetRange(unsigned int, unsigned int) (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0xacdac4)
    #03: mozilla::dom::FontFace::GetUnicodeRangeAsCharacterMap() (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0x454bcfd)
    #04: mozilla::dom::FontFaceSet::FindOrCreateUserFontEntryFromFontFace(nsTSubstring<char> const&, mozilla::dom::FontFace*, mozilla::StyleOrigin) (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0x455030e)
    #05: mozilla::dom::FontFaceSet::FindOrCreateUserFontEntryFromFontFace(mozilla::dom::FontFace*) (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0x454b38f)
    #06: mozilla::dom::FontFace::CreateUserFontEntry() (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0x454b642)
    #07: mozilla::dom::FontFace::Load(mozilla::ErrorResult&) (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0x454b484)
    #08: mozilla::dom::FontFace_Binding::load_promiseWrapper(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0x37a5d6e)
    #09: bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ConvertExceptionsToPromises>(JSContext*, unsigned int, JS::Value*) (/Applications/FirefoxNightly.app/Contents/MacOS/XUL + 0xe12e12)
Blocks: 1683418
Severity: -- → S3
Summary: DMD reports heap-unclassifed memory in mozilla::dom::FontFace::GetUnicodeRangeAsCharacterMap for Google sites → DMD reports heap-unclassified memory in mozilla::dom::FontFace::GetUnicodeRangeAsCharacterMap for Google sites

Jeff, could this be related to the recent findings on bug 1683418?

Flags: needinfo?(jmuizelaar)

No, it seems unrelated. This is more in Jonathan's wheelhouse.

Flags: needinfo?(jmuizelaar) → needinfo?(jfkthame)

Looks like dom::Document simply doesn't account for its mFontFaceSet in its memory reporter.

(AFAICS this isn't an actual leak issue, just a lack of explicit reporting.)

The other thing I notice here is that the block sizes are substantially larger than they need to be, as a result of how nsTArray allocates. We can save close to 50% of this memory by ensuring we compact the arrays once they've been populated, so we don't allow the allocation slop to persist indefinitely.

Then we should ensure the Document memory reporter accounts for what's left, to get it out of the DMD report.

Flags: needinfo?(jfkthame)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

The patch above should give us the easy win of compacting the arrays. Hooking up actual memory reporting will be a bit more of a task.

I'm going to go ahead and land this patch, as it's a significant memory savings in some cases, but will clone a followup bug for actual memory-reporter support.

Blocks: 1683904
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1b3e6914f157
patch 1 - Compact the gfxSparseBitSet created for a unicode-range descriptor, to reduce memory footprint. r=jrmuizel
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 86 Branch

== Change summary for alert #28261 (as of Mon, 28 Dec 2020 11:08:33 GMT) ==

Improvements:

Ratio Suite Test Platform Options Absolute values (old vs new)
6% Heap Unclassified linux1804-64-shippable tp6 85,885,045.42 -> 80,900,151.99
6% Heap Unclassified windows10-64-shippable tp6 62,483,764.13 -> 58,951,038.41
5% Heap Unclassified windows10-64-shippable-qr tp6 70,348,945.73 -> 66,509,045.01
4% Heap Unclassified windows10-64-shippable-qr tp6 69,098,931.26 -> 66,270,645.33
4% Heap Unclassified macosx1014-64-shippable-qr tp6 116,742,140.33 -> 112,597,778.70

For up to date results, see: https://treeherder.mozilla.org/perfherder/alerts?id=28261

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: