Skip to content

Optimize Dictionary<> allocation #393

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

Merged
merged 4 commits into from
Jun 11, 2025

Conversation

SergeiPavlov
Copy link
Collaborator

@SergeiPavlov SergeiPavlov commented Jun 10, 2025

  • Allocate EntityMappingCache.Items Dictionary<> on demand
  • Make immutable MaterializationContextCtor static
  • Reduce allocations in Translator.Optimize()
  • Remove unused string.Contains() extension

@SergeiPavlov SergeiPavlov changed the title Make MaterializationContext readonly struct Optimize Dictionary<> allocation Jun 10, 2025
@@ -80,16 +80,17 @@ internal TranslatedQuery Translate(ProjectionExpression projection,
return translatedQuery;
}

private static readonly IReadOnlyList<ColNum> SingleColumn = [0];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's not worth to keep it in a variable. Compiler should be smart enough to do it on its own.

Copy link
Collaborator Author

@SergeiPavlov SergeiPavlov Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to rely on compiler if it is easy to make it optimal manually?
And we are not sure about the compiler.

@SergeiPavlov SergeiPavlov merged commit 8b2463c into master-servicetitan Jun 11, 2025
5 checks passed
@SergeiPavlov SergeiPavlov deleted the MaterializationContext branch June 11, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants