-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Constant propagation directly from MarkStep (dotnet/linker#1771)
Call constant propagation and branch removal processing directly from `MarkStep`: * Renames `RemoveUnreachableBlocksStep` to `UnreachableBlocksOptimizer` - it's not a step anymore * Rename members to use the `_name` naming convention (which is also used by `MarkStep`) * Removes the "go over all methods in all assemblies and process them" logic * Some small changes to the `ProcessMethod` API to be more suitable for the `MarkStep` * The class is now instantiated by `MarkStep` and only lives as long as `MarkStep` does * `MarkStep.ProcessMethod` calls the optimizer's `ProcessMethod` before doing anything else on the method (this is because the optimizer can modify methods body, so mark step should only look at the modified version of the method) Some interesting statistics (on console helloworld): * Before this change the optimizer processed 73K methods (every method at least once - total number of methods is 72K). After the change the optimizer only processes 12K methods (so a huge reduction). This also means that the large dictionary maintained by the optimizer on all processed methods is now 20% of before this change. * Max stack size increased to 62 - this is because of different order of processing methods. The 62 comes from `ThrowHelpers` which initializes lot of resource strings (each a separate call to a different method), so at one point all of these dependencies are on the stack. This is not a problem, just slightly higher memory usage. It would become problematic if the stack depth reached several 1000s which is VERY unlikely to happen. * Number of rewritten methods is down to 20% (from 746 to 117) - all of those not rewritten are actually not used by the app * As far as I can tell, it produces the exact same output. Very rough perf measurement on Blazor template app: * Before all the constant prop changes (SDK from early December 2020): 6.1 seconds (on average) * After this change: 3.4 seconds (on average) Commit migrated from dotnet/linker@d8c44b8
- Loading branch information
1 parent
d00ebc7
commit 1e2d7a2
Showing
4 changed files
with
114 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.