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

Small optimizations for the ExtensionManager #16382

Merged
merged 25 commits into from
Jul 24, 2024

Conversation

gvkries
Copy link
Contributor

@gvkries gvkries commented Jun 28, 2024

The initialization of the ExtensionManager is synchronous and must always be run before any method can be called. It can therefore be moved into the constructor to avoid a check before any method call.
This is a minor performance optimization, but EnsureInitialized was called at least once during every request and on some requests dozens of times.

I based this optimization on PR #16379.

Note: After discussion, only some minor optimizations are kept here.

Copy link
Contributor

github-actions bot commented Jul 2, 2024

This pull request has merge conflicts. Please resolve those before requesting a review.

@gvkries gvkries marked this pull request as ready for review July 3, 2024 09:53
Copy link
Member

@MikeAlhayek MikeAlhayek left a comment

Choose a reason for hiding this comment

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

Have you done any performance benchmark to understand what is the performance gain here?

src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
@gvkries
Copy link
Contributor Author

gvkries commented Jul 15, 2024

Have you done any performance benchmark to understand what is the performance gain here?

I did not measure this, because I don't think it is worth the effort to test it. Same as e.g. making the classes sealed, which is also hardly measurable inside our code base, but safes some CPU cycles anways. And those tiny optimizations will add up over time.
Additionally, the motivation for this was more to make the code simpler.

@gvkries
Copy link
Contributor Author

gvkries commented Jul 16, 2024

I undid the initialization change and moved it back to the original EnsureInitialize. It's just a lot of work for a c'tor.

So there are only a few optimizations left here, e.g. sealing the class and removing some fields that don't need to be kept alive over the lifetime of the application.

@gvkries gvkries changed the title Move initialization of the ExtensionManager into the c'tor Small optimizations for the ExtensionManager Jul 16, 2024
@gvkries gvkries requested a review from MikeAlhayek July 20, 2024 11:03
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
src/OrchardCore/OrchardCore/Extensions/ExtensionManager.cs Outdated Show resolved Hide resolved
@MikeAlhayek MikeAlhayek merged commit af59baa into OrchardCMS:main Jul 24, 2024
10 checks passed
@gvkries gvkries deleted the gvkries/exmgr-optimzations branch July 24, 2024 07:07
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