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
[Enhancement] RouteCollection and UrlMatcher Performance #18145
Comments
Does this also happen with the dumped UrlMatcher? Or is this optimization for when you don't dump the UrlMatcher. |
I think that the only use for this enhancement is when you don't dump the UrlMatcher. If I'm not mistaken sf group routes when you dump right? |
@leonelvsc thanks for opening this issue to try to improve Symfony's UrlMatcher. Since Symfony dumps the UrlMatcher to PHP code even in the dev environment, I'd like to ask you in which scenarios do you think this improvement could be used. The Routing component is a critical piece for Symfony framework, so we are always very reluctant to change anything on it (except bug fixes). Thanks! |
Well as i said before the only useful case is when you don't wanna dump the UrlMatcher , ie: another project that is using this component but not the symfony framework. But taking in count that is a critical piece of the framework it self , and this is not a major improvement , this proposal has no sense at all. |
I'm closing this as "fixed". Although we didn't implement this exact proposal, in Symfony 3.3 we optimized both the UrlMatcher and the UrlGenerator. See https://symfony.com/blog/new-in-symfony-3-3-faster-routing |
Hi all, first than anything my english it's not so good so i apologize and this is just a suggestion.
Reading the RouteCollection class i saw that currently you store the routes in an array and then in the UrlMatcher you iterate the routes array until you find a match.
My suggestion is that you use a Hash structure in the array for optimizing performance , i.e if the app has 100000 routes that loop for in the UrlMatcher class has to iterate all the array (in the worst case).
Maybe we can research if it's possible to store routes in the following way.
For the RouteCollection class add a hashedRoutes array
Then when you add a route to the collection you build some sort of hash
i.e
then we could add the following method to the RouteCollection
Of course that for this to work we would have to regenerate the hash in several methods of the RouteCollection i.e the addPrefix method
Then if we store the Routes in a Hash inside the RouteCollection the UrlMatcher class can take advantage of this, and just itarate over the routes that matches the hash , i.e
The text was updated successfully, but these errors were encountered: