The Wayback Machine - https://web.archive.org/web/20210529002224/https://github.com/dotnet/aspnetcore/pull/33129
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

Fix ResourceManagerStringLocalizerFactory caching #33129

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

@sebastienros
Copy link
Member

@sebastienros sebastienros commented May 29, 2021

The cache key was using reflection which was visible in allocation profiles since it's called for every view that is rendered.

Before:
image

After
image

Allocations

Type Bytes Before Bytes After
GetCustomAttributeRecords 912,000 0
String 2,196,946 2,017,262
The cache key was using reflection which was visible in allocation profiles since it's called for every view that is rendered.
@sebastienros sebastienros requested a review from Pilchie as a code owner May 29, 2021

var assembly = typeInfo.Assembly;
return _localizerCache.GetOrAdd(resourceSource.AssemblyQualifiedName!, _ =>

This comment has been minimized.

@sebastienros

sebastienros May 29, 2021
Author Member

This could just be Add, worst case it's called more than once, but only on first concurrent requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants