At http://drupal.org/node/197720 we identified that Drupal eats considerably more amount of memory on the modules page. This is due to all .install files being included and checked for possible update functions not run yet. Even if the PHP memory limit is made higher, this page might display a WSOD.

The reason .install files are included is to check whether they have newer update functions not yet run on the local database. So the admin is informed that certain modules need their updates run. So we need the list of update functions defined in each module enabled.

A few options to not include the .install file to get this list:

(a) Not serious: introduce a new hook to specify the latest update number. But this would need to be updated by hand, and the info is already in .install files.

(b) Preg through the .install files (so we can load and *unload* them), grepping for update functions. This sounds easy but could have false positives in commented update functions. The only real problem here would be if update functions later then the ones run already are commented out. I'd say his is highly unlikely.

(c) Load in .install files and tokenize them one by one. Then in the tokenized form, we can look up the function definitions. This surely avoids the comment problem from the previous option, but takes considerably more memory, as we would need to have the tokenized source of one .install file in memory at a time. This might end up requiring more memory memory in core itself as the tokenized source takes up more memory is a PHP array then when we include the file and tokenization takes place in PHP's internals (without userspace data access). *But*, we can unset() the file string and the token array, once done with a file, and we can go to the next. This also takes more time most probably then (b).

All these options can decrease the memory requirement for the modules page considerably. Although (c) might not decrease it for core-only installations, it will definitely decrease it for contrib (when lots more install files are loaded, so the fact that we can unload stuff becomes more of an advantage).

Opinions? Anyone up for implementation?

Comments

JirkaRybka’s picture

I like the (b) solution most. If the preg checks for something like [newline]function [module]_update_[digits](, it will catch the // or # comments, leaving only just /* big block */ problem - I think it's not likely to occur on *latest* function in *released* code, it's quite edge case, and we risk maximally a false alarm prompting the user to run update.php (which then do nothing). Also this may be documented somewhere.

moshe weitzman’s picture

yes, b) sounds reasonable to me too.

scor’s picture

could the cron be used to do these operations in batch and cache somehow the relevant updates in the db?

moshe weitzman’s picture

scor - thats a performance optimization thats not needed. this mega load is a very infrequent event.

JirkaRybka’s picture

Additional thoughts:

I think that update.php should be fixed in the same patch, re-using the same detection mechanism. It's a pretty similar case: All .install files included after full bootstrap (and going to be even worse, if the disabled modules update patch lands - http://drupal.org/node/194310 ).

This will also make update.php offering the same versions as reported on modules page, thus partially fixing the "commented function" problem (in the sense of avoiding user's confusion, when update.php offered nothing after a warning shown on modules page).

The actual inclusion of .install files would be then done one-by-one in the batch processing, cutting on the update.php footprint. I'm not sure whether this is important, but keeping update.php on the safe side is always nice.

This will all result in the commented-out functions included in the update.php batch, though. But I think this may be easily solved by a simple function_exists() check, so that the commented-out functions will then behave just like if only just their content was commented-out.

So, we need to re-factor drupal_get_schema_versions() to the preg method, remove drupal_load_updates() here and there, and add module_load_install() and function_exists() to the batch. Opinions?

I'm not sure whether I'll find time to try and implement this, though.

Crell’s picture

I'm actually working on an enhanced version of the page-split system for Drupal 7 that uses token_get_all(), so I'd actually favor C. While the tokenized version of each file will be non-small, we'll only ever have one in memory at a time so the cost is relatively flat.

Also not sure if I'll have a chance to work on this in the next day or two, but I'll see if I can play with it and come up with anything.

dpearcefl’s picture

Component: update system » ajax system
Status: Active » Postponed (maintainer needs more info)

Is this still a problem in current D6?

Crell’s picture

Version: 6.x-dev » 8.x-dev
Status: Postponed (maintainer needs more info) » Active
Issue tags: +Performance, +memory

The "enhanced page split" I talked about in #6 is the registry, which sadly got ripped out later in Drupal 7's lifetime (at least for functions). I believe the class registry ended up using option B, string parsing, over tokenizing.

This probably is worth revisting for D7/D8, but not for D6. Refiling.

rfay’s picture

Component: ajax system » database update system
catch’s picture

This is very closely related to #1188084: Try to avoid loading every specified include file during theme registry rebuilds. (where we load very many if not all .pages.inc and .admin.inc also just looking for functions).

We are not going to be able to avoid loading all .install files from this though, because they're also loaded for hook_requirements() iirc. However it would be a good start.

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

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should 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.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should 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.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should 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.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should 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.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should 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.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should 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.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should 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: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Active » Postponed (maintainer needs more info)

Wonder if this can be closed? To my knowledge the update functions are displayed on the modules page? (Least I've never seen)

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.