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

Massive performance hit when upgrading from 1.0.8.18 to 1.0.9 #236

Closed
ascott18 opened this issue Jan 4, 2019 · 11 comments
Closed

Massive performance hit when upgrading from 1.0.8.18 to 1.0.9 #236

ascott18 opened this issue Jan 4, 2019 · 11 comments
Labels

Comments

@ascott18
Copy link
Contributor

ascott18 commented Jan 4, 2019

We have a bit of code that, in this example, ends up calling .OrderBy("SomeProperty ASC, SomeOtherProp DESC") a total of 262 times, each time on an EnumerableQuery<T> (that is, LINQ to objects rather than LINQ to sql).

With 1.0.8.18, the total CPU time spent in System.Linq.Dynamic.Core.DynamicQueryableExtensions::OrderBy was ~58ms. In 1.0.9, the total CPU time for the same code against the same data is ~17691ms:

image

It appears that System.Linq.Dynamic.Core is iterating over every single type currently loaded into the app domain, and pulling the custom attributes from every one of those types? Why is it doing this? Why does it do this on every single call to OrderBy()?

ascott18 referenced this issue in IntelliTect/Coalesce Jan 4, 2019
@StefH
Copy link
Collaborator

StefH commented Jan 5, 2019

  1. Are you using NET Full framework (4.x ?) or NETStandard/NetCore ?
  2. And do you have set AllowNewToEvaluateAnyType to true or false in the config?

@StefH
Copy link
Collaborator

StefH commented Jan 5, 2019

#237

@StefH
Copy link
Collaborator

StefH commented Jan 5, 2019

@ascott18
Can you try MyGet package:
https://www.myget.org/feed/system-linq-dynamic-core/package/nuget/System.Linq.Dynamic.Core/1.0.9.1-ci-1643 ? This should hopefully fix your issue.

@ascott18
Copy link
Contributor Author

ascott18 commented Jan 5, 2019

This was with net471, and all config is default.

Thanks for the fix - I won't have a chance to try it out for a while, though.

@StefH
Copy link
Collaborator

StefH commented Jan 6, 2019

@ascott18 When do you have time to validate?

@ascott18
Copy link
Contributor Author

ascott18 commented Jan 7, 2019

Its an order of magnitude better than 1.0.9, but still ~2 orders of magnitude worse than it was in 1.0.8.18, to the extent that it will still be unusable for our use cases:

image

@StefH
Copy link
Collaborator

StefH commented Jan 7, 2019

How did you do that exact profiling?

@ascott18
Copy link
Contributor Author

ascott18 commented Jan 7, 2019

In VS 2017 preview:

  • Start my application in debug

  • Put a breakpoint before and after my code that is doing all the calls to OrderBy

  • When the breakpoint before is hit, turn on "Record CPU Profile" in the Diagnostic Tools window, and then continue
    image

  • When the second breakpoint is hit, the CPU profile results will be analyzed and displayed.

  • Scroll down in the CPU profile results to the lines for OrderBy. Right-click one of the OrderBy lines, and choose something like "display in call tree" (can't remember exactly what it says).

@StefH
Copy link
Collaborator

StefH commented Jan 7, 2019

I found the issue, the types were not cached anymore. I added the caching again, this should be fixed in MyGet version 1.0.9.1-ci-1661. Can you please test this?

@ascott18
Copy link
Contributor Author

ascott18 commented Jan 7, 2019

Thanks - that fixed it completely!

@StefH
Copy link
Collaborator

StefH commented Jan 7, 2019

Official version 1.0.9.1 will be released in some time.

@StefH StefH closed this as completed Jan 7, 2019
@StefH StefH added the bug label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants