-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Slow performance of ILocalizationProvider.Translate<T>() #341
Comments
The |
@hangy Looks like a good optimization. But is there a way to fill in the properties that avoids converting to and from JSON? |
noice! :) @stefanolsen there might be some options for that. json route was the lazy old man path |
I guess it could be filled in with Reflection. Sort of like how Newtonsoft.Json fills in properties on an object. Like:
Although, Newtonsoft.Json runs through all the JSON tokens and then fills properties. While this is the opposite way. But it is the gist of my idea. |
@valdisiljuconoks I think I cracked the case on replacing JSON conversion with reflection. It is still rather crude code, and it is not yet benchmarked. But it passes all the unit tests. |
never trust unit tests ;) but you are awesome guys! 🤙 I never had time to look closely on perf. there are many unoptimized anomalies.. |
you also motivated me to work on v9 specifically focusing on bottlenecks |
You are right about the unit tests. They are not a full proof. Can we do a prerelease NuGet (marked so solutions doesn't auto-update)? Then I could test with a solution where we use regular, nested and static resource classes. |
If you do a version 9, then I would suggest to:
|
@valdisiljuconoks Do you want me to merge this PR into a v9 branch instead of master? |
I changed base already for the PR. will go through later tonight and merge all pending stuff. we can push pre-release nuget if you wanna test out. |
@stefanolsen are you looking for testing this is opti? I'm targeting v9 to net9... |
@valdisiljuconoks Yes, I will test on Optimizely CMS 12. |
that one will be still running on net8? |
@valdisiljuconoks Yes, .NET 8. I also have a project using .NET 9. So cross-compiling for both will be great in v9. |
@valdisiljuconoks Just did a code profiling session on the same site and page, with the v9 branch build. And the results were very nice. Now the bottleneck is moved to I wonder if there is a way to avoid the KnownKeys, and maybe cache the data in a different way. So that the loading on each request gets less intensive. |
@stefanolsen yeah, I never liked |
@valdisiljuconoks Nice! Is it materialized to dictionary before or after adding to cache? Regarding caching. Would you prefer to cache every single resource separately (one cache key for each) and a list of all resources? Sort of like how Optimizely CMS caches many things internally. Or would you like to cache the result of conversion (like how Optimizely CMS caches read-only content instances)? This would require some changes to the data layer, so that ReflectionConverter can load a scoped set of resources from the data store. Then it would only cache the resulting objects, so they don't need to be done on every request. |
GetAllResources already returns a dictionary. But I haven't decided on cache heuristics.. it's next |
During a code profiling session, I found that 36% of the running time is spent on this line:
LocalizationProvider/common/src/DbLocalizationProvider/LocalizationProvider.cs
Line 237 in 4c0d66e
The test scenario is a start page with various blocks. Two of these blocks are instances of the same block type, which uses the
ILocalizationProvider.Translate<T>()
method.Is there a way to get rid of both serialization and deserialization in that method?
The text was updated successfully, but these errors were encountered: