-
Notifications
You must be signed in to change notification settings - Fork 351
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
Fix performance regression in DataServiceContext DefaultResolveType method #2569
Fix performance regression in DataServiceContext DefaultResolveType method #2569
Conversation
a5e36a1
to
74071f8
Compare
74071f8
to
9ecd701
Compare
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me. I would request some clarifications on the performance measurements:
- Are the figures shared measuring the expected/best case (i.e., the type is in the
targetAssembly
)? - If the provided figures are for the expected case, could you share figures for the worst case if possible (the type cannot be resolved)
- Could you run the tests on a version of the client before the changes that introduced the regression were made, just so we can have an idea how close it is to initial expectations, if not the same (or better), at least for the common case (the type does exist in the target or entry assembly).
internal static bool TryResolveType(string typeName, string fullNamespace, string languageDependentNamespace, out Type matchedType) | ||
{ | ||
/// <returns>true if a type with the specified name is successfully resolved; otherwise false.</returns> | ||
internal static bool TryResolveType( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we cache the 'Resolving' ?
I mean once we resolved the type, we should cache it for next use, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xuzhg The cache is in the DataServiceContext
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@habbes Failure to find a type to use for materialization when deserializing a payload results into an exception. However, I was able to create a simple benchmark to measure the time the public class DataServiceContextBenchmark : DataServiceContext
{
[Benchmark]
[IterationCount(targetIterationCount: 100)]
public void BenchmarkResolveType()
{
for (var i = 0; i < 250; i++)
{
this.DefaultResolveType("NonExistentType", "NS.Models", "NS.Models");
}
}
} Stats: Before this fix:
After this fix:
The results are a bit inconsistent across runs but it'd be right to say their is an observable improvement after the fix |
Thanks for adding the additional benchmark data. Looks good to me! |
Issues
This pull request fixes #2557, fixes #2514
Description
Fix performance regression in
DataServiceContext
DefaultResolveType
method.Performance improvements stats
Before this fix:
After this fix:
Before the change that introduced the performance regression:
Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.