-
Notifications
You must be signed in to change notification settings - Fork 806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate core text performance with DWrite stack #1374
Comments
One demo scenario is the non-standard edit control in xamlcatalog. |
There was one thing that stood out during perf analysis - we spent a lot of time in DWriteWrapper.mm _DWriteGetFontPropertiesFromName(), specifically in __CFLocaleCopyCurrent. While this is a result of #1490, the font properties don't need to be localized, and there is no need for any usage of cflocale in this file. CFLocaleCopyCurrent() can hence go away and nullptr can be used where locale is needed. |
- Remove NSLayoutManager __lineHasGlyphsAfterIndex(), which is called multiple times per line - Instead, directly search for the index of the last visible glyph once, compare against this - DWriteWrapper_CoreText - Skip first range of attributes in __DWriteTextLayoutCreate() - was redundant due to the underlaying Format already taking it into account - reserve() ahead of time for glyphRunDescriptionInfo._clusterMap, CTRun->_glyphOrigins, ->_glyphAdvances - A lot of time was being spent in reallocation, resizing - Remove DWriteWrapper _GetUserDefaultLocaleName(), don't wrap in a wstring, directly use a wchar_t buffer - Reduce the number of character buffer copies in _CFStringFromLocalizedString() by 1 - Remove unused/not useful _characters member from CTTypesetter - Misc Related to microsoft#1374
- Remove NSLayoutManager __lineHasGlyphsAfterIndex(), which is called multiple times per line - Instead, directly search for the index of the last visible glyph once, compare against this - Was previously about ~10% of the CPU time of [NSLayoutManager __layoutAllText], now negligible - DWriteWrapper_CoreText - Skip first range of attributes in __DWriteTextLayoutCreate() - Was redundant due to the underlaying Format already taking it into account - Saves about 8% of CPU time in __DWriteTextLayoutCreate() - reserve() ahead of time for glyphRunDescriptionInfo._clusterMap, CTRun->_glyphOrigins, ->_glyphAdvances - Was previously about 8~10% of _DWriteCreateFrame()'s CPU time, now negligible - Remove DWriteWrapper _GetUserDefaultLocaleName(), don't wrap in a wstring, directly use a wchar_t buffer - Performance impact not measured, likely to be fairly small - Reduce the number of character buffer copies in _CFStringFromLocalizedString() by 1 - Saves 20%~30% of CPU time in _CFStringFromLocalizedString() - Remove unused/not useful _characters member from CTTypesetter - Misc Related to microsoft#1374
- Remove NSLayoutManager __lineHasGlyphsAfterIndex(), which is called multiple times per line - Instead, directly search for the index of the last visible glyph once, compare against this - Was previously about ~10% of the CPU time of [NSLayoutManager __layoutAllText], now negligible - DWriteWrapper_CoreText - Skip first range of attributes in __DWriteTextLayoutCreate() - Was redundant due to the underlaying Format already taking it into account - Saves about 8% of CPU time in __DWriteTextLayoutCreate() - reserve() ahead of time for glyphRunDescriptionInfo._clusterMap, CTRun->_glyphOrigins, ->_glyphAdvances - Was previously about 8~10% of _DWriteCreateFrame()'s CPU time, now negligible - Remove DWriteWrapper _GetUserDefaultLocaleName(), don't wrap in a wstring, directly use a wchar_t buffer - Performance impact not measured, likely to be fairly small - Reduce the number of character buffer copies in _CFStringFromLocalizedString() by 1 - Saves 20%~30% of CPU time in _CFStringFromLocalizedString() - Remove unused/not useful _characters member from CTTypesetter - Misc Related to #1374
Summary of current CoreText performance issues after #1558 and assorted recommendations: UIKit functions to watch:
Bottlenecks:
|
We have a few inefficiencies:
RenderTarget Begin/EndDraw() is called for each rendering block (glpyh runs), which will cause performance issues because EndDraw() is expensive. We should batch these calls and known points.
Creating of numerous dwrite factory instances.
Static initializations.
The text was updated successfully, but these errors were encountered: