Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 296690

Memory usage increases linearly when (un)installing modules via config import

$
0
0

Problem/Motivation

When importing config that has changes to core.extension (i.e enabling or uninstalling modules) memory usage grows linearly based on the number of modules being installed or uninstalled.

On our XL site:

  • When making 5 module changes (2 uninstalls, 3 installs) memory usage jumps to over 1GB.
  • The memory usage seems to be roughly the same if the combination is different (i.e 2 uninstalls and 1 install uses roughly the same memory as 1 uninstall and 2 installs).
  • 3 module changes peaks at ~800MB memory
  • 2 module changes peaks at ~700MB
  • 1 module change peaks at ~600MB

This was profiled using blackfire run php -d memory_limit=-1 ./bin/drush cim -y

Here's a screenshot of the Blackfire memory graph. Everything seems to stem from RouteBuilder::rebuild.

Blackfire profile 5 module changes

Things of note:

  1. 118,000 calls to unserialize
  2. 97,000 calls to serialize
  3. 45,000 SQL queries executed

Interestingly, when profiling a drush updb -y that does the following, memory usage peaked at 250MB:

  $moduleInstaller = \Drupal::service('module_installer');
  $moduleInstaller->install([
    'module1',
    'module2',
    'module3',
  ], FALSE);
  $moduleInstaller->uninstall([
    'module4',
    'module5',
  ], FALSE);

Steps to reproduce

This is probably only applicable to large sites with a lot of routes/config/modules?

There does seem to be a somewhat linear memory usage just by doing the same thing with a standard profile and uninstalling some modules, although obviously MUCH lower memory (less than 200MB)

Proposed resolution

The main thing here is - why does memory usage keep increasing? RouteBuilder::rebuild is called once for every module change. Is there a memory leak in here somewhere?

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 296690

Trending Articles