-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Enumerate paramnames on startup #46086
Enumerate paramnames on startup #46086
Conversation
Thanks for your PR, @marafiq. Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
@mitchdenny Assigning this to you to look at since the corresponding issue is assigned to you. |
Also looping in @captainsafia since she would be interested in seeing the PR and is doing some stuff in AOT in this area. On the surface this doesn't look like a breaking API change (good) - but in terms of performance impact in an actual application I don't think I can see the impact. One thing to point out with the benchmark is that you've got 10 route parameters - that is actually a lot when you consider even quite nested APIs such as:
I re-ran the benchmark with 3 route parameters and the results aren't quite as dramatic in that case:
Let's imagine an application with a modest number of 3 parameter routes (say a 10):
|
Thanks for taking a look at us @mitchdenny
As you have seen in your benchmark run, there are slight improvements in allocation and some ns. There is not nothing else in terms of impact. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will probably not merge this kind of micro-optimization unless it is on a really hot path in the future. If the optimization is large enough that it would show a statistically significant impact on the overall RequestDelegateFactory.Create(Delegate)
call, that would be a different story.
That said, I appreciate the initiative! Given that the microbenchmark shows an improvement, and that the code is as easy to follow as it was before imo, I think we should merge the PR this time.
Thanks for contributing!
Enumerate endpoint parameter names on startup instead of allocating a list.
Enumerate endpoint parameter names on startup instead of allocating a list.
Summary of the changes
Use Enumerable instead of List to save allocation
Use of
IEnumerable<string>
when getting the endpoint parameters names from the collection, which then gets used to create theRequestDelegateFactoryContext
Fixes #46010