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

Reflection caching #28877

Closed
bugproof opened this issue Mar 5, 2019 · 5 comments
Closed

Reflection caching #28877

bugproof opened this issue Mar 5, 2019 · 5 comments
Labels
Milestone

Comments

@bugproof
Copy link

bugproof commented Mar 5, 2019

Reflection is slow, why isn't it internally cached by default?

@mattwarren
Copy link
Contributor

There's is already some caching, for instance if you fetch a single field/property/method all the other fields/properties/methods on the Type are cached internally.

This is done using RuntimeTypeCache (here) and this search shows you the places in the code that make use of it.

There's other things going on with reflection that also contribute to the overhead, this post explains some of them

@jkotas
Copy link
Member

jkotas commented Mar 5, 2019

What are the specific reflection operations you would like to run faster?

@bugproof
Copy link
Author

bugproof commented Mar 6, 2019

GetCustomAttributes, getting and setting values of fields etc. Emitting IL or using expressions is almost always faster than using vanilla reflection.

There are many libraries like fasterflect or fastmember solving those performance problems so why couldn't it be faster out of the box? Would be cool

@jkotas
Copy link
Member

jkotas commented Mar 6, 2019

Some of the potential solutions are discussed in https://github.com/dotnet/corefx/issues/24390

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the Future milestone Feb 1, 2020
@maryamariyan maryamariyan added the untriaged New issue has not been triaged by the area owner label Feb 23, 2020
@steveharter steveharter removed the untriaged New issue has not been triaged by the area owner label Feb 25, 2020
@steveharter
Copy link
Member

Closing as duplicates of existing perf-related issues including
#19484
#23716
#7560

@ghost ghost locked as resolved and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants