Skip to content
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

NegotiateAuthentication larger code size and also brings in BigInteger #90898

Closed
NinoFloris opened this issue Aug 21, 2023 · 13 comments · Fixed by #90957
Closed

NegotiateAuthentication larger code size and also brings in BigInteger #90898

NinoFloris opened this issue Aug 21, 2023 · 13 comments · Fixed by #90957
Assignees
Labels
area-System.Net.Security bug size-reduction Issues impacting final app size primary for size sensitive workloads tenet-performance Performance related issue
Milestone

Comments

@NinoFloris
Copy link
Contributor

NinoFloris commented Aug 21, 2023

Afaik the following PR #87930 is part of .NET 8.0 preview 7, it caused a 60kb size regression for us:

preview 6: https://github.com/npgsql/npgsql/actions/runs/5930686472
preview 7: https://github.com/npgsql/npgsql/actions/runs/5931742857

Mostly due to it bringing in BigInteger (and a managed NegotiateAuthentication impl?)

Not sure what we can or want to do here.

/cc @filipnavara

Screenshot 2023-08-22 at 00 04 06
@NinoFloris NinoFloris added the tenet-performance Performance related issue label Aug 21, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 21, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 21, 2023
@vcsjones vcsjones added area-System.Net.Security and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Aug 21, 2023
@ghost
Copy link

ghost commented Aug 21, 2023

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Afaik the following PR #87930 is part of .NET 8.0 preview 7, it caused a 50kb size regression for us:

preview 6: https://github.com/npgsql/npgsql/actions/runs/5930686472
preview 7: https://github.com/npgsql/npgsql/actions/runs/5931742857

Mostly due to it bringing in BigInteger (and a managed NegotiateAuthentication impl?)

Not sure what we can or want to do here.

/cc @filipnavara

Author: NinoFloris
Assignees: -
Labels:

area-System.Net.Security, tenet-performance, untriaged

Milestone: -

@wfurt
Copy link
Member

wfurt commented Aug 22, 2023

what platforms is this on @NinoFloris? I think we do want to keep the managed implementation in. We can perhaps try to make it more trimming friendly.

@NinoFloris
Copy link
Contributor Author

These builds were done on ubuntu

@filipnavara
Copy link
Member

It should be trimmed out on Linux for NativeAOT unless the UseManagedNtlm option is turned on. I'll have a look.

@filipnavara
Copy link
Member

filipnavara commented Aug 22, 2023

Can you try adding this to the test app .csproj?

<ItemGroup>
  <RuntimeHostConfigurationOption Include="System.Net.Security.UseManagedNtlm" Value="false" Trim="true" />
</ItemGroup>

Generally the idea is that the ILLink substitution (https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Security/src/ILLink/ILLink.Substitutions.xml) will turn System.Net.NegotiateAuthenticationPal.UseManagedNtlm into false and trim away the rest of the code. There are two possible failures that I can think of: 1) the substitution not taking place when the feature option is not specified at all, and 2) the resulting branch trimming not happening.

UPD: Apparently this doesn't help. :-/
UPD2: It does actually work, I just forgot to add Trim="true".

@filipnavara
Copy link
Member

filipnavara commented Aug 22, 2023

I reread the ILLink documentation and it seems we are missing featuredefault="true" attribute there. On .NET 9 we would need to conditionally use different substitution for macOS/iOS though.

@NinoFloris
Copy link
Contributor Author

Does that mean it should be fixed for rc2 or where do we stand? Npgsql is a library, I can't ask people to flip these switches for us.

@filipnavara
Copy link
Member

I will try to submit the fix and then we can see about backports.

@filipnavara
Copy link
Member

I was not able to get featuredefault to do the right thing on NativeAOT yet. I'm trying to figure out whether it is supposed to work, or not. The alternative is to specify the option through RuntimeHostConfigurationOption in the NativeAOT build integration. I'll post once I have more details to share.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Aug 22, 2023
@karelz karelz added this to the 9.0.0 milestone Aug 29, 2023
@karelz karelz removed their assignment Aug 29, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Aug 29, 2023
@karelz
Copy link
Member

karelz commented Aug 29, 2023

Triage: @wfurt discussed it with @jkotas and his suggestion was to NOT take it for 8.0 as it is size improvement, but not functional impact.
@NinoFloris are you ok with that for npgsql customers? (cc @roji)

@filipnavara
Copy link
Member

I generally agree it doesn't meet the bar for 8.0 servicing, but should we try to backport the SDK switch (dotnet/sdk#34903) to make the workaround easier?

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Aug 29, 2023
@NinoFloris
Copy link
Contributor Author

Thanks, @karelz we are. We have added an explicit opt-in to our slim builder for "integrated security" auth, sidestepping the issue.

@karelz karelz added bug size-reduction Issues impacting final app size primary for size sensitive workloads labels Aug 29, 2023
@roji
Copy link
Member

roji commented Aug 29, 2023

Yeah, agreed this isn't critical for a 8.0 backport.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Security bug size-reduction Issues impacting final app size primary for size sensitive workloads tenet-performance Performance related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants