Open
Bug 418536
Opened 16 years ago
Updated 1 year ago
cleanup string handling in font code
Categories
(Core :: Graphics: Text, defect, P4)
Tracking
()
REOPENED
mozilla1.9
People
(Reporter: benjamin, Unassigned)
References
()
Details
(Keywords: perf)
From bug 416411 comment 17: dmandelin found a reduced test case where about 20% of ~110,000 nsAutoStrings are assigned to an nsString: loading http://zh-yue.wikipedia.org/wiki/%E7%BE%8E%E5%9C%8B The highest frequency contexts for the assign are below, in this format: [freq] [sourceline] [source code] [additional info on stack trace] freq = % of nsAutoString assigns accounted for in this item sourceline = source line of deepest non-libxpcom call on stack at assign source code = code of that line 44% modules/libpref/src/nsPrefBranch.cpp:343 (in nsPrefBranch::GetComplexValue) rv = theString->SetData(NS_ConvertUTF8toUTF16(utf8String)); [Mostly called from AppendPrefFonts via CopyUnicharPref.] 15% gfx/thebes/src/gfxFont.cpp:671 (in ResolveData::ResolveData) mGenericFamily(aGenericFamily), [Mostly called from AppendPrefFonts via gfxFontGroup::ForEachFont.] 15% gfx/thebes/src/gfxQuartzFontCache.mm:205 (in gfxQuartzFontCache::GenerateFontListKey) aResult = aKeyName; [Mostly called from AppendPrefFonts via gfxFontGroup::ResolveFontName.] 15% gfx/thebes/src/gfxPlatform.cpp:253 (in AppendGenericFontFromPref) genericDotLang.Assign(NS_ConvertUTF16toUTF8(genericName)); [Mostly called from AppendPrefFonts.] Overall, 88% of the nsAutoStrings that got assigned to another nsString had a call to AppendPrefFonts when Assign was called. dmandelin, was this on mac?
Flags: wanted1.9+
Flags: blocking1.9?
Comment 1•16 years ago
|
||
Yes, it was on Mac.
Comment 2•16 years ago
|
||
(In reply to comment #0) > From bug 416411 comment 17: > > dmandelin found a reduced test case where about 20% of ~110,000 nsAutoStrings > are assigned to an nsString: loading > > http://zh-yue.wikipedia.org/wiki/%E7%BE%8E%E5%9C%8B > I think a lot of this was fixed by bug 409432, which went in on 1/30. We were building pref font lists per *character*, leading to a lot of string thrashing. This string thrashing should now only occur once after startup, pref font lists are then cached.
Comment 3•16 years ago
|
||
My analysis of the stuff is in bug 416411 comment 19. If we do in fact cache this stuff now, that's great news. Some of the string code is still pretty iffy, but if it's not called much it's less of an issue.
Comment 4•16 years ago
|
||
I reran the measurements with cvs trunk as of 19 Feb 2008. Now, 3.6% of autostrings are assigned to other strings, which is in line with the numbers for other pages I've tested. I'll leave the decision on how to mark the bug to those who actually the code.
Reporter | ||
Updated•16 years ago
|
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → WORKSFORME
Comment 5•16 years ago
|
||
Not a blocker but it's probably a good idea to clean up the string code noted in bug 418536 comment 19: > 15% gfx/thebes/src/gfxFont.cpp:671 (in ResolveData::ResolveData) I just looked at the consumers, and it looks to me like mGenericFamily could just be a |const nsACString&|. Then we'd avoid the string copy altogether. Probably worth a separate bug as well. > 15% gfx/thebes/src/gfxQuartzFontCache.mm:205 This one is tough, since we copy and immediately modify. This might or might not work better with the two-arg form of ToLowerCase. It also might or might not work better if callers can sort out whether they already have a lowercased string... > 15% gfx/thebes/src/gfxPlatform.cpp:253 (in AppendGenericFontFromPref) The code here should be more like: NS_ConvertUTF16toUTF8 genericDotLang(genericName); That would save an object construction and a string copy. There's similar code above: 279 genericName = NS_ConvertASCIItoUTF16(aGenericName); That should likely be: CopyASCIItoUTF16(aGenericName, genericName);
Status: RESOLVED → REOPENED
Priority: -- → P4
Resolution: WORKSFORME → ---
Version: unspecified → Trunk
Updated•16 years ago
|
Summary: Many string allocations (20k!) from AppendPrefFonts via gfxFontGroup::ForEachFont → cleanup string handling in font code
Flags: wanted1.9.0.x+
Flags: blocking1.9?
Flags: blocking1.9-
Comment 6•13 years ago
|
||
John, is this still wanted?
Comment 7•13 years ago
|
||
Yes, this code still hasn't been cleaned up and should be.
Updated•8 years ago
|
Assignee: jd.bugzilla → nobody
Updated•2 years ago
|
Severity: normal → S3
Updated•1 year ago
|
Component: Graphics → Graphics: Text
You need to log in
before you can comment on or make changes to this bug.
Description
•