Skip to content

Unnessasery calls to CultureInfo.GetCultures(CultureTypes.AllCultures) on every request kills performance #43

@pbering

Description

@pbering

What happened?

Description

All OS cultures are loaded and iterated on each and every request besides /, see https://github.com/Sitecore/ASP.NET-Core-SDK/blob/main/src/Sitecore.AspNetCore.SDK.RenderingEngine/Routing/LanguageRouteConstraint.cs#L26

Without ASP.NET OutputCache the issue is not that severe, ~15 req/sec (1.000 requests, concurrency 10) but when enabling OutputCache then / does ~40.000 req/sec (5.000 requests, concurrency 50) but all other pages only ~4.000 req/sec!

I see no reason to call CultureInfo.GetCultures(CultureTypes.AllCultures) at all since all supported cultures are already defined on Microsoft.AspNetCore.Builder.RequestLocalizationOptions.SupportedCultures during startup in UseRequestLocalization, see https://github.com/Sitecore/ASP.NET-Core-SDK/blob/main/tests/Sitecore.AspNetCore.SDK.RenderingEngine.Integration.Tests/Fixtures/Localization/AdvanceLocalizationFixture.cs#L49.

Reproduction Steps

  1. Enable ASP.NET OutputCache
  2. Measure throughput on / and some other route, you will see a ~10x slow down on the other route
  3. Remove calls in startup to Sitecore.AspNetCore.SDK.RenderingEngine.Extensions.MapSitecoreLocalizedRoute
  4. Measure throughput on / and some other route, you will see similar throughput of both root and the other route

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions