This is a first attempt at per-path path caching, but a much dumber approach than.
We cache two things:
1. Per $_GET['q'] cache the system paths for that page.
This is set to CACHE_TEMPORARY because it's likely to get outdated fairly quickly, and because it's just a single cache entry per page so cheap to rebuild. This is taken from information already collected in the $map static from drupal_lookup_path() and is set in drupal_page_footer()
2. Cache each path alias individually by language.
This avoids duplicating storage, and we're getting the paths out of cache in one query due to cache_get_multiple(). These cache entries will need to be cleared in path_set_alias() - not done that yet.
In drupal_lookup_path() - we fetch all the system paths which were on that page when we last cached them, and use cache_get_multiple() to fetch all the path aliases which match those. That means all paths which actually have aliases are dealt with in two database queries.
Anything not fetched from cache, goes through the normal drupal_lookup_path() query.
This works out as a query less per page per path alias which appears on that page. The only consequence of the system_path cache getting stale is that less paths will be fetched from cache - nothing will actually get broken.
I'm thinking about caching which system paths are no-ops as well, but again not there yet, just posting what I have so far.
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 456824-drupal-lookup-path-slow-query_for-6.20.patch. View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 456824-drupal-lookup-path-slow-query.patch. View