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
[WIP] Performance Improvement : Set name of system routes #9048
Conversation
422 routes exist but |
@hissy: could you try to add this line: $route->setCustomName($name); right before this line: It seems to me that the route names are calculated twice: with this change it should be done only once. Could you try to see if this makes some difference (that is, execution time, less useless calls)? |
@mlocati I'll try it later, but we're generating names nobody can see more than 400 times at every request, even if that change works as expected. |
@mlocati Number of calls dramatically reduced by adding |
I don't disagree that it'd be nice to improve performance... but this makes the routing in the core look a lot uglier by default. Would it be better if we could simply cache these routes in some way, and leave the original registering of routes alone? I think this deserves more discussion. |
With simply #9048 (comment) we can already reduce the time wasted for calculating route names twice. |
Reducing 2.4% of execution time should be a big performance improvement, but yeah, this is not the only way to do that. |
We might be able to follow what the Symfony's Router class does. It caches UrlMatcher class. https://github.com/symfony/routing/blob/3.4/Router.php#L265-L310 |
Yeah, that sounds like a good way forward. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! |
I'm working on it |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions! |
Sorry, it's in my list |
An interesting idea, but let's think about caching the router in some other ways. |
Yeah, I'll try to cache UrlMatcher class like Symfony. Please close this PR |
I don't think it's worth caching it: please remark that we pre-filter the routes (see #7026 ), so that we actually need to compile just a tiny subset of them (is this done by Symfony too?) The problem with caching is that routes may be added on the fly (for an example see https://github.com/concrete5/addon_community_translation/blob/1.0.1/controller.php#L277), and correctly handle this case may be a nightmare |
I have to test it again with the recent develop branch, but it was horrible 2 years ago. We're generating route names nobody can see more than 400 times at every request |
Currently, 2.4% of execution time, 2.5% of CPU usage is wasted to generate route names, but nobody can see that name.
How about to set route names by default?
Package developers still can add custom routes without its name.
This PR is in progress. If the core team looks it's fine, I'll add the remaining route names.