Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Routing] fix perf issue when dumping large number of routes #30058

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

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #29918
License MIT
Doc PR -

In my reproducer, dumping 12k routes goes from 40s to 3s without xdebug, and from 50s to 12s with xdebug.

There is a lower level issue which is that strpos is called 16M times, but that's still a lot faster than calling preg_match 16M times. Reducing the number of checks is certainly possible, but that would be more involving. This could happen on master if someone is up to dig into it.

Copy link
Member

@javiereguiluz javiereguiluz left a comment

Choose a reason for hiding this comment

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

Nice!

As a minor suggestion, I'd rename some variables:

  • $prefix -> $staticPrefix
  • $p -> $prefix

@nicolas-grekas nicolas-grekas merged commit 872efe5 into symfony:4.2 Feb 7, 2019
nicolas-grekas added a commit that referenced this pull request Feb 7, 2019
…es (nicolas-grekas)

This PR was merged into the 4.2 branch.

Discussion
----------

[Routing] fix perf issue when dumping large number of routes

| Q             | A
| ------------- | ---
| Branch?       | 4.2
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29918
| License       | MIT
| Doc PR        | -

In my reproducer, dumping 12k routes goes from 40s to 3s without xdebug, and from 50s to 12s with xdebug.

There is a lower level issue which is that `strpos` is called 16M times, but that's still a lot faster than calling `preg_match` 16M times. Reducing the number of checks is certainly possible, but that would be more involving. This could happen on master if someone is up to dig into it.

Commits
-------

872efe5 [Routing] fix perf issue when dumping large number of routes
@nicolas-grekas nicolas-grekas deleted the route-perf branch February 7, 2019 19:31
@fabpot fabpot mentioned this pull request Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants