Closed
Bug 997007
Opened 11 years ago
Closed 10 years ago
[Tarako] What of freetype is allocating memory
Categories
(Firefox OS Graveyard :: Performance, defect, P2)
Tracking
(Not tracked)
RESOLVED
FIXED
2.1 S1 (1aug)
People
(Reporter: ting, Unassigned)
References
Details
(Keywords: memory-footprint, perf, Whiteboard: [c=memory p= s=2014.08.01.t u=tarako] [MemShrink:P2])
Attachments
(1 file)
5.93 MB,
text/plain
|
Details |
While working on Tarako bug 989713, about memory (attachment 8406762 [details]) shows freetype consumes ~6MB memory at inbox page of Email, I'd like to figure out what of freetype is allocating memory, and see if there're chances to lower it.
Reporter | ||
Updated•11 years ago
|
Summary: What of freetype is allocating memory → [Email] What of freetype is allocating memory
Updated•11 years ago
|
Whiteboard: [MemShrink]
Comment 1•11 years ago
|
||
Is this just a consequence of using a font different from our typical Fira Sans?
Reporter | ||
Comment 2•11 years ago
|
||
Seems so, there're emails with Chinese subject from the test account, I will still take a look to confirm.
BTW, I checked also Messages app which has only English titles, freetype takes just ~0.3 MB.
Updated•11 years ago
|
Reporter | ||
Comment 3•11 years ago
|
||
Without Chinese subject emails, freetype takes ~0.2 MB.
Reporter | ||
Comment 4•11 years ago
|
||
Disabled FreetypeReporter, and got DMD report for the stack allocating memory when there're Chinese subject emails.
Reporter | ||
Comment 5•11 years ago
|
||
I put 4 Chinese characters on one email subject, and checked FreetypeReporter's difference between gfxFontGroup::FindFontForChar() invocaitons:
D/TINGf ( 510): #0 217652 font=Fira Sans OT Medium
D/TINGf ( 510): #6 3093824 font=MotoyaLMaru W3 mono
D/TINGf ( 510): #6 3093824 font=MotoyaLMaru W3 mono
D/TINGf ( 510): #6 3093824 font=MotoyaLMaru W3 mono
D/TINGf ( 510): #6 3093824 font=MotoyaLMaru W3 mono
D/TINGf ( 510): #0 3097040 font=Fira Sans OT
Traced freetype2 a bit, it allocates a buffer for storing uncompressed SFNT from the MotoyaLMaru woff.
Reporter | ||
Comment 6•11 years ago
|
||
Aside from woff things, freetype2 does support memory-mapped files:
http://www.freetype.org/freetype2/docs/design/design-4.html
<quote>
However, the Unix build of FreeType 2 provides an alternative implementation that uses memory-mapped files, when available on the host platform, resulting in a significant access speed-up.
FreeType distinguishes between memory-based and disk-based streams. In the first case, all data is directly accessed in memory (e.g. ROM-based, write-only static data and memory-mapped files), while in the second, portions of the font files are read in chunks called frames, and temporarily buffered similarly through typical seek/read operations.
</quote>
I will check is this used.
Comment 7•11 years ago
|
||
After looking into the code of freetype, it dues to uncompressed font data of WOFF. All compressed data of WOFF is uncompressed into a block of memory during open. I suggest to use other format to avoid this block of memory (~2.7MB).
Reporter | ||
Comment 8•11 years ago
|
||
memory-mapped FT_Stream_Open() is not enabled on Tarako:
objdir-gecko/modules/freetype2/config.log:
configure:4344: checking for working mmap
configure:4501: result: no
objdir-gecko/modules/freetype2/unix-def.mk:
FTSYS_SRC = $(BASE_DIR)/ftsystem.c
Comment 9•11 years ago
|
||
(In reply to Thinker Li [:sinker] from comment #7)
> After looking into the code of freetype, it dues to uncompressed font data
> of WOFF. All compressed data of WOFF is uncompressed into a block of memory
> during open. I suggest to use other format to avoid this block of memory
> (~2.7MB).
The alternative is to use (uncompressed) .ttf files, but this will significantly increase the size of the ROM image, which was apparently a problem for Tarako. Somehow we'll have to decide whether ROM size or RAM usage is the more critical issue here, as we can't optimize for both at the same time.
Comment 11•11 years ago
|
||
In order to save the rom size, we will verify again if all indian related .ttf fonts can be included.
Flags: needinfo?(kli)
Comment 12•11 years ago
|
||
In case of we need to use ttf fonts becasue of performance regression, I think we should remove those fallback fonts with larger size but it would be better to include some Indian related fonts.
Flags: needinfo?(kli)
Comment 13•11 years ago
|
||
Is the font unloaded when a memory pressure event occurs? (and then re-loaded) If so this could be ok.
Reporter | ||
Comment 14•11 years ago
|
||
The memory-pressure observer gfxFontCache::Observer::Observe() clears only shapped-word caches. Please also note uncompressing WOFF font takes time, see bug 992150, comment 54.
Reporter | ||
Updated•11 years ago
|
Summary: [Email] What of freetype is allocating memory → [Tarako] What of freetype is allocating memory
Updated•11 years ago
|
Whiteboard: [MemShrink], [c=memory p= s= u=] → [MemShrink:P2], [c=memory p= s= u=]
Updated•11 years ago
|
Priority: -- → P2
Whiteboard: [MemShrink:P2], [c=memory p= s= u=] → [MemShrink:P2], [c=memory p= s= u=tarako]
Reporter | ||
Comment 15•11 years ago
|
||
Options for storing uncomprssed WOFF:
File based:
a. SD card
b. data partition
Memory based:
c. share between processes by ashmem
Had some discussions with Kai-Zhen Li:
a) Not ok since maybe there won't be a SD card
b) There're only ~80MB space on data partition, and all the uncompressed fonts are ~20MB
c) Still need memory for storing uncompressed fonts
Any other ideas?
# Note from bug 992150, removing fonts seems not a good idea.
Comment 16•11 years ago
|
||
I agree removing fonts could not be a good idea. But Tarako is a special project and that's why it got its own branch v1.3t, so I think having some tradeoff is fair to it. The tradeoff is do not use compressed fonts and remove a few fonts which could make tarako not working properly.
Updated•11 years ago
|
Flags: needinfo?(ttsai)
Reporter | ||
Comment 17•10 years ago
|
||
Closed as the source of allocating memory has been spotted, and there's no more actions needed from this topic.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Updated•10 years ago
|
Component: General → Performance
Whiteboard: [MemShrink:P2], [c=memory p= s= u=tarako] → [c=memory p= s=2014.08.01.t u=tarako] [MemShrink:P2]
Updated•10 years ago
|
Target Milestone: --- → 2.1 S1 (1aug)
You need to log in
before you can comment on or make changes to this bug.
Description
•