-
Notifications
You must be signed in to change notification settings - Fork 934
Optimize LINQ batch item processing for queries with overridden result type #2350
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
Conversation
public static class LinqBatchItem | ||
{ | ||
internal static ConcurrentDictionary<System.Type, Func<ILinqBatchItem, IList>> GetResultsForTypeDic = new ConcurrentDictionary<System.Type, Func<ILinqBatchItem, IList>>(); |
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.
Let's generate compiled delegate returning typed results and cache it per result type.
Example of generated delegate for int?
type:
IList GetTypedResuls(ILinqBatchItem batchItem) => batchItem.GetTypedResults<int?>();
It's OK to have static cache as it will contain only few items (and for now it's only for nullable types)
return null; | ||
} | ||
var elementType = _postExecuteTransformer.Method.GetParameters()[1].ParameterType.GetGenericArguments()[0]; | ||
if (typeof(T).IsAssignableFrom(elementType)) |
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.
There is no need to do such analysis - if type is overridden its type provided in ExpressionToHqlTranslationResults.ExecuteResultTypeOverride
What is the performance improvement? |
Negligible to investigate. That's some old work that's been dusting in my local repos. If you think that compiled expression generation looks ugly or may worsen the perf - I will undo this part and just leave it as clean up PR that removes unnecessary |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…fields unnecessary initialization
No description provided.