Problem/Motivation

The permissions page calls system_rebuild_module_data() to get module names - takes about 3M of memory.

Proposed resolution

Use getName() on the module handler instead.

Remaining tasks

User interface changes

None.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

catch’s picture

catch’s picture

Issue summary: View changes
FileSize
49.73 KB

Right screenshot this time.

catch’s picture

Issue tags: +Performance
kim.pepper’s picture

Status: Needs review » Needs work

Minor nitpick:

+++ b/core/modules/user/src/Form/UserPermissionsForm.php
@@ -41,9 +49,10 @@ class UserPermissionsForm extends FormBase {
+  public function __construct(PermissionHandlerInterface $permission_handler, RoleStorageInterface $role_storage, ModuleHandler $module_handler) {

Needs @param docblock

catch’s picture

Status: Needs work » Needs review
FileSize
2.61 KB

Thanks! Added the @param docblock.

Berdir’s picture

Status: Needs review » Needs work

Nice find, we didn't see this one when improving getName() because it didn't call system_get_info()...

Testing this with the following in index.php, on an beta8 installation with a fair amount of roles and permissions and 215 non-test-folder .info.yml files (core as 74).


$start = microtime(TRUE);

print format_size(memory_get_peak_usage()) . "<br />\n";
print format_size(memory_get_usage()) . "<br />\n";
print round((microtime(TRUE) - $start), 2). "s";

This isn't too exact, since I also had to apply the patch from #2281989: Add a fast and simple way to get module name from the module handler, but it makes a nice difference for me:

Before:

167.32 MB
115.23 MB
15.8s

After:

133.27 MB
81.36 MB
11.09s (varies between 10-12s)

This is with xdebug and xhprof disabled. execution time varies quite a bit, but the memory numbers are stable.

Setting to needs work for the following nitpick:

+++ b/core/modules/user/src/Form/UserPermissionsForm.php
@@ -34,16 +35,26 @@ class UserPermissionsForm extends FormBase {
-  public function __construct(PermissionHandlerInterface $permission_handler, RoleStorageInterface $role_storage) {
+  public function __construct(PermissionHandlerInterface $permission_handler, RoleStorageInterface $role_storage, ModuleHandler $module_handler) {

type hint should be ModuleHandlerInterface (docs are correct).

catch’s picture

Status: Needs work » Needs review
FileSize
2.62 KB

Just that type-hint change.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 7: 2488610_module_handler.patch, failed testing.

catch’s picture

Status: Needs work » Needs review
FileSize
2.63 KB

Use statement also needed updating.

kim.pepper’s picture

Status: Needs review » Reviewed & tested by the community

Looks great.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a major bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 241def3 and pushed to 8.0.x. Thanks!

  • alexpott committed 241def3 on 8.0.x
    Issue #2488610 by catch, kim.pepper, Berdir: Use ModuleHander::getName...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.