Allow some Globalization code to be dynamically removed.#596
Allow some Globalization code to be dynamically removed.#596marek-safar merged 1 commit intodotnet:masterfrom
Conversation
| if (FeatureGlobalization) | ||
| ExcludeGlobalization (type); | ||
|
|
||
| if (RemoveCustomAttributes (type)) { |
There was a problem hiding this comment.
This block has already been merged, ignore.
| public bool FeatureCOM { get; set; } | ||
| public bool FeatureETW { get; set; } | ||
| public bool FeatureSRE { get; set; } | ||
|
|
There was a problem hiding this comment.
This block has already been merged, ignore.
| FeatureCOM = excluded_features.Contains ("com"), | ||
| FeatureETW = excluded_features.Contains ("etw"), | ||
| FeatureSRE = excluded_features.Contains ("sre"), | ||
| FeatureGlobalization = excluded_features.Contains ("globalization") |
There was a problem hiding this comment.
This block has already been merged, ignore.
|
Please disregard the SRE changes; I intentionally made this draft against an older version of the linker as I'm having some difficulties with the SDK-style projects in VSMac. I got them to build, but Intellisense is completely messed up, thus making it very hard to edit / debug. |
|
All sizes are from the wasm profile.
|
|
Trying to analyzing the difference between the linker and my tool ...
still investigating .... |
|
With my tool, but without touching Now when looking at individual classes / method - but tool does not account for metadata size, so these numbers are a bit off on the lower side. The entire However, I can also do a diff between individual classes.
Okay, I think that gave me a few methods to look at and apply the same technique. |
|
Disregard this (generated output from my tool), it's just for my own reference later on. |
|
Disregard as well; generated output. |
|
Okay, looking at However, we can try to split that method into two parts then use the trick showed in this draft to remove one of them - this should have about the same effect. And we can probably apply the same technique to some other functions as well. But even without that, we still have |
@baulig Out of curiosity, what tool are you referring to? |
|
Latest commit brought us to 680448 versus 675328, slowly getting better ... |
It's a research project that I've been working on recently. I created a tool called "Linker Optimizer" that does basic block scanning and dead code elimination. |
|
Neat. We have things like that in our UnityLinker. I've mentioned it to @marek-safar a couple times in passing over the past year or so. The conclusion at the time has always been that it was best to keep the logic in our linker so that we could iterate faster. Maybe the time is near to bring our efforts upstream and combine forces? Or do you have a completely different approach you are looking to take (i.e. not inside monolinker)? |
|
I would absolutely love to collaborate more on these issues instead of us duplicating work. The reason why I put my tool into a separate module was simply because I needed something fast to use during my day-to-day work and it was easier and faster for me to have it in a place where I can easily modify it at any time without worrying about breaking or blocking somebody else's work. However, long-term we should look into incorporating that into the linker in some way. |
|
BCL PR's are now up: mono/corefx#298 and mono/mono#14825. We need to bump CoreFX after landing that one. |
f0978e6 to
0c3112a
Compare
This requires mono/corefx#298 and mono/mono#14825. We are using the same techinique as previously employed in dotnet#590 to dynamically remove the `System.Reflection.Emit` code. Since the linker does not currently support dead code elimination, it cannot break down any conditionals inside method bodies. One trick that we use to work around this is to move those conditional pieces into separate methods; then we can give the linker a list of those methods and tell it to replace their bodies with exceptions. After this has been done in the BCL, we need to explicitly tell the linker to turn those method bodies into stubs when `--exclude-feature globalization`. Ideally, we would want to use `MethodAction.ConvertToStub` instead of `ConvertToThrow` here, but we'd have to extend the code rewriter first to support methods with arbitrary return types and parameters.
0c3112a to
7f18668
Compare
|
build |
Rationale: allow dynamic removal (as it without rebuilding corlib) of some of the globalization code when
--exclude-feature globalizationis provided.Currently removes the Japanese, Taiwan and Hebrew calendars as well as Hebrew numbers.
This requires mono/corefx#298 and mono/mono#14825.
We are using the same techinique as previously employed in #590 to dynamically remove the
System.Reflection.Emitcode.Since the linker does not currently support dead code elimination, it cannot break down any conditionals inside method bodies. One trick that we use to work around this is to move those conditional pieces into separate methods; then we can give the linker a list of those methods and tell it to replace their bodies with exceptions.
After this has been done in the BCL, we need to explicitly tell the linker to turn those method bodies into stubs when
--exclude-feature globalization.Ideally, we would want to use
MethodAction.ConvertToStubinstead ofConvertToThrowhere, but we'd have to extend the code rewriter first to support methods with arbitrary return types and parameters.