Page MenuHomePhabricator

Improving the function cache
Open, Needs TriagePublic

Description

When digging in the code, I noticed in FilterEvaluator.php that when the function cache is full, it is just entirely emptied.

We could do better, by replacing:

$this->funcCache = [];

with something like:

// remove the 100 oldest entries
$this->funcCache = array_slice( $this->funcCache, 100, null, true );

Another thing, a follow-up to T309609 which raised the condition limit from 1000 to 2000 for WMF wikis:

The function cache still has a limit of 1000, so it may become completely filled (then entirely emptied, see above). It would be much better to have a larger cache so that it can keep all entries.

Rationale: the condition limit is incremented by functions, and also by keywords and by comparisons (search for raiseCondCount in FilterEvaluator.php). Therefore, the function cache should never get filled with more entries than the condition limit.

We could replace this:

if ( count( $this->funcCache ) > 1000 ) {

by something like:

if ( count( $this->funcCache ) > ( $this->condLimitEnabled ? $this->conditionsLimit : 1000 ) ) {