Problem/Motivation

On incoming requests, we check resolve aliases to paths.

This runs a query (which is very poor for the MySQL query cache) on every request to check if the path matches a path alias.

If there are no path aliases, the query still runs.

Proposed resolution

Store whether we have any path aliases or not somewhere. (in the path alias whitelist in a magic key? a separate cache item?). If there are no aliases at all, we could compeletely skip the lookup. Want to ensure there isn't an undue cost for sites that do have path aliases.

Remaining tasks

Figure out a solution and patch it.

API changes

Comments

dawehner’s picture

The path alias whitelist is not possible right, because we need to run the path alias conversion before we get to the system path, and just by having that we can get that list of path aliases.

I guess we should need an extra cache entry.

For a while I thought that we could figure out how many path aliases we have on container build time and then skip registering those services in total, but I realized that this was BS.
Another idea I had in mind is that in D8, unless d7, we could actually move every functionality of the path alias system into its own module, which would allow you to simply disable the entire functionality, move the inbound/outbound processor to path module, as well the alias manager, or at least the fact that we register those services.

catch’s picture

The path alias whitelist is not possible right, because we need to run the path alias conversion before we get to the system path, and just by having that we can get that list of path aliases.

Very good point.

Another idea I had in mind is that in D8, unless d7, we could actually move every functionality of the path alias system into its own module, which would allow you to simply disable the entire functionality, move the inbound/outbound processor to path module, as well the alias manager, or at least the fact that we register those services.

Large-ish change but possibly the cleanest. Although we already have path.module so it'd either need to move in there or could get confusing with names.

catch’s picture

The path alias whitelist is not possible right, because we need to run the path alias conversion before we get to the system path, and just by having that we can get that list of path aliases.

Sorry this actually isn't such a good point.

There are two things we do to reduce queries:

1. A whitelist of system path roots (so node, user, admin etc.) where there is at least one alias assigned to a system path matching that. This is global for the whole site so it's available where we'd need it.

2. A pre-load cache of system paths for outbound alias look-ups - this is per system-path and not available, so we can't use it here.

For #1 that's quite possible to use. The trick though is we'd either need to add a method, or use a magic key like AliasWhitelistManager::HAS_ANY_ALIAS and handle that differently in resolveCacheMiss() - then we do a SELECT 1 FROM {path_alias} LIMIT 0, 1 if it's not set. That would save the additional cache entry but don't love the magic key.

dawehner’s picture

So we now cache things per incoming path already, so I think we don't run this query too often.
@catch
Do you think our routing level caching is enough?

catch’s picture

@dawehner we could skip the query and the cache for sites with no aliases. So if we care about those sites, it'd be an improvement for them.

dawehner’s picture

Honestly, that sounds a bit like an edge case usecase for me ... those could use a contrib module which swaps out the path services to do just nothing.

catch’s picture

That's reasonable. Or we could look at defaulting to a null service in core, then letting path/path alias wire it up.

dawehner’s picture

This would be an API break, because well, you can use already path aliases via API and then enable path module to deal with it. Path is afaik more of a path_ui module at this point.

catch’s picture

Version: 8.0.x-dev » 9.x-dev

Yes it'd be an API break, just that might be something to do in 9.x.

catch’s picture

Version: 9.x-dev » 8.1.x-dev
Priority: Normal » Minor
Status: Active » Postponed

Well there might be more alias-free websites than we think - i.e. something which only does REST. Moving to 8.1.x for now.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Postponed » Active

I have not triaged this issue, I just notice that it is no longer postponed.

Berdir’s picture

Status: Active » Closed (outdated)

I'm going ahead and closing this as outdated.

AliasManager is part of the path_alias module now. If you do not want aliases at all, you can disable that module and then no alias lookups happen, ever.