-
Notifications
You must be signed in to change notification settings - Fork 127
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
Remove special handling of EventSource #1949
Comments
/cc @LakshanF |
Part of #1349 |
PR #2063 Reverted the earlier checkin and we need to revisit this |
We cannot remove the special handling of EventSource nested classes easily due to the scenarios like the following
Specific example for the above scenario is the internal
|
Is this being stripped during library build? This sounds like an analysis hole with any DAM placed on classes when illink is running in the special "library mode" (and doesn't have whole program view). If illink is running in the library mode, it shouldn't wait to see if |
Yes, specifically for the System.Net.Mail.dll with the
|
Can I just repeat that I hate the library mode ... I think I agree with Michal. The easiest way to implement this would be to add a new CodeOptimization which will enable/disable the "wait for GetType call". |
I think we should move it to the special code path we have for other such cases in library mode (e.g. AssemblyRootMode.Library). We don't need any new CodeOptimization just move the logic there. |
Just handling this on library mode alone might have a larger scope impact than just on type hierarchy (e.g. the |
That's not what I meant. You keep the same logic that does the selection today but instead of the run on every Mark it runs only for types that have Library mode visibility. |
Sorry for misunderstanding. To be specific, do you mean to move the EventSource special handling code to be under the library mode? |
You will probably have to refactor the code a bit but yes. Essentially adding something like the code below to https://github.com/mono/linker/blob/main/src/linker/Linker.Steps/MarkStep.cs#L2537 if ((members & TypePreserveMembers.Library) != 0 && f.IsStatic && BCL.EventTracingForWindows.IsProviderName (f.DeclaringType.Name) (f)) {
MarkField (f, di);
continue;
} |
I don't like that approach. I would much rather implement what Michal suggested. Basically in library mode, the type hierarchy marking will happen regardless of us finding the "usage" for it. I don't think this should be in any way specific to event source. |
I didn't measure it but I expect this to make the mode useless because most libraries build savings comes from removing internal infrastructure types which are needed only for a single platform. It won't also help with the case of private or internal events though not sure how common they are in libraries build. |
Note that the type still has to be referenced by something in the library. By "usage" I meant that linker sees Private or internal events are actually the case where this should help - they are referenced by the library code, but some of the members on them are not references (since they're only accessed via reflection from the EventSource implementation). In order to keep them correctly working, we need to preserve these additional members. The way that works in app-mode is that we apply the annotation (since we see the |
The fix seems reasonable enough with the library optimization mode and only applied if a base type has annotations. |
Some results from runtime build.cmd, specifically from target
The differences are because we apply the DAM for internal derived types. For example,
|
Linker has some special handling of EventSource types:
https://github.com/mono/linker/blob/55bd0ebd00ddbf2cd817314b1cf6824003cfb463/src/linker/Linker.Steps/MarkStep.cs#L1701-L1705
With the changes to support EventSource fully with annotations, this should be removed once the necessary framework changes are made.
The text was updated successfully, but these errors were encountered: