Fixed Bad performance with many route filters.

Yoskaldyr

Well-known member
In the XenForo_Link::buildPublicLink translateRouteFilterToRegex method is called for each route filter.
PHP:
            list($from, $to) = self::translateRouteFilterToRegex(
               $filter['find_route'], $filter['replace_route']
             );
And these calls heavy impact on performance especially on forum index page if the board has many forums/categories with route filters for it.

Why not prepare regex before saving them into 'routeFiltersOut' and 'routeFiltersIn' cache keys?
 
And the same problem with route matching if a many route filters exist.
And performance can be improved by caching regex results and grouping route filters in the 'routeFiltersIn' by prefix.
 
I can change a cache generation and match rules by my add-on and dirty hacks. But it is not too good and better if it will be in a XenForo core.
 
How many is "many route filters"? There isn't really an expectation of thousands (or likely even hundreds) as a targeted use case.
 
Well I have 63 route filters in place because I like to translate everything to my language.

Never noticed performance issues.
 
>500 route filters (one filter per each forum/category).
There isn't really an expectation of thousands (or likely even hundreds) as a targeted use case.
I know it.
But many on-the-fly regexes take lot of cpu time and these regexes can be done before caching. Also on match phase performance will be much greater if the route filters has been grouped by prefix or by first letter or by any other way.

This minimal changes do not break anything and will increase performance greatly on boards with many route filters.
 
Last edited:
Just curious - but why are you using a route filter for every category and forum?
One of my clients wants a separate clean seo-friendly url for each forum/category with different prefixes and different nested levels.

I understand that the route filters feature was designed only for small amount of filters, but with a minimal changing of a code it can handle a much more filters without performance penalties.
 
Back
Top Bottom