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

Routing performance improvements #38117

Open
javiercn opened this issue Nov 5, 2021 · 4 comments
Open

Routing performance improvements #38117

javiercn opened this issue Nov 5, 2021 · 4 comments
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing Priority:1 Work that is critical for the release, but we could probably ship without

Comments

@javiercn
Copy link
Member

javiercn commented Nov 5, 2021

We've seen some issues with large DFAs as a result of some patterns that involve a large amount of variable prefixes. We've done work in 6.0 to address this via automatically trimming the DFA we generate by leveraging existing route constraints as well as the existing structure in complex segments.

However, all these techniques don't guarantee smaller DFAs (although in most common cases they will) and require explicit actions from the user to identify and address this issue (adding constraints to the app). We believe there are other optimizations we can do in this space that will have an impact in the size of the DFA without involving explicit user action.

This is critical to provide a good experience for large applications as well as proxy servers like YARP as it contributes to reduce the memory footprint required to run those apps.

In addition to this, there are other things we want to consider with regards to performance on a per request basis. Our MapFallback APIs greatly negatively impact matching on other scenarios as they force a dynamic endpoint on to all the endpoint candidate lists of the app.

  • For Blazor it will be ideal a "tighter" integration with ASP.NET Core routing to clearly identify the set of routes the app uses.
  • For other SPA frameworks to provide the ability to read the list of client routes generated at build time from a file to narrow down the set of patterns involved.

Another initiative to pursue in this area is the ability to have more powerful matching primitives on a segment. Proxying scenarios involve matching a segment but not capturing the value, which reduces allocations per request. We do custom processing for complex segments where we perform our own "pseudo-regex" matching. We are also interested on some potential new "regex segment" as a more powerful expression of complex segments.

You can currently use regex constraints in parameters, however that leads to an awkward syntax and doesn't allow for capturing subsets of the regex expressions. These come in to play in proxying scenarios and other servers offer similar functionality. This might allows us to do two things:

  • A more powerful version of complex segments, where the parts that aren't parameter don't have to be literals.
  • A way to optimize existing complex segments by transforming them into "regex" segments.
  • A way to offer non-capturing segments/parameters via non-capturing groups in the regex.
  • A way to optimize all these patterns at compile time if we are able to work with the runtime folks to generate the regex code at compile time using the experimental regex source generator.

#33749
#27996
#27840

@javiercn javiercn added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-routing jcn-p0 labels Nov 5, 2021
@javiercn
Copy link
Member Author

javiercn commented Nov 5, 2021

#19772

@javiercn javiercn added this to the .NET 7 Planning milestone Nov 5, 2021
@mkArtakMSFT mkArtakMSFT added Priority:1 Work that is critical for the release, but we could probably ship without triaged labels Nov 11, 2021
@ghost
Copy link

ghost commented Sep 14, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@mkArtakMSFT mkArtakMSFT added triaged enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Oct 26, 2022
@surayya-MS surayya-MS self-assigned this Feb 23, 2023
@javiercn javiercn assigned surayya-MS and unassigned surayya-MS Jul 26, 2023
@ghost
Copy link

ghost commented Oct 10, 2023

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@surayya-MS surayya-MS removed their assignment Dec 7, 2023
@andrewjsaid
Copy link
Contributor

I've created an issue/PR which may go a small way towards improving routing perf.
#52812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-routing Priority:1 Work that is critical for the release, but we could probably ship without
Projects
None yet
Development

No branches or pull requests

8 participants