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

Attribute.IsDefined is a perf hotsport during model building #25891

Closed
roji opened this issue Sep 6, 2021 · 1 comment
Closed

Attribute.IsDefined is a perf hotsport during model building #25891

roji opened this issue Sep 6, 2021 · 1 comment

Comments

@roji
Copy link
Member

roji commented Sep 6, 2021

In #20135, building a user-submitted model shows a huge amount of time spent in Attribute.IsDefined, called from ForeignKeyAttributeConvention.FindForeignKeyAttributeOnProperty (and other conventions). I suspect that the inherit flag increases the perf cost, and the model in question seems to have quite a bit of hierarchy.

In addition, it seems like the same MemberInfo gets checked more than once; introducing a simple Dictionary<MemberInfo, bool> cache in ForeignKeyAttributeConvention for the results of Attribute.IsDefined reduced model building time from 79 to 45 seconds. After this I can still see other call-side for Attribute.IsDefined showing up (e.g. PropertyAttributeCOnventionBase) - we may want to investigate if it makes sense to be traversing the same members/entity types multiple times, and if so, consider adding caching.

@AndriySvyryd
Copy link
Member

Duplicate of #13691

Also #214 will allow to remove the attribute conventions if attributes aren't used for model configuration.

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants