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

Remove use of Tuple<> from corelib #44706

Merged
merged 2 commits into from
Nov 17, 2020
Merged

Conversation

stephentoub
Copy link
Member

Related to #44684
cc: @jkotas, @marek-safar

(The flip side of this change, of course, is that if Tuple<T1, T2> is already being used by the rest of the app, this could actually increase the overall size rather than decrease it.)

@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@jkotas
Copy link
Member

jkotas commented Nov 15, 2020

I think this is a good idea. If we take this route, we should also do a pass to remove uses of Tuple in netcoreapp that are easy to avoid. For example, the Tuple use in src\libraries\System.Security.Cryptography.Algorithms\src\Internal\Cryptography\AesImplementation.Unix.cs can be replaced with ValueTuple or custom type.

@stephentoub
Copy link
Member Author

we should also do a pass to remove uses of Tuple in netcoreapp that are easy to avoid

For uses that need to pass a few arguments through an object state, is there a measurable downside to boxing/unboxing a ValueTuple<> instead of using Tuple<>?

@jkotas
Copy link
Member

jkotas commented Nov 15, 2020

is there a measurable downside to boxing/unboxing

I doubt it that the difference is measurable. It is just an extra local copy (ie a few extra mov instructions).

@jkotas
Copy link
Member

jkotas commented Nov 15, 2020

There is a difference between TupleSlim vs. Tuple/ValueTuple for AOT. The full AOT compilers will typically end up generating the code for all interfaces and methods on Tuple/ValueTuple. TupleSlim avoids this overhead.

@stephentoub
Copy link
Member Author

There is a difference between TupleSlim vs. Tuple/ValueTuple for AOT

Right.

for all interfaces and methods on Tuple/ValueTuple

Minus anything that could be trimmed, but presumably the problem here is little can be trimmed because most of the methods are interface implementations or virtual overrides.

It is just an extra local copy

And if it were an issue (which it shouldn't be), there's always Unsafe.Unbox I guess.

@stephentoub stephentoub added the linkable-framework Issues associated with delivering a linker friendly framework label Nov 17, 2020
@stephentoub stephentoub added this to the 6.0.0 milestone Nov 17, 2020
@jkotas jkotas merged commit a5d6b30 into dotnet:master Nov 17, 2020
@stephentoub stephentoub deleted the tupleslim branch November 21, 2020 01:10
@ghost ghost locked as resolved and limited conversation to collaborators Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
linkable-framework Issues associated with delivering a linker friendly framework
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants