Issue Bug Rejected

#110306SetRegistry rewalks the set dependency graph for every site and every candidate set

Benni Mack 07/27/26, 20:05 updated 10/02/26, 15:40

Description

With many sites, resolving site sets does far more work than necessary: “SetRegistry::getSets()” filters the full list of ordered sets and, for every candidate set, walks the dependency graph from scratch to decide whether that candidate is reachable from the requested set names. Nothing is memoized.

The ordered set list and the dependency graph are identical for all of these calls within a request – “getOrderedSets()” is even persistently cached.

The root cause seems to be “SetRegistry::getSets()”:

return array_values(array_filter(
    $this->getOrderedSets(),
    fn(SetDefinition $set): bool
        => in_array($set->name, $setNames, true)
        || $this->hasDependency($setNames, $set->name)   // per candidate set
));

“hasDependency()” (line 185) recurses through “dependencies” and “optionalDependencies” with no memoization and no visited set. Because it only returns early on a match, a negative answer enumerates every walk through the graph – and the filter asks the negative question for every unrelated set. The
cost is therefore exponential in dependency depth, not linear.

Blackfire shows 31000+ calls to “gtSets()” on an instance with 54 sites.

Reviews 1

History 23

  1. Benni Mack commented and changed status Under Review Rejected <span data-processor="relativetime" data-value="2026-10-02T15:40:23+00:00" > 10/02/26, 15:40 </span>

    caching on site settings helped