Open Bug 1487146 Opened 7 years ago Updated 2 years ago

Consider memory reporting for FontFace

Categories

(Core :: Layout: Text and Fonts, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: bzbarsky, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [overhead:noted])

I have a DMD report that says: Unreported { 94 blocks in heap block record 6 of 6,988 3,465,216 bytes (3,273,456 requested / 191,760 slop) Individual block sizes: 36,864 x 94 0.72% of the heap (17.97% cumulative) 1.95% of unreported (48.81% cumulative) Allocated at { #01: replace_malloc(unsigned long) (DMD.cpp:1267, in libmozglue.dylib) #02: moz_xmalloc (mozalloc.cpp:71, in libmozglue.dylib) #03: nsTArrayInfallibleAllocator::ResultTypeProxy nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_CopyWithMemutils>::EnsureCapacity<nsTArrayInfallibleAllocator>(unsigned long, unsigned long) (nsTArray-inl.h:137, in XUL) #04: gfxSparseBitSet::SetRange(unsigned int, unsigned int) (nsTArray.h:1761, in XUL) #05: mozilla::dom::FontFace::GetUnicodeRangeAsCharacterMap() (FontFace.cpp:803, in XUL) #06: mozilla::dom::FontFaceSet::FindOrCreateUserFontEntryFromFontFace(nsTSubstring<char16_t> const&, mozilla::dom::FontFace*, mozilla::SheetType) (FontFaceSet.cpp:1167, in XUL) #07: mozilla::dom::FontFace::DoLoad() (FontFaceSet.cpp:991, in XUL) #08: mozilla::dom::FontFace::Load(mozilla::ErrorResult&) (RefPtr.h:296, in XUL) } } So those are 36KiB-sized sparse bitsets. And that's just for the array of pointers to blocks. The blocks themselves are 32 bytes and there is a separate DMD entry for 37628 Block allocations, for a total of 1.2MB there. Unfortunately, I don't know offhand what unicode-range values are involved here... But at the very least, we should consider memory-reporting this stuff. gfxSparseBitSet can definitely do memory reporting; we would "just" need to memory-report FontFace and make sure to report that member.
The DMD report for the Block allocations is: Unreported { 37,628 blocks in heap block record 22 of 6,988 1,204,096 bytes (1,204,096 requested / 0 slop) Individual block sizes: 32 x 37,628 0.25% of the heap (24.40% cumulative) 0.68% of unreported (66.30% cumulative) Allocated at { #01: replace_malloc(unsigned long) (DMD.cpp:1267, in libmozglue.dylib) #02: moz_xmalloc (mozalloc.cpp:71, in libmozglue.dylib) #03: gfxSparseBitSet::SetRange(unsigned int, unsigned int) (mozalloc.h:0, in XUL) #04: mozilla::dom::FontFace::GetUnicodeRangeAsCharacterMap() (FontFace.cpp:803, in XUL) #05: mozilla::dom::FontFaceSet::FindOrCreateUserFontEntryFromFontFace(nsTSubstring<char16_t> const&, mozilla::dom::FontFace*, mozilla::SheetType) (FontFaceSet.cpp:1167, in XUL) #06: mozilla::dom::FontFace::DoLoad() (FontFaceSet.cpp:991, in XUL) #07: mozilla::dom::FontFace::Load(mozilla::ErrorResult&) (RefPtr.h:296, in XUL) #08: mozilla::dom::FontFace_Binding::load_promiseWrapper(JSContext*, JS::Handle<JSObject*>, mozilla::dom::FontFace*, JSJitMethodCallArgs const&) (ErrorResult.h:383, in XUL) } }
Just FTR, in bug 1487553 I'm intending to make gfxSparseFontSet a little more compact (typically around 20-25% smaller, though in this example I expect the saving may be more like 50%). That doesn't remove the need for FontFace memory reporting, of course; it'll just reduce the figures a bit.
Whiteboard: [overhead:noted]
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.