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

Cleanup Admin Menu #15199

Merged
merged 12 commits into from
Jan 30, 2024
Merged

Cleanup Admin Menu #15199

merged 12 commits into from
Jan 30, 2024

Conversation

MikeAlhayek
Copy link
Member

@MikeAlhayek MikeAlhayek commented Jan 29, 2024

This PR should reduce allocations and provide a slight better performance.

INavigationProvider are called on every request to the admin page. So if we create new object every time, we have to create a new allocation every request for every client. So here we would reduce multiple allocations.

Also, since the admin menu is something we call, there is no need to check for string invariant.

  • We do not need to performance a invariant check for the admin and adminMenu
  • We don't need to create new object every time.

@MikeAlhayek MikeAlhayek requested a review from Piedone January 29, 2024 16:16
Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

While again I agree that it should be better, did you measure the impact?

@MikeAlhayek
Copy link
Member Author

While again I agree that it should be better, did you measure the impact?

@Piedone I did not measure the performance difference here. However, the INavigationProvider is called on every request. saving allocating these objects for long time make scene to me since they can be accessed by all tenants and we only have to create them once.

@Piedone
Copy link
Member

Piedone commented Jan 29, 2024

I don't disagree, but since performance issues are complex and full of surprises, we shouldn't act solely on theory.

@MikeAlhayek
Copy link
Member Author

@Piedone so you good with this PR?

@Piedone
Copy link
Member

Piedone commented Jan 30, 2024

Not yet, we still need measurements. Knowing OrchardCore.CustomSettings.AdminMenu is great, but that was one class with something unique, while there are a lot more with the anonymous object instantiation -> static RouteValueDictionary pattern of change. I don't expect that to be worse, but still.

@MikeAlhayek
Copy link
Member Author

@Piedone not sure what you want to measure here. The rest of the changes either we remove the initialization completely, or we create an object once and reuse it every time. Do you have an idea for benchmarking that you want me to try?

@MikeAlhayek
Copy link
Member Author

@Piedone I just did a benchmark to see how much memory allocation is saved over 100k requests one a single object initialization

Does this paint the picture or are there a specific test you have in mind. Its actually quite nice to be able to see these number and the amount of memory allocation you save with small tricks. as simple as one constant variable saves 12mb in memory allocation over 100k requests.

image

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

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

Awesome!

@MikeAlhayek MikeAlhayek merged commit 7fbf4a5 into main Jan 30, 2024
5 checks passed
@MikeAlhayek MikeAlhayek deleted the ma/admin-menu branch January 30, 2024 17:09
hishamco pushed a commit that referenced this pull request Feb 1, 2024
urbanit pushed a commit to urbanit/OrchardCore that referenced this pull request Mar 18, 2024
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.

3 participants