Problem/Motivation

Spin-off from #3456244: Normalize the incoming path with urldecode directly in RouteProvider, I think we can make the caching more efficient.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Before:


| route:[language]=en:[query_parameters]=:/abcde             | a:3:{s:4:"path";s:6:"/abcde";s:5:"query";a:0:{}s:6:"routes";O:41:"Symfony\Component\Routing\RouteCollection":4:{s:49:" Symfony\Component\Routing\RouteCollection routes";a:0:{}s:50:" Symfony\Component\Routing\RouteCollection aliases";a:0:{}s:52:" Symfony\Component\Routing\RouteCollection resources";a:0:{}s:53:" Symfony\Component\Routing\RouteCollection priorities";a:0:{}}}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

After:

| route:[language]=en:[query_parameters]=:/abcdef            | a:3:{s:4:"path";s:7:"/abcdef";s:5:"query";a:0:{}s:6:"routes";b:0;}                                                 

Release notes snippet

Issue fork drupal-3461860

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

catch created an issue. See original summary.

catch’s picture

Issue tags: +Performance

MR does two things:

1. When generating the cache ID, runs the same logic as the decode inbound path processor. That processor should be merged into the router, all it does by trying to decouple it is create inconsistencies. See #3456244: Normalize the incoming path with urldecode directly in RouteProvider for more.

2. When no routes are found, instead of caching a serialized empty route collection, caches FALSE instead. Given 404s are unbounded, while this is a relatively small saving, it's potentially multiplied by a lot of cache items.

andypost’s picture

Status: Active » Needs review
catch’s picture

Status: Needs review » Active
catch’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

early returns make sense.

Not for this issue but would be neat to eventually have a performance test around caching if possible?

catch’s picture

I did think about test coverage here but all we could really do is assert the contents of the cache entry when no routes are found rather than a performance test, which feels a bit too much like repeating what the code does.

nod_’s picture

Status: Reviewed & tested by the community » Needs work

some phpcs issue

catch’s picture

Status: Needs work » Reviewed & tested by the community

Sorry, sloppiness.

  • nod_ committed 41ac5c14 on 10.4.x
    Issue #3461860 by catch, smustgrave: More efficient route lookup caching...

  • nod_ committed da5f6215 on 11.x
    Issue #3461860 by catch, smustgrave: More efficient route lookup caching
    
nod_’s picture

Version: 11.x-dev » 10.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed da5f6215a9 to 11.x and 41ac5c1446 to 10.4.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.