Problem/Motivation
THIS IS NOT ABOUT CACHING THE ACTUAL ROUTING
In order to be able to support linking to paths directly and checking access, we need to do
the following:
- Convert the path to a route on runtime
- Check access using that route
The second bit will be solved by cacheable access checking.
The first bit is not cacheable first, let's do that.
Proposed resolution
Given that the determined route of a menu link just varies by path, we can use the UrlMatcherInterface and provide a wrapper
which caches the result. With that checking access to path based menu links can be done faster in the future.
Ones we have the path => route resolution cached, we can store the paths for menu links, not having to worry about the access checking performance
in the future.
Even if core doesn't implement it, also contrib could implement a path only based menu link and reuse the functionality added in this issue.
Remaining tasks
User interface changes
API changes
Beta phase evaluation
Issue category | Tasks because it allows us to to use paths potentially for menu links without a big sacrifice of performance |
---|---|
Issue priority | TODO |
Disruption | Not disruptived at all, it just adds an internal API. |
Comment | File | Size | Author |
---|---|---|---|
#42 | interdiff.txt | 444 bytes | kim.pepper |
#42 | 2370651-path-route-cache-42.patch | 15.18 KB | kim.pepper |
#40 | interdiff.txt | 818 bytes | kim.pepper |
#40 | 2370651-path-route-cache-40.patch | 15.21 KB | kim.pepper |
#38 | interdiff.txt | 597 bytes | kim.pepper |
Comments
Comment #1
dawehnerThere we go.
Comment #3
dawehnerHa.
Comment #5
dawehnerThis seems to be a random one.
Comment #7
dawehner... Added some debug statements.
Comment #9
amateescu CreditAttribution: amateescu commented@dawehner, this might be handy: https://twitter.com/andrei_mateescu/status/344855495967928320 :)
Comment #10
dawehnerSeems not a random test failure but I cannot really preproduce it.
Comment #11
dawehnerComment #14
dawehnerHa!
Comment #15
jibranI believe we need tests here.
Comment #16
dawehnerAlright, this time with more test coverage.
Comment #17
catchSee #643984: Cache menu_get_item() and #1234830: Revert cache_menu patch removal, add a $conf setting instead (was: cache_menu: huge table size).
Short version - this is an absolute necessity to keep some sites up (MySQL query cache saved by memcache), but it can also take other sites down (cache table size growing out of control using MySQL for the cache).
On the 7.x issue we were discussing making it configurable.
For 8.x I'm wondering if we want a special cache bin that requires a size-limited cache backend, but otherwise uses the null or memory cache backend if one isn't available.
Comment #18
dawehnerMh, this is not yet caching the routing by request.
@catch
Was this caused by the menu_get_item() call for routing or by the ones needed for menu item loading?
Comment #19
catchMenu items never had a menu_get_item() to load the route - the route was loaded with the menu links as part of the database query via join. This is part of the reason Drupal 8 routing is so much slower for menu link rendering. See for example #1845402-5: Update menu link access checks for new router for a slightly longer description of the regression.
So while there can be other menu_get_item() calls with a path name in 7.x, nearly all of them were for the incoming request not for link generation.
The issue here is that there can be potentially millions of valid paths on a site (nodes + users + $entity_type), and if the site is being crawled that will fill the cache quite quickly. Also the original patch that went in had this as a permanent cache entry (since it's valid until the router changes).
Comment #20
dawehnerComment #22
dawehnerUps.
Comment #23
dawehnerchx made a point.
Comment #24
Fabianx CreditAttribution: Fabianx commentedI would totally RTBC this, it looks great!
Comment #25
alexpottThe service or class name should be more consistent?
Missing documentation - looks like it should be on the interface.
Currently this will result in just shoving stuff in memory that is never used. How caching if a cache backend is injected and defaulting to the backend to NULL.
Comment #26
alexpottComment #27
dawehnerI on purpose did not set it onto the interface, because its a pure implementation detail to avoid circular dependencies.
I hope this new paragraph helps a bit.
@catch request caching of those bits, but I don't want to introduce it at that point, given that its a more complex topic than path only based routing.
Let's split up this part into another issue: #2406117: potentially cache parts of routing
Comment #29
dawehnerFixed that.
Comment #31
dawehnerThis contained some unrelated changes from a different patch
Comment #32
jibranBE in IS is not complete and one minor nit. I think it is ready.
I think line commenting is wrong here we should use block commenting.
Comment #33
dawehnerRerolled and fixed the points in the review #32.
Comment #35
dawehnerComment #36
dawehnerAdapt the title.
Comment #37
dawehnerComment #38
kim.pepperFixes editable config test failure.
Comment #40
kim.pepperFix more editable config fails.
Comment #41
aspilicious CreditAttribution: aspilicious commentedA file has been deleted that shouldn't be deleted ;)
Comment #42
kim.pepperWhoops!
Comment #43
bill richardson CreditAttribution: bill richardson as a volunteer commentedPatch requires re-roll - setting to needs work.
Comment #44
dawehnerYeah I don't think we will need this any longer