Fix DebuggableAttribute in InjectModuleInitializer post-build targets #1745
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses #1549
In the ReconstituteDll target, we call ILAsm to merge a module constructor into the assembly we previously disassembled. We need to enable JIT optimizations here so that we get an appropriate DebuggableAttribute on the assembly and don't cause perf problems.
@vatsan-madhavan who helped debug and find this fix.
Issue: #1549
PR:#1745
Description
Fix DebuggableAttribute in PresentationCore.dll
Background:
In .NET Core 3.0 Preview 6 and .NET Framework 4.x, PresentationCore was a single assembly that consisted of C# and C++/CLI components merged together by link.exe (using netmodules as inputs).
In Preview 2, PresentationCore was split into C# and C++/CLI component assemblies (PresentationCore and DirectWriteForwarder, respectively) to work around bugs in the new C++/CLI toolsets that prevented them from being merged into a single DLL effectively.
Due to this split, a module constructor implemented (#741) on the C++/CLI side was no longer running in the same initialization order with respect to the rest of WPF. This caused regressions in WPF’s high DPI support (#334)
Issue Details:
The fix for the high DPI issue (#741) introduced a regression where the
DebuggableAttribute
on PresentationCore was not being correctly set and was disabling JIT optimizations (by settingDebuggingModes.DisableOptimizations
on PresentationCore.dll)This is causing a 30% perf regression in warmed up repro applications and close to 50% in cold start scenarios. These regressions mainly revolve around text rendering and layout code which is the main set of code that was split off in the aforementioned Preview 2 change.
After investigation across WPF and the JIT teams, WPF was alerted to the incorrect attribute and we root caused it to a missing parameter in ILAsm (used to inject a module constructor into PresentationCore) to enable JIT optimizations.
After this change, PresentationCore will have
DebuggingModes.Default | DebuggingModes.IgnoreSymbolStoreSequencePoints
, which is functionally identical to all other “Release” configuration assemblies.### Customer Impact
Severity:
All text rendering is at least 30% slower across the board in WPF.
We tested this via several applications that render large amounts of text via different methods:
When testing without warm-up, the regression is more than 30% (50%-ish).
Applicability:
DataGrid
, for e.g., in an LoB app) will be affected immediately.For e.g., if text is shown in a
ListBox
orDataGrid
, and a user interacts with it to look at data, the changes in the text will immediately affect performance.Regression?
Yes, from .NET Framework 4.8 and .NET Core 3 Preview 5
Risk
DebuggableAttribute
configuration.DebuggableAttribute
is generally used across all other managed WPF binaries.